Skip to main content

frink_models/
lib.rs

1//! frink-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 act_layers;
12pub mod alibi;
13pub mod attn_gate;
14pub mod attn_temperature;
15pub mod attn_value_scale;
16pub mod bert_encoder;
17pub mod bert_gguf_loader;
18pub mod block_residual;
19pub mod capability;
20pub mod chat_template;
21pub mod chunked_swa;
22pub mod clamp_kqv;
23pub mod config;
24pub mod decoder;
25pub mod deepseek_v4_budget;
26pub mod deepseek_v4_decoder;
27pub mod device_budget;
28pub mod draft_model;
29pub mod dry;
30pub mod embedding_model;
31pub mod encoder;
32pub mod engine;
33pub mod engine_factory;
34pub mod execution_plan;
35pub mod gdn;
36
37/// When a whole decoder layer can run in ONE Metal submission, and the
38/// weights it takes. The refusals are exhaustive by construction.
39#[cfg(feature = "metal")]
40pub mod fused_layer;
41
42/// The `-ctk` value vocabulary, which is llama.cpp's.
43pub mod ctk;
44/// What `--list-devices` prints, shared by both front ends.
45pub mod devices;
46pub mod gemma4_engine;
47pub mod gemma4_gguf_loader;
48pub mod glm52_decoder;
49pub mod glm52_gguf_loader;
50pub mod glm_dsa;
51pub mod grammar;
52pub mod grammar_sampler;
53pub mod hadamard_fold;
54pub mod hf_pull;
55pub mod hrm;
56#[cfg(feature = "hub")]
57pub mod hub;
58pub mod hybrid_engine;
59pub mod hyper_connections;
60pub mod kda;
61pub mod kimi_decoder;
62pub mod kimi_generate;
63pub mod kimi_gguf_loader;
64pub mod kimi_loader;
65pub mod kimi_tokenizer;
66pub mod kimi_validate;
67pub mod kv_budget;
68pub mod kv_head_dims;
69pub mod latent_moe;
70pub mod layer_loops;
71pub mod layer_shapes;
72/// MiniMax-01's lightning attention block.
73pub mod lightning;
74pub mod loader;
75pub mod lora;
76pub mod lora_attach;
77pub mod mamba1;
78pub mod mamba2;
79/// Metal launch descriptions built from a `WeightMatrix`, in one place
80/// because the decoder and the recurrent branch both read them.
81#[cfg(feature = "metal")]
82pub(crate) mod metal_launch;
83pub mod minimax_engine;
84pub mod mla;
85pub mod mla_arch;
86pub mod mla_gguf_loader;
87pub mod mla_q_proj;
88pub mod mla_yarn;
89pub mod mmproj;
90pub mod moe_interleave;
91pub mod mrope;
92pub mod mtp_blocks;
93pub mod norm;
94pub mod norm_sites;
95pub mod normed_residual;
96pub mod output_projection;
97pub mod parallel_dense_ffn;
98pub mod parallel_residual;
99pub mod penalty_window;
100pub mod plamo2_ssm;
101pub mod pooling;
102pub mod position_embd;
103pub mod prefix_cache;
104pub mod proj_bias;
105pub mod qk_layer_norm;
106pub(crate) mod qkv_fused;
107pub mod rank_head;
108pub mod recurrent_engine;
109pub mod rerank_pooler;
110pub mod residency_report;
111pub mod rope_finetuned;
112pub mod rope_layers;
113pub mod rope_ntk_alpha;
114pub mod routed_weight_site;
115pub mod router_input;
116pub mod safetensors_f32;
117pub(crate) mod sampler_chain;
118pub mod sampler_order;
119pub mod sampling;
120pub mod scalar_multipliers;
121pub mod shortconv;
122pub mod skip_stream;
123pub mod speculative;
124pub mod ssm_block;
125pub mod sub_norms;
126pub mod swa_geometry;
127pub mod swa_layers;
128pub mod t5_engine;
129pub mod tensor_role;
130#[cfg(test)]
131pub(crate) mod test_source;
132pub mod tokenizer;
133pub mod unread_tensors;
134pub mod vision;
135pub mod vl_engine;
136pub mod weight_scales;
137pub mod weightless_qk_norm;
138pub mod yarn_magnitude;
139
140pub use bert_encoder::{BertEncoder, BertHparams, BertLayer};
141pub use bert_gguf_loader::{load_bert_encoder_from_path, read_bert_hparams, BERT_ARCH};
142pub use capability::{
143    architecture_catalog, coverage_report_markdown, resolve_architecture, resolve_profile,
144    ArchPath, ArchProfile, ArchScope, DecoderFamily, MemoryKind, QkNormStyle,
145};
146pub use config::{deepseek_v4_pro, glm_5_2, kimi_k3, FfnActivation, ModelConfig, RopeLayout};
147pub use decoder::{Decoder, MultiSeqKv};
148pub use device_budget::{BudgetBackend, DeviceBudget};
149pub use draft_model::{DraftModelSpeculator, VocabMismatch};
150pub use embedding_model::{is_embedding_arch, EmbedError, EmbeddingModel};
151pub use encoder::{EncodeError, PairSequence, TextEncoder};
152pub use engine::{
153    DeepseekV4Engine, Engine, Glm52Engine, KimiEngine, MlaDenseFfn, MlaEngine, MlaLayerFfn,
154    MlaLayerWeights, MlaMoeFfn, MlaMoeRuntime, TextTokenizer,
155};
156pub use engine_factory::{
157    ensure_generic_decoder, load_gemma4_engine_from_path, load_glm52_engine_from_path,
158    load_mla_engine_from_path, select_engine_kind, EngineSelectError, SelectedEngineKind,
159    ServedEngine,
160};
161pub use execution_plan::{ExecutionPlan, FusedOpCaps, MemoryPlan, PlanGeometry};
162pub use gemma4_engine::{Gemma4Engine, Gemma4Hparams, GEMMA4_ARCHES};
163pub use kv_budget::{
164    Ceiling, ContextCap, ContextFit, KvBudget, KvBudgetError, KvElem, KvLayout, KvResidency,
165    KvShape, CTX_AUTO_GRANULARITY,
166};
167pub use loader::LoadError;
168pub use norm::NormOp;
169pub use output_projection::grouped_output_projection;
170pub use penalty_window::PenaltyWindow;
171pub use pooling::{l2_normalize, pool, PoolingError, PoolingType};
172pub use prefix_cache::{PrefixCache, PrefixCacheStats, PrefixMatch};
173pub use rank_head::{load_rank_head, RankHead};
174pub use rerank_pooler::{splice_pooler, SpliceError, SplicedPooler};
175pub use sampler_order::{ChainStep, SamplerName, SamplerOrder, SamplerOrderError};
176pub use sampling::{sampling_distribution, Sampler, SamplingParams};
177pub use speculative::{
178    accept_or_resample, speculative_decode, speculative_decode_with, DraftBlock, DraftDist,
179    Drafter, PromptLookupSpeculator, SpeculativeDecodeResult, SpeculativeOptions,
180};
181pub use tensor_role::TensorRole;
182pub use tokenizer::{
183    ByteTokenizer, GgufBpeTokenizer, GgufPlamo2Tokenizer, GgufSpmTokenizer, GgufUnigramTokenizer,
184    GgufWordPieceTokenizer, NormalizerOptions, TokenizerLoadError,
185};
186
187#[cfg(feature = "metal")]
188pub use frink_metal::attn::{metal_greedy_argmax_active, set_metal_greedy_argmax};