vllm.models.inkling2.nvidia.ops.nvfp4
¶
NVFP4 per-token activation quantization ("fouroversix_mae" scale rule).
Each row gets a per-token global scale amax / 1536. For every 16-element
block both a 6.0- and a 4.0-based e4m3 block scale are tried and the one with
the smaller absolute reconstruction error is kept.
Functions:
-
nvfp4_quantize–Quantize rows of bf16
x[M, K] to NVFP4.
_block_scales(block_max, encoder_scale, decoder_scale)
¶
The 6.0- and 4.0-based block scales of blocks with max |x| block_max
and their inverses.
Source code in vllm/models/inkling2/nvidia/ops/nvfp4.py
_candidate(x, inverse, scale, outer_scale)
¶
Packed values (uint64) and the reconstruction error of the blocks
x (16 columns) with block scale scale: the error is summed
pairwise, as in _block_error.
Source code in vllm/models/inkling2/nvidia/ops/nvfp4.py
_e2m1(x)
¶
The e2m1 code (sign in bit 3) of fp32 x rounded to nearest even
with saturation (cvt.rn.satfinite), and its value.
Source code in vllm/models/inkling2/nvidia/ops/nvfp4.py
_e2m1_pair(a, b)
¶
The e2m1x2 byte of (a, b) (a in the low nibble) and both
values rounded to e2m1.
Source code in vllm/models/inkling2/nvidia/ops/nvfp4.py
_pair(x, k, inverse, scale, outer_scale)
¶
Columns 2k and 2k + 1 of _candidate: their e2m1 byte at
byte k and their reconstruction error.
Source code in vllm/models/inkling2/nvidia/ops/nvfp4.py
_quantize_columns(x, encoder_scale, decoder_scale, outer_scale)
¶
_quantize_block of blocks given as a tuple x of their 16 fp32
columns, for each thread to hold whole blocks: packed values (uint64) and
e4m3 scales.
Source code in vllm/models/inkling2/nvidia/ops/nvfp4.py
_quantize_row(X, Values, Scales, Amax, row, K, BLOCK)
¶
Quantizes row row of X, with row-major scales and the row amax
in Amax.
Source code in vllm/models/inkling2/nvidia/ops/nvfp4.py
nvfp4_quantize(x)
¶
Quantize rows of bf16 x [M, K] to NVFP4.
Returns packed e2m1 values, row-major e4m3 block scales and the fp32 per-row amax.