[Attention][MiniMax-M3] NVFP4 KV cache on the MSA sparse attention path (#59300)

Signed-off-by: Yongye Zhu <zyy1102000@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yongye Zhu
2026-10-01 14:39:55 -07:00
committed by GitHub
co-authored by Claude Opus 5.5
parent ea84051819
commit 7566d83bd3
12 changed files with 1297 additions and 73 deletions
+12 -1
View File
@@ -2587,6 +2587,8 @@ def fused_minimax_m3_qknorm_rope_kv_insert(
skip_index_branch: bool = False,
q_fp8_out: torch.Tensor | None = None,
q_fp8_scale: float = 1.0,
kv_k_scale: torch.Tensor | None = None,
kv_v_scale: torch.Tensor | None = None,
) -> None:
"""Fused MiniMax-M3 attention pre-processing (in-place).
@@ -2610,7 +2612,14 @@ def fused_minimax_m3_qknorm_rope_kv_insert(
attention's flat TMA descriptor.
If ``q_fp8_out`` is given, the same normalized q is also written in FP8
E4M3 using ``q_fp8_scale`` as its dequantization scale.
E4M3 using ``q_fp8_scale`` as its dequantization scale. Without ``q_out``,
q is then written only in FP8 and the q slice of ``qkv`` is left as is.
``kv_cache_dtype="nvfp4"`` quantizes k/v into the packed HND
``[num_blocks, 2 * num_kv_heads, block_size, 72]`` uint8 cache using the
device dequantization scales ``kv_k_scale``/``kv_v_scale``. Slot
``2 * head + side`` (K = 0, V = 1) holds that head's E2M1 data followed by
its E4M3 block scales, so every head is one contiguous run of the page.
When ``skip_index_branch`` is true, sparse rows still keep their packed
``[index_q | index_k]`` tail, but the kernel only processes the main q/k/v
@@ -2641,6 +2650,8 @@ def fused_minimax_m3_qknorm_rope_kv_insert(
skip_index_branch,
q_fp8_out,
q_fp8_scale,
kv_k_scale,
kv_v_scale,
)