[Hybrid] support prefix cache for Qwen3.5/Next with --mamba-cache-mode align#7103
[Hybrid] support prefix cache for Qwen3.5/Next with --mamba-cache-mode align#7103MengqingCao merged 14 commits intovllm-project:mainfrom
--mamba-cache-mode align#7103Conversation
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. |
Summary of ChangesHello, 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 introduces support for prefix caching in Mamba models, specifically targeting Qwen3.5/Next, within the vLLM-Ascend framework. It integrates a new utility for efficient batch memory copy operations, refines the block table management to correctly account for Mamba's state and distributed processing, and enables the necessary preprocessing steps during model execution. These changes allow for improved performance by leveraging prefix caching for Mamba-based architectures. 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 introduces support for prefix caching for Mamba models on Ascend, a valuable feature that extends vLLM-Ascend functionality. A security audit found no high or critical vulnerabilities. For performance, there is a suggestion to optimize the new Triton kernel for memory copy; please refer to the specific comment for details. Additionally, suggested PR title and summary have been provided for adherence to repository style guidelines.
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
10ea397 to
7623c0d
Compare
--mamba-cache-mode align--mamba-cache-mode align
MengqingCao
left a comment
There was a problem hiding this comment.
Plz add e2e test on prefix cache and single op test on the triton kernels
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: Angazenn <supperccell@163.com>
Signed-off-by: Angazenn <supperccell@163.com>
Signed-off-by: Angazenn <supperccell@163.com>
Signed-off-by: Angazenn <supperccell@163.com>
|
plz rebase your code after #7230 merged |
…de align` (vllm-project#7103) ### What this PR does / why we need it? To support prefix cache for Qwen3.5/Next in vLLM-Ascend, this PR mainly follows the design in [#30877](vllm-project/vllm#30877) and inherits changes to functions which are overridden in vLLM-Ascend. Note: 1. `--mamba-cache-mode align` && PD disaggregation is still not supported yet in vLLM v0.17.0(see https://github.com/vllm-project/vllm/blob/main/vllm/v1/core/sched/scheduler.py#L295). 2. The current implementation of hybrid kv cache might result in a very large block_size when scheduling. For example, if we run Qwen3.5-35B-A3B with `-tp 2`, the block_size is adjusted to 2048, which means that any prefix shorter than 2048 will never be cached. Although this behavior is consistent with vLLM, it still needs improvements in the future. 3. `--mamba-cache-mode align` requires to copy mamba states during forward steps. vLLM uses a triton kernel to implement it. However, the original version run into some bugs on Ascend hardwares. Thus we patch a new triton kernel to avoid this bug. ### Does this PR introduce _any_ user-facing change? To use mamba prefix cache, set `--enable-prefix-caching` and `--mamba-cache-mode align`. Note that the mamba state copy function(see [do_mamba_copy_block](https://github.com/vllm-project/vllm/blob/main/vllm/v1/worker/mamba_utils.py#L132)) does not provide a torch native version, thus it might have trouble if users can't use triton. - vLLM version: v0.16.0 - vLLM main: vllm-project/vllm@4034c3d --------- Signed-off-by: Angazenn <supperccell@163.com>
What this PR does / why we need it?
To support prefix cache for Qwen3.5/Next in vLLM-Ascend, this PR mainly follows the design in #30877 and inherits changes to functions which are overridden in vLLM-Ascend.
Note:
--mamba-cache-mode align&& PD disaggregation is still not supported yet in vLLM v0.17.0(see https://github.com/vllm-project/vllm/blob/main/vllm/v1/core/sched/scheduler.py#L295).-tp 2, the block_size is adjusted to 2048, which means that any prefix shorter than 2048 will never be cached. Although this behavior is consistent with vLLM, it still needs improvements in the future.--mamba-cache-mode alignrequires to copy mamba states during forward steps. vLLM uses a triton kernel to implement it. However, the original version run into some bugs on Ascend hardwares. Thus we patch a new triton kernel to avoid this bug.Does this PR introduce any user-facing change?
To use mamba prefix cache, set
--enable-prefix-cachingand--mamba-cache-mode align. Note that the mamba state copy function(see do_mamba_copy_block) does not provide a torch native version, thus it might have trouble if users can't use triton.How was this patch tested?