WeightQuantFormat

Enum WeightQuantFormat 

Source
pub enum WeightQuantFormat {
    Bf16,
    Fp8PerRow,
    Fp8BlockScaled,
    Fp8SingleScale,
    Nvfp4,
    Mxfp4E8m0,
    PackedQ2_0,
}
Expand description

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.

Phase 2c day-3 follow-up (2026-05-24): introduced after the audit at bench/phase2c-kv-sweep/CAUSAL-PATHWAY-AUDIT.md found that block-scaled FP8 weights from disk were being silently stuffed into the row_scale field of Fp8Weight (which documents itself as per-row F32), causing either crashes (when concat math read past the smaller block-scale tensor) or — if the concat dimension happened to fit — silent precision loss because downstream kernels (fp8_gemm_n128) take no scale arg and assume single-scale FP8.

Variants§

§

Bf16

BF16 dense — no quantization. Kernel must consume BF16 inputs.

§

Fp8PerRow

FP8 E4M3 weight + per-row F32 dequant scale ([N] f32). Produced by runtime quantization from BF16 (Fp8DenseWeight) or by checkpoints that ship per-row scales. Consumed by w8a16_gemv / w8a16_gemm.

§

Fp8BlockScaled

FP8 E4M3 weight + per-block BF16 dequant scale ([N/BS, K/BS] BF16). Standard Qwen-team FP8 release format (BS=128). NO Atlas kernel currently consumes this directly for SSM — kernels expect either dequant-to-BF16-then-NVFP4 (current path) or single-scale FP8. Block-scaled FP8 GEMV/GEMM is the missing kernel (open task).

§

Fp8SingleScale

FP8 E4M3 weight with a single global scale baked into the kernel (or implicit). Produced by bf16_to_fp8 from a BF16 dense. Consumed by fp8_gemm_n128 (takes no scale argument).

§

Nvfp4

NVFP4: packed E2M1 nibbles + per-group FP8 block scales + per-tensor F32 scale. Consumed by w4a16_gemv, w4a16_gemm, and variants.

§

Mxfp4E8m0

Native MXFP4 (OCP micro-scaling): packed E2M1 nibbles + per-block E8M0 power-of-2 scales (GROUP_SIZE=32), no per-tensor global. This is DeepSeek-V4-Flash’s ORIGINAL on-disk routed-expert format. The bytes are landed device-resident UNCHANGED (transcode-free) — the scale byte is a biased exponent, effective scale 2^(byte-127). Consumed by the E8M0 variants of the MoE grouped/decode GEMMs (Phase-K lane); feeding these bytes through an Nvfp4 kernel (which reads the scale as FP8-E4M3 per-16 and applies a global) = silent garbage — assert with WeightQuantFormat::expect at the dispatch site.

§

PackedQ2_0

Keep-packed PrismML ternary Q2_0 (ggml id 42): raw block_q2_0 blocks (fp16 inline scale + 2-bit codes per group), dequantized in-kernel by the native q2_0_gemv decode GEMV. Consumed only by that kernel — feeding these bytes through any other GEMV/GEMM is silent garbage.

Implementations§

Source§

impl WeightQuantFormat

Source

pub fn expect(self, expected: WeightQuantFormat, context: &str)

Assert that self matches expected; panic with a descriptive message if not. Used at kernel-call sites to prevent silent leaks of one quant format into a kernel that expects a different one.

Trait Implementations§

Source§

impl Clone for WeightQuantFormat

Source§

fn clone(&self) -> WeightQuantFormat

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WeightQuantFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for WeightQuantFormat

Source§

fn eq(&self, other: &WeightQuantFormat) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for WeightQuantFormat

Source§

impl Eq for WeightQuantFormat

Source§

impl StructuralPartialEq for WeightQuantFormat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more