Module quant_helpers

Module quant_helpers 

Source
Expand description

2026-09-25: FP8-to-BF16 dequantization, dtype-dispatching dense loads, and the compressed-tensors NVFP4 loader.

Owner: model-layers (weight loading). Invariants: none beyond the types.

Functions§

dense_auto
2026-09-25: Load name as a BF16 DenseWeight, converting by dtype:
dequant_fp8_blockscaled_to_bf16
2026-09-25: Dequantize a block-scaled FP8 E4M3 weight {prefix}.weight [N, K] into a new BF16 device buffer: bf16[i,j] = fp8[i,j] * scale[i/block_n, j/block_k], with the block sizes inferred from the scale’s shape.
quantized_v2
2026-09-25: Build a QuantizedWeight from compressed-tensors NVFP4 keys: weight_packed, weight_scale, weight_global_scale and an optional input_global_scale. compressed-tensors stores the global scale as the reciprocal of weight_scale_2, so weight_scale_2 = 1 / weight_global_scale.