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, tier-1 compile profile helpers, and
18//! packed GGUF prefill guards ([`flow_bridge::packed_gguf_compile_guard`], etc.).
19
20pub mod arch_registry;
21pub mod autoregressive;
22pub mod config;
23pub mod dataprocessing;
24pub mod device_capabilities;
25pub mod flow_bridge;
26pub mod flow_util;
27pub mod gguf_config;
28pub mod gguf_resolve;
29pub mod gguf_support;
30pub mod lm;
31pub mod moe_weights;
32pub mod vision_ops_ir;
33pub mod weight_loader;
34pub mod weight_map;
35pub mod weight_registry;
36pub mod weights;
37
38pub use device_capabilities::{
39    STANDARD_DEVICE_NAMES, STANDARD_DEVICES, device_memory_for_moe_offload, is_standard_device,
40    validate_sam_device, validate_standard_device,
41};
42
43pub use gguf_config::{
44    DINOV2_GGUF_ARCHES, EMBED_GGUF_ARCHES, EmbedGgufKind, FLUX_GGUF_ARCHES, GgufMemoryFootprint,
45    SAM_GGUF_ARCHES, SAM2_GGUF_ARCHES, SAM3_GGUF_ARCHES, VJEPA2_GGUF_ARCHES, W2V_BERT_GGUF_ARCHES,
46    embed_gguf_kind, gguf_memory_footprint, gguf_meta_u32, gguf_runner_hint, is_dinov2_gguf_arch,
47    is_embed_gguf_arch, is_flux_gguf_arch, is_sam_gguf_arch, is_sam2_gguf_arch, is_sam3_gguf_arch,
48    is_vjepa2_gguf_arch, is_w2v_bert_gguf_arch,
49};
50pub use gguf_resolve::{
51    GgufTensorNameResolver, LlamaFamilyGgufResolver, PassThroughGgufResolver,
52    PrefixStripGgufResolver, Qwen35NativeGgufResolver, register_gguf_tensor_resolver,
53    resolve_gguf_tensor_name,
54};
55pub use gguf_support::{
56    GgufModelFamily, ResolveWeightsOptions, assert_gguf_family, gguf_architecture_from_path,
57    gguf_architecture_str, gguf_f32_bytes_estimate, gguf_family_for_arch,
58    gguf_safetensors_only_hint, gguf_split_hint, gguf_split_siblings, gguf_validate_arch,
59    list_gguf_files_in_dir, load_gguf_file, resolve_weights_file,
60    resolve_weights_file_with_options,
61};
62
63pub use autoregressive::{
64    KvCacheState, compile_cache_ensure_graph, kv_from_prefill_outputs, past_kv_input_names,
65    prefill_cache_key, run_bucketed_kv_decode, run_bucketed_kv_decode_hir,
66    split_bucketed_decode_kv, split_decode_logits_kv,
67};
68pub use config::{BertConfig, NomicBertConfig, NomicVisionConfig};
69pub use flow_bridge::{
70    apply_compile_profile, compile_graph_encoder, compile_graph_gemma_decode,
71    compile_graph_gemma_prefill, compile_graph_legacy, compile_graph_llama32_decode,
72    compile_graph_llama32_prefill, compile_graph_qwen3_decode, compile_graph_qwen3_prefill,
73    compile_graph_qwen35_decode, compile_graph_qwen35_prefill, compile_graph_sam,
74    compile_graph_with_profile, compile_options_for_packed_gguf_prefill,
75    compile_options_for_packed_gguf_prefill_with_profile, compile_options_for_profile,
76    load_compile_profile, packed_gguf_compile_guard, packed_gguf_execution_device,
77    profile_near_weights,
78};
79pub use flow_util::{
80    WeightMapSource, bucket_cache_ensure_built, build_graph, built_from_graph, built_from_hir,
81    built_from_hir_with_profile, compile_built, compile_built_cpu, compile_cache_ensure_built,
82    compile_graph_encoder_with_params, compile_graph_gemma_decode_with_params,
83    compile_graph_gemma_prefill_with_params, compile_graph_profile,
84    compile_graph_qwen3_prefill_with_params, compile_graph_qwen35_decode_with_params,
85    compile_graph_qwen35_prefill_with_params, compile_graph_sam_with_params,
86    compile_graph_with_kv_export_params, graph_from_built, graph_from_hir,
87};
88pub use gguf_resolve::ensure_builtin_resolvers;
89pub use gguf_support::DEFAULT_GGUF_PREFER_SUBSTR;
90pub use lm::{FlowBuildExt, into_compile_parts};
91pub use weight_loader::{
92    GgufLoader, HfTranslatingLoader, WeightLoader, ggml_type_to_quant_scheme, gguf_to_hf_name,
93    gguf_to_hf_name_for_arch, hf_to_gguf_name, is_mtp_weight, load_from_path,
94};
95pub use weight_map::{WeightDrainPolicy, WeightMap};
96pub use weight_registry::{
97    LoadWeightsOptions, LoadedWeights, RegisteredFormat, WeightFormatRegistration,
98    format_for_extension, list_registered_formats, load_weight_map_resolved, load_weights_resolved,
99    open_weight_loader, register_weight_format, registered_extensions_hint,
100};
101pub use weights::{
102    GgufDirGuide, LoadOpts, ResolveOpts, default_resolve_opts, gguf_dir_guide, init,
103    load_weight_map, open, open_map, open_map_with, open_with, pick, pick_default,
104};