Module weight_map

Module weight_map 

Source
Expand description

Weight name mapping from HuggingFace safetensors to typed layer structures.

Maps the 72 unique weight patterns from Qwen3-Next-80B-A3B-Instruct-NVFP4 into structured per-layer weight references.

Refactor wave 4a (2026-05-03): split into weight_map/ sub-modules.

Structs§

AttentionWeights
Full attention layer weights (12 layers in Qwen3-Next).
DenseExpertWeight
BF16 expert weight (before NVFP4 quantization).
DenseWeight
BF16 dense weight (no quantization).
ExpertWeight
MoE expert weights (shared across all 512 experts per layer).
Fp8DenseWeight
FP8 E4M3 dense weight (runtime-quantized from BF16).
Fp8ExpertWeight
FP8 expert weight: gate/up/down projections as FP8 block-scaled weights.
Fp8Weight
FP8 E4M3 checkpoint weight loaded directly from safetensors.
Fp8WeightTransposed
FP8 E4M3 weight with transposed layout for coalesced prefill GEMM.
ModelWeights
All model weights organized by layer.
MoeWeights
MoE layer weights.
MtpWeights
MTP (Multi-Token Prediction) head weights (all BF16 from safetensors).
NemotronExpertWeight
Nemotron-H 2-projection expert (up_proj + relu² + down_proj, no gate_proj).
NemotronMoeWeights
Nemotron-H MoE layer weights.
NemotronSsmWeights
Nemotron-H Mamba-2 SSM weights.
PackedQ2Weight
Keep-packed ternary Q2_0 weight: a single contiguous buffer of raw PrismML block_q2_0 blocks ([fp16 d][group/4 bytes of 2-bit codes], value = (code-1)*d), row-major over [n, k]. The scale is INLINE (one fp16 per group of group elements) — there is no companion scale tensor, unlike NVFP4/FP8. Consumed by the native q2_0_gemv decode kernel, which reads the scale from each block. Built from a WeightDtype::PackedQ2_0 store tensor under ATLAS_GGUF_NATIVE_Q2=1; the buffer is owned by the WeightStore, so this struct only borrows the pointer (no free on drop).
QuantExpertWeight
Per-expert weights in any supported quant format.
QuantizedWeight
NVFP4 quantized weight: packed E2M1 data + FP8 block scales + FP32 per-tensor scale.
SsmWeights
Linear attention (SSM / Gated Delta Net) layer weights (36 layers).
SsmWeightsQwen35
Qwen3.5 SSM weights with separate projections.

Enums§

LayerWeights
All weights for one transformer layer.
NemotronSsmQuant
SSM weight quantization format detected at load time.
Nvfp4Variant
Weight quantization variant (on-disk format).
QuantWeight
Quantized weight for any supported format.
WeightQuantFormat
Runtime tag for the actual quantization format of a weight buffer in GPU memory. Distinct from on-disk format (which Nvfp4Variant describes). Used to assert at kernel-call sites that the weight matches what the kernel expects — preventing silent leaks like FP8-block-scaled data being passed through a NVFP4 GEMM, or single-scale FP8 being passed through a kernel that expects per-row scales.

Functions§

detect_nvfp4_variant
Detect the weight quantization variant from the weight store.
load_fp8_block_scaled_as_fp8weight
Load an FP8 E4M3 block-scaled checkpoint weight as a native Fp8Weight.
load_fp8_weight
Load an FP8 E4M3 checkpoint weight with per-row f32 scales.
quantize_to_fp8
Quantize a BF16 dense weight to FP8 E4M3 on GPU.
quantize_to_fp8_blockscaled
Quantize an [n, k] BF16 dense weight to block-scaled FP8 E4M3 on GPU.