Repository navigation
Accept and ignore topk_indices in FlashInfer MLA dense backend - #30994
AliceChenyy wants to merge 2 commits into
Conversation
DSA-family models (GLM-5.x / DeepSeek V3.2+, GlmMoeDsaForCausalLM etc.)
unconditionally pass the indexer's topk_indices to the attention backend.
The dense FlashInfer MLA backend does not take that keyword, so any code
path that calls the backend interface directly -- speculative-decoding
verify (TARGET_VERIFY via the decode graph runner) and pipeline-parallel
non-overlap decode -- crashes with:
TypeError: FlashInferMLAAttnBackend.forward_decode() got an
unexpected keyword argument 'topk_indices'
while the default overlap decode path happens to work because the
tc-piecewise wrapper filters kwargs. Reproduced on v0.5.15 with
GLM-5.2-NVFP4 on SM120 (where the DSA sparse kernels are unavailable and
dense MLA is the only option): plain --tp 8 serves fine, adding EAGLE MTP
or PP crashes on the first verify/decode.
Dense attention over the full KV is a lossless superset of the sparse
top-k selection, so accepting and ignoring the hint is sound.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request adds a topk_indices parameter to the forward_extend and forward_decode methods in FlashInferMLAAttnBackend to support DSA-family models. The reviewer recommends replacing this specific parameter with **kwargs in both methods to adhere to the Liskov Substitution Principle, align with the base class signature, and prevent potential TypeError crashes from unsupported arguments in the future.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| # DSA-family models pass the indexer's top-k selection; dense MLA | ||
| # attends the full KV (a lossless superset of the sparse selection), | ||
| # so the hint is safely ignored. | ||
| topk_indices: Optional[torch.Tensor] = None, |
There was a problem hiding this comment.
Instead of adding a specific topk_indices parameter, it is highly recommended to add **kwargs to the signature of forward_extend.\n\nThe base class AttentionBackend defines forward_extend with **kwargs to allow backends to gracefully ignore arguments they do not support. By not accepting **kwargs, FlashInferMLAAttnBackend violates the Liskov Substitution Principle and is fragile to any other keyword arguments passed by different model architectures or speculative decoding strategies (which can cause TypeError crashes). Adding **kwargs makes the backend robust and future-proof.
| # DSA-family models pass the indexer's top-k selection; dense MLA | |
| # attends the full KV (a lossless superset of the sparse selection), | |
| # so the hint is safely ignored. | |
| topk_indices: Optional[torch.Tensor] = None, | |
| **kwargs, |
| # DSA-family models pass the indexer's top-k selection; dense MLA | ||
| # attends the full KV (a lossless superset), safely ignored. | ||
| topk_indices: Optional[torch.Tensor] = None, |
There was a problem hiding this comment.
Instead of adding a specific topk_indices parameter, it is highly recommended to add **kwargs to the signature of forward_decode.\n\nThe base class AttentionBackend defines forward_decode with **kwargs to allow backends to gracefully ignore arguments they do not support. By not accepting **kwargs, FlashInferMLAAttnBackend violates the Liskov Substitution Principle and is fragile to any other keyword arguments passed by different model architectures or speculative decoding strategies (which can cause TypeError crashes). Adding **kwargs makes the backend robust and future-proof.
| # DSA-family models pass the indexer's top-k selection; dense MLA | |
| # attends the full KV (a lossless superset), safely ignored. | |
| topk_indices: Optional[torch.Tensor] = None, | |
| **kwargs, |
…ture The base class declares forward_extend/forward_decode with **kwargs so backends tolerate keyword arguments they do not consume; accept that contract here instead of enumerating topk_indices specifically. Validated on 8x RTX 6000D with a v0.5.15 build of this patch: TP8 + EAGLE MTP now serves GLM-5.2-NVFP4 correctly (GSM8K 20q 0.90, greedy output identical to non-spec; bs=1 median TPOT 11.4ms vs 20.8ms without MTP on the same host). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Addressed the review: switched to Two notes for maintainers:
|
|
Follow-up: TP4xPP2 also validated end to end with this patch (v0.5.15 build, same 8x RTX 6000D host) — GSM8K 20q 0.90, greedy output identical to TP8, full serving bench at concurrency 1/4/8/16. The skip-topk PP-boundary assertion mentioned above is cleanly avoided with |
|
Closing: with #26928 (flashinfer sparse MLA for GLM on SM120), the dense MLA fallback path is no longer on the critical path for our SM120 GLM deployment. The underlying interface gap (dense backend not honoring the base class |
Motivation
DSA-family models (GLM-5.x, DeepSeek V3.2+) unconditionally pass the indexer's
topk_indicesto the attention backend. The dense FlashInfer MLA backend doesn't accept that keyword, so every code path that calls the backend interface directly crashes:TARGET_VERIFYthrough the decode graph runner)The default overlap decode path happens to work because the tc-piecewise wrapper filters kwargs — which makes this failure surprisingly configuration-dependent: on SM120 (RTX PRO 6000 / RTX 6000D, where DSA sparse kernels are unavailable and dense MLA is the only option)
--tp 8serves GLM-5.2-NVFP4 fine, but adding--speculative-algorithm EAGLEor--pipeline-parallel-size 2crashes on the first verify/decode. Reproduced on v0.5.15.Modification
Add an optional
topk_indicesparameter toforward_extend/forward_decodeand ignore it. Dense attention over the full KV is a lossless superset of the sparse top-k selection, so ignoring the hint is sound (sparse is an approximation of dense, not the other way around).Validated on 8x RTX 6000D, GLM-5.2-NVFP4, v0.5.15-equivalent build: TP8+EAGLE and TP4xPP2 both serve correctly with this shim (GSM8K 20q 0.90, greedy outputs identical to non-spec).
Related: this unblocks the SM120 GLM-5.2 recipe being added to sgl-cookbook.
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ❌ Run #29236214796
Latest PR Test (Extra): ❌ Run #29236214430