[Feat] Support separate attention backend for target and draft model.#7342
Conversation
Signed-off-by: SidaoY <1024863041@qq.com>
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 refactors the KV cache allocation and reshaping mechanisms within the model runner. The primary goal is to enhance flexibility and correctness when handling different model architectures, particularly those with varying attention layer configurations (e.g., MLAAttention). By introducing helper methods to retrieve layer-specific KV cache specifications and dimensions, the system can now accurately allocate and reshape KV cache tensors tailored to each layer's unique requirements, improving compatibility and efficiency across diverse target and draft models. 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
|
|
👋 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. |
There was a problem hiding this comment.
Code Review
This pull request refactors the KV cache allocation logic to correctly handle different attention specifications, particularly for models with UniformTypeKVCacheSpecs and MLAAttentionSpec. The changes extract helper methods to get layer-specific cache specs and attention dimensions, making the allocation and reshaping of KV cache tensors more generic and robust. This fixes bugs where incorrect cache specs were used for layers within a group.
However, I've identified a critical issue where a division by zero can occur during the calculation of KV cache split factors if k_dim or v_dim is zero, which can happen with certain MLAAttentionSpec configurations. I've provided a suggestion to prevent this crash.
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
Signed-off-by: SidaoY <1024863041@qq.com>
…vllm-project#7342) ### What this PR does / why we need it? This PR enables separate attention backend configuration for target and draft models in speculative decoding, decoupling the previously bound attention backend settings between the two models. It solves the compatibility issue where some draft models do not support the attention backend used by the target model, and allows users to select the optimal attention backend for each model individually to maximize inference performance. The change is fully backward compatible. --------- Signed-off-by: SidaoY <1024863041@qq.com>
…vllm-project#7342) ### What this PR does / why we need it? This PR enables separate attention backend configuration for target and draft models in speculative decoding, decoupling the previously bound attention backend settings between the two models. It solves the compatibility issue where some draft models do not support the attention backend used by the target model, and allows users to select the optimal attention backend for each model individually to maximize inference performance. The change is fully backward compatible. --------- Signed-off-by: SidaoY <1024863041@qq.com>
…vllm-project#7342) ### What this PR does / why we need it? This PR enables separate attention backend configuration for target and draft models in speculative decoding, decoupling the previously bound attention backend settings between the two models. It solves the compatibility issue where some draft models do not support the attention backend used by the target model, and allows users to select the optimal attention backend for each model individually to maximize inference performance. The change is fully backward compatible. --------- Signed-off-by: SidaoY <1024863041@qq.com>
…vllm-project#7342) ### What this PR does / why we need it? This PR enables separate attention backend configuration for target and draft models in speculative decoding, decoupling the previously bound attention backend settings between the two models. It solves the compatibility issue where some draft models do not support the attention backend used by the target model, and allows users to select the optimal attention backend for each model individually to maximize inference performance. The change is fully backward compatible. --------- Signed-off-by: SidaoY <1024863041@qq.com>
What this PR does / why we need it?
This PR enables separate attention backend configuration for target and draft models in speculative decoding, decoupling the previously bound attention backend settings between the two models.
It solves the compatibility issue where some draft models do not support the attention backend used by the target model, and allows users to select the optimal attention backend for each model individually to maximize inference performance. The change is fully backward compatible.
Does this PR introduce any user-facing change?
How was this patch tested?
4034c3d)