Expand description
§combs-models
Model architecture registry. The runtime drives any architecture through
the fixed GenerativeModel contract (MLC’s embed/prefill/decode/ create_kv_cache function set); architectures register themselves in the
ModelRegistry. Phase 1 ships the Llama family (incl. SmolLM2).
Structs§
- Arch
Spec - Resolved architecture description consumed by the decoder.
- Cache
Config - Configuration for a KV cache instance.
- ContiguousKV
Cache - Simple contiguous cache: stores one K and one V tensor per layer and concatenates along the sequence dimension every step.
- Llama
Model - Llama-family causal LM, parameterized by the resolved
ArchSpec— llama, smollm2, qwen2, and mistral today; the gemma/qwen3/phi presets migrate onto it stage by stage (roadmap wave 2). - Model
Registry - Maps architecture identifiers (
config.json::model_type, plus known aliases) to loaders. Mirrors MLC’smodel.py::MODELStable. - Page
Stats - A paged cache’s page-table state at a point in time (for monitoring).
- PagedKV
Cache - Q4KWeight
- A weight matrix resident in VRAM in packed Q4_K form (
[n_out, k],k % 256 == 0, superblocks alongk). - Q5KWeight
- A weight matrix resident in VRAM in packed Q6_K form (
[n_out, k],k % 256 == 0, superblocks alongk). A weight matrix resident in VRAM in packed Q5_K form ([n_out, k],k % 256 == 0, superblocks alongk). - Q6KWeight
- Q40Weight
- A weight matrix resident in VRAM in packed Q4_0 form.
[n_out, k]row-major,k % 32 == 0, blocks alongk— exactly the GGUF tensor layout, sofrom_gguf_bytestakes the mmap’d tensor bytes unchanged. - Q50Weight
- A weight matrix resident in VRAM in packed Q5_0 form (
[n_out, k],k % 32 == 0, blocks alongk). - Q80Weight
- A weight matrix resident in VRAM in packed Q8_0 form (
[n_out, k],k % 32 == 0, blocks alongk). - Quantized
Linear y = x @ W^T (+ b)whereWis stored group-quantized to 4 bits.- Rotary
Embedding - Precomputed RoPE cosine/sine tables.
- Smol
VlmModel - SmolVLM (Idefics3): SigLIP + connector + Llama-family text decoder.
- Whisper
Model
Enums§
- Cache
Kind - Which
KVCacheimplementation to instantiate. - Layer
Kind - Attention kind of one layer.
- Linear
- A linear layer weight: dense tensor (portable path) or packed quant blocks bound to a fused device kernel.
- Model
Error - Errors produced while constructing or running models.
- Norm
Flavor - RMSNorm flavor: plain (
x̂·w) or gemma’s zero-centered (x̂·(1+w)).
Traits§
- Generative
Model - Fixed contract every generative architecture implements — the direct
analog of MLC’s
embed / prefill / decode / create_kv_cachefunction set. The runtime only ever talks to models through this trait. - KVCache
- Per-layer key/value storage that owns the attention computation.
- Quant
Linear Op - A backend-specific quantized-linear forward. Boxed into
Linear::Quantat load time bytry_quant_linear. - Speech
ToText Model - Speech-to-text models (Whisper-style encoder–decoder). A separate
contract from
GenerativeModel: the encoder runs once per audio window, then the decoder is stepped over token prefixes against the fixed encoder states.
Functions§
- dequantize_
q4_ 0_ gpu - Runs the dequant-only kernel over a raw Q4_0 block stream. Exists for validation (bit-exact vs the CPU reference) and debugging, not the hot path.
- dequantize_
q4_ k_ gpu - Runs the Q4_K dequant-only kernel (validation/debugging path).
- dequantize_
q5_ 0_ gpu - Runs the Q5_0 dequant-only kernel (validation/debugging path).
- dequantize_
q5_ k_ gpu - Runs the Q5_K dequant-only kernel (validation/debugging path).
- dequantize_
q6_ k_ gpu - Runs the Q6_K dequant-only kernel (validation/debugging path).
- dequantize_
q8_ 0_ gpu - Runs the Q8_0 dequant-only kernel (validation/debugging path).
- image_
prompt_ expansion - Builds the Idefics3 prompt expansion for one image:
<fake_token_around_image><global-img><image>×image_seq_len<fake_token_around_image>. (image_seq_len= 64 for SmolVLM-256M.) The returned string is meant to replace each<image>placeholder in the chat text. - load_
speech_ model - Loads a speech model by
metadata.architecture— the ASR counterpart of the text registry’s loader map. - pixels_
to_ tensor - Builds a
[1, 3, H, W]pixel tensor from planar CHW f32 data (used by the runtime to hand media toembed_multimodal). - repack_
q4_ 0 - Layout step: repack a raw GGUF Q4_0 block stream into the device layout
the kernels consume — nibble bytes as little-endian
u32words (4 words per block) and onef32scale per block. The f16→f32 scale conversion is exact, so no precision is lost relative to the reference. - repack_
q4_ k - Layout step for Q4_K: split each 144-byte superblock into SoA device
arrays —
(qs words, [d, dmin] f32 pairs, scale words). 148 B per 256 weights = 4.63 bits/weight (GGUF native is 4.5). - repack_
q5_ 0 - Layout step for Q5_0: SoA of
(nibble words [4/blk], high-bit words [1/blk], f32 scales)— 24 B / 32 weights = 6.0 bits/weight. - repack_
q6_ k - Layout step for Q6_K: split each 210-byte superblock into SoA device
arrays —
(ql words, qh words, i8 scale words, d f32). 212 B per 256 weights = 6.63 bits/weight (GGUF native is 6.56). - repack_
q8_ 0 - Layout step for Q8_0: SoA of
(i8 words [8/blk], f32 scales)— 36 B / 32 weights = 9.0 bits/weight. - rms_
norm y = x / rms(x) * wwherermsis taken over the last dimension andepsis added inside the square root.- try_
quant_ linear
Type Aliases§
- Result
- Convenient result alias for this crate.