Skip to main content

rlx_models_core/
lib.rs

1// RLX — versatile ML compiler + runtime.
2// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, version 3.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16//! Shared infrastructure for RLX model crates: HuggingFace config parsing,
17//! safetensors / GGUF weight loading, and tier-1 compile profile helpers.
18
19pub mod arch_registry;
20pub mod autoregressive;
21pub mod config;
22pub mod dataprocessing;
23pub mod device_capabilities;
24pub mod flow_bridge;
25pub mod flow_util;
26pub mod gguf_config;
27pub mod gguf_resolve;
28pub mod gguf_support;
29pub mod lm;
30pub mod moe_weights;
31pub mod vision_ops_ir;
32pub mod weight_loader;
33pub mod weight_map;
34pub mod weight_registry;
35pub mod weights;
36
37pub use device_capabilities::{
38    STANDARD_DEVICE_NAMES, STANDARD_DEVICES, device_memory_for_moe_offload, is_standard_device,
39    validate_sam_device, validate_standard_device,
40};
41
42pub use gguf_config::{
43    DINOV2_GGUF_ARCHES, EMBED_GGUF_ARCHES, EmbedGgufKind, FLUX_GGUF_ARCHES, GgufMemoryFootprint,
44    SAM_GGUF_ARCHES, SAM2_GGUF_ARCHES, SAM3_GGUF_ARCHES, VJEPA2_GGUF_ARCHES, W2V_BERT_GGUF_ARCHES,
45    embed_gguf_kind, gguf_memory_footprint, gguf_meta_u32, gguf_runner_hint, is_dinov2_gguf_arch,
46    is_embed_gguf_arch, is_flux_gguf_arch, is_sam_gguf_arch, is_sam2_gguf_arch, is_sam3_gguf_arch,
47    is_vjepa2_gguf_arch, is_w2v_bert_gguf_arch,
48};
49pub use gguf_resolve::{
50    GgufTensorNameResolver, LlamaFamilyGgufResolver, PassThroughGgufResolver,
51    PrefixStripGgufResolver, Qwen35NativeGgufResolver, register_gguf_tensor_resolver,
52    resolve_gguf_tensor_name,
53};
54pub use gguf_support::{
55    GgufModelFamily, ResolveWeightsOptions, assert_gguf_family, gguf_architecture_from_path,
56    gguf_architecture_str, gguf_f32_bytes_estimate, gguf_family_for_arch,
57    gguf_safetensors_only_hint, gguf_split_hint, gguf_split_siblings, gguf_validate_arch,
58    list_gguf_files_in_dir, load_gguf_file, resolve_weights_file,
59    resolve_weights_file_with_options,
60};
61
62pub use autoregressive::{
63    KvCacheState, compile_cache_ensure_graph, kv_from_prefill_outputs, past_kv_input_names,
64    prefill_cache_key, run_bucketed_kv_decode, run_bucketed_kv_decode_hir,
65    split_bucketed_decode_kv, split_decode_logits_kv,
66};
67pub use config::{BertConfig, NomicBertConfig, NomicVisionConfig};
68pub use flow_bridge::{
69    apply_compile_profile, compile_graph_encoder, compile_graph_gemma_decode,
70    compile_graph_gemma_prefill, compile_graph_legacy, compile_graph_llama32_decode,
71    compile_graph_llama32_prefill, compile_graph_qwen3_decode, compile_graph_qwen3_prefill,
72    compile_graph_qwen35_decode, compile_graph_qwen35_prefill, compile_graph_sam,
73    compile_graph_with_profile, load_compile_profile, profile_near_weights,
74};
75pub use flow_util::{
76    WeightMapSource, bucket_cache_ensure_built, build_graph, built_from_graph, built_from_hir,
77    built_from_hir_with_profile, compile_built, compile_built_cpu, compile_cache_ensure_built,
78    compile_graph_encoder_with_params, compile_graph_gemma_decode_with_params,
79    compile_graph_gemma_prefill_with_params, compile_graph_profile,
80    compile_graph_qwen3_prefill_with_params, compile_graph_qwen35_decode_with_params,
81    compile_graph_qwen35_prefill_with_params, compile_graph_sam_with_params,
82    compile_graph_with_kv_export_params, graph_from_built, graph_from_hir,
83};
84pub use gguf_resolve::ensure_builtin_resolvers;
85pub use gguf_support::DEFAULT_GGUF_PREFER_SUBSTR;
86pub use lm::{FlowBuildExt, into_compile_parts};
87pub use weight_loader::{
88    GgufLoader, HfTranslatingLoader, WeightLoader, ggml_type_to_quant_scheme, gguf_to_hf_name,
89    gguf_to_hf_name_for_arch, hf_to_gguf_name, is_mtp_weight, load_from_path,
90};
91pub use weight_map::{WeightDrainPolicy, WeightMap};
92pub use weight_registry::{
93    LoadWeightsOptions, LoadedWeights, RegisteredFormat, WeightFormatRegistration,
94    format_for_extension, list_registered_formats, load_weight_map_resolved, load_weights_resolved,
95    open_weight_loader, register_weight_format, registered_extensions_hint,
96};
97pub use weights::{
98    GgufDirGuide, LoadOpts, ResolveOpts, default_resolve_opts, gguf_dir_guide, init,
99    load_weight_map, open, open_map, open_map_with, open_with, pick, pick_default,
100};