Module deepseek_v41

Module deepseek_v41 

Source
Expand description

2026-09-25: DeepSeek-V4.1 loader: assembles DeepSeekV41Layers from a GGUF checkpoint.

Attention, the compressor and indexer projections, the routers, the shared experts, the engram projections, the norms, the embedding and the head are read from the weight store. The projections read through resident_mat may stay raw Q2_K / Q3_K, and a Q6_K head stays raw. The routed expert stacks must be deferred by the GGUF loader; they are streamed from the shard files through expert_stream, as are the engram rows.

The loader widens to f32 the tensors the kernels read as f32: the attention sinks, the q_norm/kv_norm/compressor/indexer norm weights, the compressor projections of layers with ratio > 1, and the HC mixes. It forms the engram q * k product on the host.

The KV and index source layers are the layers whose tensors include compressor.wkv.weight and indexer.wq_b.weight. Candidate settings the config leaves unset fall back to DEFAULT_CANDIDATE_SOURCE (after METRALE_DS41_CANDIDATE_SOURCE), DEFAULT_CANDIDATE_TOPK_BLOCKS and DEFAULT_CANDIDATE_BLOCK.

Owner: model-arch weight loader. Invariants: none beyond the types.

Modules§

load_layers
2026-09-25: Builds the DeepSeek-V4.1 layers and the V41Runtime they share: the expert arena and cache, the attention, MoE and engram engines, and the engram hash tables.

Structs§

DeepSeekV41WeightLoader

Functions§

bf16_ptr
download_f32
f32_ptr
2026-09-25: A new f32 device copy of name, which must hold expect elements. The store’s tensor is widened on the host (download_f32) and uploaded.
upload_f32