Skip to main content

ferrox_models/
lib.rs

1//! ferrox-models: GGUF decoder, architecture registry, and structural
2//! presets for frontier stacks (GLM / DeepSeek V4 / Kimi).
3//!
4//! Unconfirmed preset fields go in `best_effort_fields` and must be
5//! overwritten from real `config.json` / GGUF metadata. Status of what
6//! actually runs: `docs/MODELS.md`. Presets `glm_5_2` / `deepseek_v4_pro`
7//! / `kimi_k3` are sketches for synthetic tests — not real-checkpoint
8//! support. Dedicated primitives live in `glm52_*`, `deepseek_v4_*`,
9//! `kimi_*` modules.
10
11pub mod bert_encoder;
12pub mod bert_gguf_loader;
13pub mod block_residual;
14pub mod capability;
15pub mod chat_template;
16pub mod clamp_kqv;
17pub mod config;
18pub mod decoder;
19pub mod deepseek_v4_budget;
20pub mod deepseek_v4_decoder;
21pub mod device_budget;
22pub mod draft_model;
23pub mod dry;
24pub mod embedding_model;
25pub mod encoder;
26pub mod engine;
27pub mod engine_factory;
28pub mod execution_plan;
29pub mod gdn;
30pub mod gemma4_engine;
31pub mod gemma4_gguf_loader;
32pub mod glm52_decoder;
33pub mod glm52_gguf_loader;
34pub mod glm_dsa;
35pub mod grammar;
36pub mod grammar_sampler;
37pub mod hf_pull;
38#[cfg(feature = "hub")]
39pub mod hub;
40pub mod hybrid_engine;
41pub mod hybrid_gguf_loader;
42pub mod hyper_connections;
43pub mod kda;
44pub mod kimi_decoder;
45pub mod kimi_generate;
46pub mod kimi_gguf_loader;
47pub mod kimi_loader;
48pub mod kimi_tokenizer;
49pub mod kimi_validate;
50pub mod kv_budget;
51pub mod latent_moe;
52pub mod llama4_engine;
53pub mod loader;
54pub mod minimax_engine;
55pub mod mla;
56pub mod mla_gguf_loader;
57pub mod mmproj;
58pub mod moe_interleave;
59pub mod norm;
60pub mod output_projection;
61pub mod penalty_window;
62pub mod pooling;
63pub mod prefix_cache;
64pub(crate) mod qkv_fused;
65pub mod rank_head;
66pub mod recurrent_engine;
67pub mod residency_report;
68pub mod rope_finetuned;
69pub mod rope_layers;
70pub mod rope_ntk_alpha;
71pub(crate) mod sampler_chain;
72pub mod sampler_order;
73pub mod sampling;
74pub mod scalar_multipliers;
75pub mod speculative;
76pub mod t5_engine;
77pub mod tensor_role;
78pub mod tokenizer;
79pub mod vision;
80pub mod vl_engine;
81
82pub use bert_encoder::{BertEncoder, BertHparams, BertLayer};
83pub use bert_gguf_loader::{load_bert_encoder_from_path, read_bert_hparams, BERT_ARCH};
84pub use capability::{
85    architecture_catalog, coverage_report_markdown, resolve_architecture, resolve_profile,
86    ArchPath, ArchProfile, ArchScope, DecoderFamily, MemoryKind, QkNormStyle,
87};
88pub use config::{deepseek_v4_pro, glm_5_2, kimi_k3, FfnActivation, ModelConfig, RopeLayout};
89pub use decoder::{Decoder, MultiSeqKv};
90pub use device_budget::{BudgetBackend, DeviceBudget};
91pub use draft_model::{DraftModelSpeculator, VocabMismatch};
92pub use embedding_model::{is_embedding_arch, EmbedError, EmbeddingModel};
93pub use encoder::{EncodeError, PairSequence, TextEncoder};
94pub use engine::{
95    DeepseekV4Engine, Engine, Glm52Engine, KimiEngine, MlaDenseFfn, MlaEngine, MlaLayerFfn,
96    MlaLayerWeights, MlaMoeFfn, MlaMoeRuntime, TextTokenizer,
97};
98pub use engine_factory::{
99    ensure_generic_decoder, load_gemma4_engine_from_path, load_glm52_engine_from_path,
100    load_mla_engine_from_path, select_engine_kind, EngineSelectError, SelectedEngineKind,
101    ServedEngine,
102};
103pub use execution_plan::{ExecutionPlan, FusedOpCaps, MemoryPlan, PlanGeometry};
104pub use gemma4_engine::{Gemma4Engine, Gemma4Hparams, GEMMA4_ARCHES};
105pub use kv_budget::{
106    Ceiling, ContextCap, ContextFit, KvBudget, KvBudgetError, KvElem, KvLayout, KvResidency,
107    KvShape, CTX_AUTO_GRANULARITY,
108};
109pub use loader::LoadError;
110pub use norm::NormOp;
111pub use output_projection::grouped_output_projection;
112pub use penalty_window::PenaltyWindow;
113pub use pooling::{l2_normalize, pool, PoolingError, PoolingType};
114pub use prefix_cache::{PrefixCache, PrefixCacheStats, PrefixMatch};
115pub use rank_head::{load_rank_head, RankHead};
116pub use sampler_order::{ChainStep, SamplerName, SamplerOrder, SamplerOrderError};
117pub use sampling::{sampling_distribution, Sampler, SamplingParams};
118pub use speculative::{
119    accept_or_resample, speculative_decode, speculative_decode_with, DraftBlock, DraftDist,
120    Drafter, PromptLookupSpeculator, SpeculativeDecodeResult, SpeculativeOptions,
121};
122pub use tensor_role::TensorRole;
123pub use tokenizer::{
124    ByteTokenizer, GgufBpeTokenizer, GgufSpmTokenizer, GgufUnigramTokenizer,
125    GgufWordPieceTokenizer, NormalizerOptions, TokenizerLoadError,
126};
127
128#[cfg(feature = "metal")]
129pub use ferrox_metal::attn::{metal_greedy_argmax_active, set_metal_greedy_argmax};