vllm.v1.attention.ops.mxfp4_mla.store
¶
Triton store kernel for the mxfp4_mla KV cache.
concat_and_cache_mla takes a single per-tensor scale, so it cannot write
MXFP4's per-group scales. A row is packed data then scales,
row_bytes(d) == d // 2 + d // 32, addressed as slot * row_bytes.
Functions:
-
store_mxfp4_mla–Quantize the MLA latent to MXFP4 and write it into the paged cache.
_ceil_pow2_exponent(v)
¶
Smallest integer e with 2**e >= v, for positive fp32 v.
Done on the bit pattern rather than with log2: fp32 log2 is not
exactly representable at powers of two, and rounding one of those up would
waste a whole exponent step and halve the usable E2M1 range for that group.
For v = m * 2**e with m in [1, 2), the biased exponent field is
e + 127 and the mantissa field is zero exactly when v is a power of
two. So ceil(log2(v)) is e when the mantissa is zero and e + 1
otherwise.
Source code in vllm/v1/attention/ops/mxfp4_mla/store.py
_quantize_e2m1(normalized)
¶
fp32 values pre-divided by their group scale -> 4-bit E2M1 codes.
Source code in vllm/v1/attention/ops/mxfp4_mla/store.py
store_mxfp4_mla(kv_c_normed, slot_mapping, cache, group=GROUP_SIZE)
¶
Quantize the MLA latent to MXFP4 and write it into the paged cache.
Parameters:
-
(kv_c_normed¶Tensor) –[num_tokens, latent], the post-RMSNorm latent. -
(slot_mapping¶Tensor) –[num_tokens]global slot indices; negative entries (PAD_SLOT_ID) are skipped. -
(cache¶Tensor) –uint8, either the paged[num_blocks, block_size, row_bytes(latent)]layer view, whose block stride may exceedblock_sizerows when other layers' pages sit between blocks, or any contiguous tensor viewable as[num_slots, row_bytes(latent)]. -
(group¶int, default:GROUP_SIZE) –number of latent elements sharing one E8M0 scale.