vllm.model_executor.layers.quantization.utils.lut_b_utils
¶
LUT-B weight format: 3-bit indices into per-tile E4M3 codebooks.
Rubin's tcgen05.mma ... decompress::lut::b instructions decode each weight
from a three-bit index into an eight-entry E4M3 codebook shared by eight
output channels. This module implements a calibration-free format matching
that contract. Each 8 (N) x 64 (K) tile of a [N, K] weight stores:
- 192 bytes of packed three-bit indices (row-major over the tile),
- an eight-entry E4M3 codebook, and
- one UE8M0 exponent applied to the whole codebook.
The exponent maps into the hardware's per-32-K block B scale, which keeps small-magnitude tiles out of the E4M3 subnormal range. In total the format uses 3.14 bits per weight.
Functions:
-
dequantize_lut_b–Reconstruct the
[N, K]or[E, N, K]weight from LUT-B tiles. -
lut_b_to_sm107_tiles–Rearrange stacked LUT-B weights into the SM107 MoE kernel layout.
-
pack_lut_b_indices–Pack groups of eight 3-bit indices into three little-endian bytes.
-
quantize_lut_b–Quantize a
[N, K]or stacked[E, N, K]weight to LUT-B. -
unpack_lut_b_indices–Inverse of :func:
pack_lut_b_indices.
_fit_tiles(values, num_iterations)
¶
Fit one E4M3 codebook per row of values with Lloyd iterations.
Three initializations are tried and the lowest-error fit per tile is kept.
Source code in vllm/model_executor/layers/quantization/utils/lut_b_utils.py
_normalize_centers(centers, preserve_zero)
¶
Snap to E4M3, keep an exact zero where needed, and sort.
Source code in vllm/model_executor/layers/quantization/utils/lut_b_utils.py
dequantize_lut_b(packed, codebooks, scales, out_dtype=torch.bfloat16)
¶
Reconstruct the [N, K] or [E, N, K] weight from LUT-B tiles.
Source code in vllm/model_executor/layers/quantization/utils/lut_b_utils.py
lut_b_to_sm107_tiles(packed, codebooks, scales)
¶
Rearrange stacked LUT-B weights into the SM107 MoE kernel layout.
Returns [E, N / 128, K / 128, 7168] uint8. Each tile holds:
- 6144 bytes of 3-bit indices, 48 bytes (K128) per output channel, in the no-swizzle K-major core-matrix layout (8 rows x 16 bytes),
- 512 bytes of UE8M0 B scales: byte
qof word[lane][col]is the scale of channelcol * 32 + lanefor K32 blockq, - 512 bytes of codebooks: lane
gholds the two eight-entry books (one per K64 half) of channel groupg; lanes 16-31 are zero padding.
Source code in vllm/model_executor/layers/quantization/utils/lut_b_utils.py
pack_lut_b_indices(indices)
¶
Pack groups of eight 3-bit indices into three little-endian bytes.
Source code in vllm/model_executor/layers/quantization/utils/lut_b_utils.py
quantize_lut_b(weight, *, num_iterations=LUT_B_LLOYD_ITERATIONS, max_tiles_per_chunk=LUT_B_MAX_TILES_PER_CHUNK)
¶
Quantize a [N, K] or stacked [E, N, K] weight to LUT-B.
Returns (packed, codebooks, scales) with shapes
[E, N/8, K/64, 192] (uint8), [E, N/8, K/64, 8] (float8_e4m3fn)
and [E, N/8, K/64] (uint8 UE8M0). The expert dim is dropped for 2D
inputs.
Source code in vllm/model_executor/layers/quantization/utils/lut_b_utils.py
unpack_lut_b_indices(packed)
¶
Inverse of :func:pack_lut_b_indices.