Repository navigation
fix(dsa): align FA3 metadata with unpadded queries - #42793
Merged
Merged
Conversation
Jzz1943
requested review from
Fridge003,
HaiShaw,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
October 6, 2026 18:35
Contributor
Author
|
@merrymercy @Fridge003 @ispobock Could you please take a look at this PR when you have a chance? Thanks! |
Fridge003
approved these changes
Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
GLM-5.3-Flash fails during breakable prefill CUDA Graph capture when using FA3 with MegaMoE:
MoE synchronization can pad the DSA length metadata, while the prefill attention bridge narrows the query tensors and page table to the real token count. FA3 then receives inconsistent batch dimensions.
For example, 19 real query tokens can be passed with 20 entries in
cache_seqlensand 21 entries in the cumulative sequence-length arrays.#41311 addressed the pooled-indexer output row mismatch. This PR fixes the remaining FA3 metadata mismatch.
Modifications
Update
DeepseekSparseAttnBackend._forward_fa3()to:cache_seqlens,cu_seqlens_q, andcu_seqlens_kto the effective query count before calling FA3.The slices are local views and do not modify the original metadata tensors. The change adds no tensor-value reads or CPU/GPU synchronization. Inputs without excess metadata remain unchanged.
Accuracy Tests
Server launch command
The same command was used before and after applying the fix.
End-to-end reproduction
Tested on 4 × NVIDIA H200 with GLM-5.3-Flash, based on upstream commit
49bafb58cd6.Configuration:
Before: startup fails during prefill graph capture with the error above.
After: graph capture and server startup complete successfully with the same configuration.
GSM8K
Evaluated the patched server using:
reasoning_effort=lowThe unpatched configuration cannot complete startup, so no end-to-end accuracy baseline is available for this configuration.
Isolated FA3 validation
Separate H200 kernel-level validation passed eight cases covering padded and unpadded inputs, NoPE and RoPE, eager execution, and CUDA Graph replay. Patched outputs matched the explicitly trimmed reference exactly and passed comparison against a mathematical attention reference.
These validation cases are not included as repository unit tests in this PR.
Speed Tests and Profiling
No dedicated performance benchmark or profiling comparison was performed. This is a correctness fix for a configuration that previously failed at startup; no throughput improvement is claimed.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #37512517398
Latest PR Test (Extra): ❌ Run #37512516796
Latest PR Test (AMD ROCm 10): ❌ Run #37512517169