[Bugfix] Prevent out-of-bounds access in FlashInfer SM90 sparse MLA mixed batches (#56969)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
This commit is contained in:
Chauncey
2026-09-15 15:03:58 +00:00
committed by GitHub
parent 9446ea1680
commit 836bb3839f
2 changed files with 27 additions and 7 deletions
@@ -277,6 +277,7 @@ class FlashInferMLASparseSM90Builder(FlashInferMLASparseMetadataBuilder):
attention_layer = vllm_config.compilation_config.static_forward_context[
layer_names[0]
]
self._attention_layer = attention_layer
impl = attention_layer.impl
if not isinstance(impl, FlashInferMLASparseSM90Impl):
raise TypeError(
@@ -376,6 +377,13 @@ class FlashInferMLASparseSM90Builder(FlashInferMLASparseMetadataBuilder):
# Replan every step outside any CUDA graph capture with this step's
# exact per-row lengths; captured runs read the refreshed buffers.
num_rows, kv_lens = self._kv_lens_host(common_attn_metadata)
# MHA prefills are removed from q before forward_mqa. Plan only the
# decode prefix in that case, using the same routing decision as MLA.
if metadata.num_prefills > 0 and self._attention_layer._use_sparse_mha(
metadata
):
num_rows = metadata.num_decode_tokens
kv_lens = kv_lens[:num_rows]
self.state.plan(num_rows, kv_lens)
metadata.state = self.state
return metadata