fix(mamba): separate state and checkpoint chunk sizes - #35086
Draft
momaekar1 wants to merge 1 commit into
Draft
Conversation
momaekar1
force-pushed
the
fix/mamba-checkpoint-state-chunk
branch
from
August 17, 2026 09:04
e9bb1a7 to
9f9d089
Compare
Co-authored-by: McZyWu <zhuoyun.wu.23@ucl.ac.uk>
momaekar1
force-pushed
the
fix/mamba-checkpoint-state-chunk
branch
from
August 17, 2026 10:06
9f9d089 to
e3c01c1
Compare
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.
Important
This PR contains only the Mamba checkpoint semantic fix. It does not include
#32500 or #35013. Merge this after #32500; #34560 is already merged into
main. The end-to-end validation stack also included #35013 for packed MTPHiCache transfers.
Motivation
Mamba radix caching currently uses
mamba_cache_chunk_sizefor two differentconcepts:
cache; and
tensor
h.These values are not always equal on Ascend. Qwen3.6 GDN uses 64-token kernel
state chunks with
page_size=128, so L1 checkpoints remain on a 128-token gridwhile
his packed every 64 tokens. Indexinghwith the L1 grid restores thewrong recurrent state. The incorrect state is selected before tier transfer,
so L2 and L3 can both replay the same wrong checkpoint; this is not a Mooncake
transport issue.
CUDA does not use this new semantic. The shared backend and non-NPU scheduler
path continue to use the existing
mamba_cache_chunk_size, preserving theircurrent behavior.
This is the minimal checkpoint-semantics part of #33515, adapted to the latest
main. It intentionally does not include that PR's cold-prefill boundarychange.
Minimal reproduction
Use Qwen3.6 GDN on Ascend with:
The scheduler uses a synthetic tracked length of 2945 to select the interior
state at checkpoint 2944. The packed state index must therefore be:
The previous code instead used the L1 checkpoint grid and selected:
The NPU backend comment records this concrete L1 failure, and the regression
test covers the per-request packed offset with expected
h_src=[46, 93]for atwo-request batch.
Modifications
npu_mamba_state_chunk_sizefor the Ascend kernel's packed intermediatestates.
AscendMambaAttnBackendBase.mamba_cache_chunk_sizeand the checkpoint grid unchanged for radixplacement, branching, convolution tracking, and all non-NPU backends.
mamba_checkpoint_grid/DCP checkpoint-depth behavior.for unchanged shared-backend behavior.
L1 divergence comparison
The A/B test used commits that differ only by this PR's patch. The before commit
was the validation stack parent
c2f86df61; the after commit14f0e87f3hasthe same stable patch-id as this PR head. Both runs used Qwen3.6-27B BF16, TP2,
Ascend NPU, NEXTN, 4 prompts with 3000 input tokens and 512 output tokens, and
reused exactly 2944 L1 device tokens for every prompt.
The cold baseline was identical in both runs: weighted accept rate
63.4988%and weighted accept length
2.9050. The later first mismatches and improvedNEXTN statistics show that the wrong
hindex is fixed. Replay is still nottoken-identical to cold generation; that remaining divergence is the separate
cold-prefill boundary issue intentionally left out of this PR.
L2/L3 replay verification
The end-to-end validation stack was latest
mainwith #34560,#32500@9acc6b733, #35013, and this PR. Model and request settings matched theL1 test above.
6 passed.8 passed.host=2944, device=0, storage=0for 4/4 prompts.storage=2944, device=0, host=0for 4/4 prompts.sha256=a0349ca2a8cdf023da0ef7b86370fbc25eac55ba5d8a656665a845c4a1d969d9.62.8169%, weighted accept length2.8845, and correct/proposed drafts1338/2130.L2 and L3 had the same first mismatch positions as the fixed L1 run:
[217, 322, 293, 58]. Mooncake therefore adds no additional divergence.Accuracy verification
Ran the repository's
benchmark/gsm8k/bench_sglang.pyagainst the same fullNEXTN + Mooncake validation stack using the first 200 examples from the
official GSM8K test set:
Result:
194/200correct (97.0%accuracy),0%invalid responses, no requestfailures, and
218.519 slatency. The previous incomplete-stack result was195/200; only prompt 182 changed correctness, from the correct answer23to24.Speed tests and profiling
This change adds no kernel launch or state copy. It only gives the Ascend state
index calculation its own chunk semantic. The 200-example accuracy run took
218.519 s; this is not a controlled performance comparison.Checklist
CI States
Latest PR Test (Base): ⏳ Run #32013403511
Latest PR Test (Extra): ⏳ Run #32013403405