Skip to content

[Qwen3-next] support mamba radix cache for overlap scheduler - #14792

Merged
merrymercy merged 50 commits into
mainfrom
hanming/mamba-cache-p1
Dec 15, 2025
Merged

[Qwen3-next] support mamba radix cache for overlap scheduler#14792
merrymercy merged 50 commits into
mainfrom
hanming/mamba-cache-p1

Conversation

@hanming-lu

@hanming-lu hanming-lu commented Dec 10, 2025

Copy link
Copy Markdown
Collaborator

Motivation

  • Currently, qwen3-next doesn't support 1) overlap scheduler; 2) page_size > 1; 3) branching point caching

Modifications

  1. Support overlap scheduler for qwen3-next
  2. Support page_size > 1 for qwen3-next
  3. Support branching point caching for qwen3-next
  4. tested for (ps = 1, ps > 1) x (non-spec dec, sd topk1, sd topk>1). All work except for ps > 1 + sd topk > 1, which is not supported on main yet
  5. enable with --mamba-scheduler-strategy extra_buffer
  6. Better memory allocation for ssm spec dec - instead of coupling spec dec intermediate state size with total ssm states, couple it with max running requests.

Accuracy Tests

  1. Added mamba radix cache KL tests for prefill and decode
  2. cover both --mamba-scheduler-strategy extra_buffer and no_buffer

Benchmarking and Profiling

Checklist

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added the npu label Dec 10, 2025
Comment thread python/sglang/srt/managers/scheduler_output_processor_mixin.py Outdated
@hanming-lu hanming-lu changed the title [Qwen3-next] Prefix cache for qwen3-next [Qwen3-next] radix cache v2 for qwen3-next Dec 11, 2025
@hanming-lu

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Dec 13, 2025
@hanming-lu hanming-lu changed the title [Qwen3-next] radix cache v2 for qwen3-next [Qwen3-next] support mamba radix cache for overlap scheduler Dec 14, 2025
Comment on lines +158 to +165
self.enable_mamba_radix_cache_v2 = False
self._init_mamba_pool(
size + pre_alloc_size, cache_params, device, speculative_num_draft_tokens
size + pre_alloc_size,
size + pre_alloc_size,
cache_params,
device,
self.enable_mamba_radix_cache_v2,
speculative_num_draft_tokens,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ShangmingCai Once this is merged. Can you help support PD + this PR?

| `--max-mamba-cache-size` | The maximum size of the mamba cache. | `None` | Type: int |
| `--mamba-ssm-dtype` | The data type of the SSM states in mamba cache. | `float32` | `float32`, `bfloat16` |
| `--mamba-full-memory-ratio` | The ratio of mamba state memory to full kv cache memory. | `0.2` | Type: float |
| `--mamba-scheduler-strategy` | The strategy to use for mamba scheduler. `auto` currently defaults to `no_buffer`. 1. `no_buffer` does not support overlap scheduler due to not allocating extra mamba state buffers. Branching point caching support is feasible but not implemented. 2. `extra_buffer` supports overlap schedule by allocating extra mamba state buffers to track mamba state for caching (increases mamba state usage per running req by 2 for non-speculative decoding, 1 for speculative decoding). 2a. `extra_buffer` is strictly better for non-KV-cache-bound cases; for KV-cache-bound cases, the tradeoff depends on whether enabling overlap outweighs reduced max running requests. 2b. mamba caching at radix cache branching point is strictly better than non-branch but requires kernel support (currently only FLA backend), currently only extra_buffer supports branching. | `auto` | `auto`, `no_buffer`, `extra_buffer` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the meaning of (increases mamba state usage per running req by 2 for non-speculative decoding)? Can we use descriptions such as increase by 1.2x or 1.5x?

@ShangmingCai

Copy link
Copy Markdown
Collaborator

@ShangmingCai Once this is merged. Can you help support PD + this PR?

@merrymercy Sure. I will support PD + this PR ASAP.

@Ageliss

Ageliss commented Jan 20, 2026

Copy link
Copy Markdown

Is there any performance details before and after the overlap scheduler support of qwen3-next?

@mingyuedang

Copy link
Copy Markdown

求指教,非投机解码开启extra_buffer给每个请求分配2个slot作用是啥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation npu run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants