Skip to content

[Fix] mamba: Clear a stale COW source when an unadmitted request is matched again - #50009

Merged
kpham-sgl merged 2 commits into
mainfrom
kpham/port-mamba-stale-cow-source
Nov 12, 2026
Merged

kpham-sgl merged 2 commits into
mainfrom
kpham/port-mamba-stale-cow-source

Conversation

@kpham-sgl

@kpham-sgl kpham-sgl commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Original authors: @yhyang201

Port of #48414

A request that a prefix match set up for a Mamba copy-on-write, but that the admission pass then left queued without calling _drop_unadmitted_match, keeps req.kv.mamba_cow_src_index. If the matched node's device state is evicted before the next pass, the rematch finds no device state and returns early, leaving the old source index. The request then copies its initial state from a slot that may have been reused. This PR ports the fix from the Kimi-K3.1 Day-0 branch: the rematch clears the source index when the node has no device state.

Against the raw port (first commit): no changes.

Not taken: the Day-0 branch also calls _drop_unadmitted_match on the three early exits of the admission loop regardless of defer_cow_slot. Main guards those calls since #49300, and the rematch fix covers the stale source without changing that.

Modifications

  • MambaComponent.finalize_match_result_in_cache sets req.kv.mamba_cow_src_index = None when the best-match node has no device Mamba state.

Tests

  • New test_mamba_stale_cow_source.py (1 GPU): match with copy-on-write, evict the node's device state, match again, and check the request holds no source index that is not the node's live state.
  • Not run yet: static checks only (pre-commit, compile).

CI States

Latest PR Test (Base): 🚫 Run #43159687576
Latest PR Test (Extra): ❌ Run #43159687559
Latest PR Test (AMD ROCm 10): ⏳ Run #43159687623

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

@kpham-sgl

Copy link
Copy Markdown
Collaborator Author

/rerun-test registered/unit/mem_cache/test_mamba_stale_cow_source.py

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-5090 (1 test): ✅ View workflow run

cd test/ && python3 registered/unit/mem_cache/test_mamba_stale_cow_source.py  # base-b

@alphabetc1 alphabetc1 added the run-ci CI: run the baseline test suite on this PR label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR unified-radix-cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants