[Fix][Qwen3.5] Pass max_mamba_cache_size to mamba pool in disaggregation decode path#19002
[Fix][Qwen3.5] Pass max_mamba_cache_size to mamba pool in disaggregation decode path#19002YAMY1234 wants to merge 2 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello @YAMY1234, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical bug in the disaggregation decode path where the mamba memory pool was not correctly sized according to the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a bug where max_mamba_cache_size was ignored in the disaggregation decode path, leading to crashes. The changes introduce the mamba_size parameter and use it to properly configure the mamba pool, which resolves the issue as demonstrated by the provided test results. I have one suggestion to refine the calculation of the mamba pool size for better clarity and to prevent potential memory over-allocation when pre_alloc_size is used.
|
/tag-and-rerun-ci |
| speculative_num_draft_tokens: int, | ||
| enable_mamba_extra_buffer: bool, | ||
| pre_alloc_size: int, | ||
| mamba_size: int = None, |
There was a problem hiding this comment.
It is weird that we have a size and a mamba size for HybridMambaDecodeReqToTokenPool at the same time.
There was a problem hiding this comment.
I had similar concern when I was trying to understand this, but I found its parent class HybridReqToTokenPool also takes both size and mamba_size as separate parameters — they represent different things (max_num_reqs for req-to-token vs max_mamba_cache_size for mamba state)
| pre_alloc_size = max_num_reqs * 2 if max_num_reqs <= 32 else 0 | ||
| if config := self.mambaish_config: | ||
| self.req_to_token_pool = HybridMambaDecodeReqToTokenPool( | ||
| size=max_num_reqs, |
There was a problem hiding this comment.
Is it possible that we change this line?
CC: @yizhang2077
There was a problem hiding this comment.
If you mean changing size from max_num_reqs to max_mamba_cache_size, my understanding is that it may be not so good at the call site because size is also used by DecodeReqToTokenPool.__init__ (for the req_to_token tensor) and for mamba_spec_state_size , changing it would over-allocate the req_to_token pool and misalign the speculative buffer size with the non-disagg path. Happy to hear alternative suggestions though!
There was a problem hiding this comment.
Makes sense, I check the logic, LGTM.
ShangmingCai
left a comment
There was a problem hiding this comment.
LGTM. Should be OK to merge after a double-check from @yizhang2077
Motivation
HybridMambaDecodeReqToTokenPool(used exclusively in PD disaggregation decode) ignores the--max-mamba-cache-sizesetting when initializing its mamba pool. The original code hardcodessize(=max_num_reqs) as the mamba pool capacity, whereas the non-disaggregation path (HybridReqToTokenPool) correctly accepts a separatemamba_sizeparameter (=max_mamba_cache_size).With
mamba-scheduler-strategy: extra_buffer, each request consumes 3 mamba pool slots (1 main + 2 ping-pong). Would setmax-mamba-cache-size = 3 × max-running-requeststo provide enough slots, but in disagg decode the configured value is silently discarded — the mamba pool is always allocated atmax_num_reqssize, causing:For example, with
--max-mamba-cache-size 750 --max-running-requests 250, the decode mamba pool is still created with only 250 slots (confirmed by logs:Mamba Cache is allocated. max_mamba_cache_size: 250), which can serve at most 83 concurrent requests before exhausting mamba slots.Modifications
decode.py: Addmamba_sizeparameter toHybridMambaDecodeReqToTokenPool.__init__. Use it for the mamba pool capacity (size) in_init_mamba_pool, while keepingmamba_spec_state_sizeatsize + pre_alloc_size(aligned with the non-disagg path where speculative intermediate buffers are sized bymax_num_reqs, notmax_mamba_cache_size).model_runner_kv_cache_mixin.py: Passmamba_size=self.server_args.max_mamba_cache_sizewhen constructingHybridMambaDecodeReqToTokenPool.Accuracy Tests
Qwen3.5-397B-A17B-FP8, 1P1D PD disaggregation, TP4,
extra_bufferstrategy, GB200:max-mamba-cache-sizemamba-full-memory-ratio: 2.5)Repro config (on GB200):
Checklist