Adapt with #20522 #26877 in mamba#288
Open
IzacharyI wants to merge 1 commit into
Open
Conversation
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
Fix Qwen3.5 GDN linear-attention issues when prefix/radix cache and HIP/flydsl decode are enabled.
There are two problems addressed here:
KVlayout for prefill/extend andVKlayout for HIP/flydsl decode. Prefix-cache reuse copies mamba state rows between pool slots, but the per-slot layout bitmap was not moved with those rows. A stale layout bit can make the next KV↔VK transpose run against the wrong baseline, corrupting the SSM state and producing non-recoverable garbled output.mamba_track_mask.any()/nonzero()inside GDN layer forwards, causing D2H synchronization overhead. This was visible as a prefix-cache performance gap.Modifications
MambaPool:MambaPool.state_layout(0=KV,1=VK).KV.state_layouttogether with mamba state rows inMambaPool.copy_from()/fork_from().GDNAttnBackendsharemamba_pool.state_layoutinstead of allocating a private bitmap.KV.has_mamba_track_mask,mamba_track_mask_indices, andconv_states_mask_indicestoForwardMetadata.forward_extendand_track_mamba_state_extend, avoiding repeated per-layer D2H checks.has_mamba_track_maskthroughMamba2Metadata.prepare_decode()andprepare_mixed().Accuracy Tests
Benchmarking and Profiling
Qwen3.5-27B-FP8, tp=4
Qwen3.5-397B-A17B-PTPC, tp=8
Checklist
Review Process
-
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci