fix(qsa): dequantize FP8 cached prefixes in the sparse prefill kernels (#38855)

This commit is contained in:
YAMY
2026-09-10 14:07:39 -07:00
committed by GitHub
parent 06dfe05d65
commit 55b45cb45a
2 changed files with 62 additions and 0 deletions
@@ -243,6 +243,13 @@ def _sparse_gqa_chunk_prefill(
mask=valid[:, None],
other=0.0,
)
# The chunk-prefill K/V tensors are gathered from the KV pool and can
# therefore carry the FP8 storage dtype, which Triton's dot rejects
# (`Unsupported rhs dtype fp8e4nv`). Convert to Q's dtype; the QSA
# backend writes the pool without per-tensor k/v scales, so this is a
# plain cast (no-op for BF16 pools).
keys = keys.to(q_values.dtype)
values = values.to(q_values.dtype)
scores = tl.where(valid[None, :], tl.dot(q_values, keys), -float("inf"))
next_max = tl.maximum(max_value, tl.max(scores, 1))
alpha = tl.math.exp2(max_value - next_max)