Repository navigation
[Cherry-pick][releases/v0.25.1rc][Feature]dsv4 dsa_cp support dspark (from #13249) - #13316
vllm-ascend-ci wants to merge 1 commit into
Conversation
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 integrates the dspark feature into the dsv4 dsa_cp implementation. The changes enable non-causal attention for draft tokens by expanding the sliding window and passing custom sparse indices to the attention operator, ensuring proper handling of KV lengths during speculative decoding. Highlights
New Features🧠 You can now enable Memory (public preview) 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. 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 the 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 counterproductive. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
Suggested PR Title:
[Attention][Feature] Support DSpark with Context Parallel (DSA CP) for DeepSeek V4Suggested PR Summary:
### What this PR does / why we need it?
This pull request adds support for DSpark speculative decoding with Context Parallel (DSA CP) for DeepSeek V4. It introduces the necessary metadata fields (`ori_win_left`, `ori_win_right`, and `dspark_swa_indices`) to `AscendDSAReqMetadata` and implements the logic to build and pad `dspark_swa_indices` when non-causal attention is used. It also updates the attention forward pass to utilize these indices and window configurations.
Feedback:
One review comment suggests replacing `F.pad` with `torch.full` and slice assignment to avoid potential compatibility or performance issues with integer tensor padding on Ascend NPUs.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
A new end-to-end test `test_deepseek_v4_dsa_cp_dspark_acceptance_tp4` has been added to verify the acceptance rate of DeepSeek V4 with DSA CP and DSpark speculative decoding.| if pad_rows: | ||
| global_dspark_indices = F.pad(global_dspark_indices, (0, 0, 0, 0, 0, pad_rows), value=-1) |
There was a problem hiding this comment.
Using F.pad with constant values on integer tensors can sometimes hit compatibility or performance issues on specialized hardware like the Ascend NPU. A more robust and standard approach is to pre-allocate the padded tensor using torch.full and copy the original indices into it.
| if pad_rows: | |
| global_dspark_indices = F.pad(global_dspark_indices, (0, 0, 0, 0, 0, pad_rows), value=-1) | |
| if pad_rows: | |
| padded_indices = torch.full( | |
| (num_tokens_pad, *global_dspark_indices.shape[1:]), | |
| -1, | |
| dtype=global_dspark_indices.dtype, | |
| device=global_dspark_indices.device, | |
| ) | |
| padded_indices[:global_dspark_indices.shape[0]] = global_dspark_indices | |
| global_dspark_indices = padded_indices |
Cherry-pick of PR vllm-project#13249 by @weiguihua2
10960d9 to
f8b6658
Compare
|
/rerun Rerun:
|
Cherry-pick of PR #13249 onto
releases/v0.25.1rc.Original PR: #13249
Original author: @weiguihua2
What this PR does / why we need it?
dsv4 dsa_cp supports the integration of the dspark feature.
Does this PR introduce any user-facing change?
No
How was this patch tested?