[BugFix] Fix Qwen3.5 MoE flash comm v1 shared expert shape error of mtp layer on A2 - #7683
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 addresses specific bugs affecting the Qwen3.5 series models when running on the A2 platform. The changes primarily refine the conditional logic for tensor communication and reduction operations, ensuring that multimodal and vision-language models correctly interact with 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. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refines the conditions for applying tensor parallel communication and padding/reduction operations within the vllm_ascend framework. It modifies vllm_ascend/ops/register_custom_ops.py to include is_ep_comm in the bypass condition for draft and VL models when flash_comm_v1 is disabled. Additionally, in vllm_ascend/spec_decode/eagle_proposer.py, it adjusts the maybe_pad_and_reduce function to prevent multimodal models from undergoing padding and reduction when flash_comm_v1 is enabled, by removing an early return and adding a not self.is_multimodal_model check to the reduction logic. These changes aim to ensure correct behavior and potentially optimize performance for multimodal and other specific model configurations under different communication settings. There are no review comments to address.
|
👋 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. |
f7303bd to
5839062
Compare
Signed-off-by: wangbj127 <wangbj1207@126.com>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com>
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com>
…tp layer on A2 (vllm-project#7683) ### What this PR does / why we need it? Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled. fix vllm-project#7996 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - vLLM version: v0.18.0 - vLLM main: vllm-project/vllm@35141a7 Signed-off-by: wangbj127 <wangbj1207@126.com> Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com>
…tp layer on A2 (vllm-project#7683) ### What this PR does / why we need it? Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled. fix vllm-project#7996 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - vLLM version: v0.18.0 - vLLM main: vllm-project/vllm@35141a7 Signed-off-by: wangbj127 <wangbj1207@126.com> Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com> Signed-off-by: anning-2026 <anning@isrc.iscas.ac.cn>
…tp layer on A2 (vllm-project#7683) ### What this PR does / why we need it? Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled. fix vllm-project#7996 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - vLLM version: v0.18.0 - vLLM main: vllm-project/vllm@35141a7 Signed-off-by: wangbj127 <wangbj1207@126.com> Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com>
…tp layer on A2 (vllm-project#7683) ### What this PR does / why we need it? Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled. fix vllm-project#7996 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - vLLM version: v0.18.0 - vLLM main: vllm-project/vllm@35141a7 Signed-off-by: wangbj127 <wangbj1207@126.com> Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com> Signed-off-by: guxin108 <1252896542@qq.com>
…tp layer on A2 (vllm-project#7683) ### What this PR does / why we need it? Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled. fix vllm-project#7996 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - vLLM version: v0.18.0 - vLLM main: vllm-project/vllm@35141a7 Signed-off-by: wangbj127 <wangbj1207@126.com> Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com> Signed-off-by: zouyida2052 <zouyida2002@gmail.com>
…tp layer on A2 (vllm-project#7683) ### What this PR does / why we need it? Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled. fix vllm-project#7996 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - vLLM version: v0.18.0 - vLLM main: vllm-project/vllm@35141a7 Signed-off-by: wangbj127 <wangbj1207@126.com> Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com>
…tp layer on A2 (vllm-project#7683) ### What this PR does / why we need it? Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled. fix vllm-project#7996 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - vLLM version: v0.18.0 - vLLM main: vllm-project/vllm@35141a7 Signed-off-by: wangbj127 <wangbj1207@126.com> Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com> Signed-off-by: nanxing <1014662416@qq.com>
…tp layer on A2 (vllm-project#7683) ### What this PR does / why we need it? Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled. fix vllm-project#7996 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - vLLM version: v0.18.0 - vLLM main: vllm-project/vllm@35141a7 Signed-off-by: wangbj127 <wangbj1207@126.com> Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com>
…tp layer on A2 (vllm-project#7683) ### What this PR does / why we need it? Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled. fix vllm-project#7996 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - vLLM version: v0.18.0 - vLLM main: vllm-project/vllm@35141a7 Signed-off-by: wangbj127 <wangbj1207@126.com> Signed-off-by: wangbj127 <256472688+wangbj127@users.noreply.github.com>
Remove the legacy draft VL TP all-reduce bypass from the EP
sequence-parallel finalize path and add regression coverage.
### What this PR does / why we need it?
This PR fixes a token-layout mismatch when Qwen3.5 MTP is used together
with expert parallelism and upstream MoE sequence parallelism.
With upstream MoE sequence parallelism enabled,
`PrepareAndFinalizeWithAllGather` uses the following communication flow:
```text
TP AllGather
-> Attention
-> TP ReduceScatter
-> EP AllGather
-> MoE
-> EP ReduceScatter
```
Therefore, `maybe_pad_and_reduce` is an EP sequence-parallel finalize
operation and must return the local EP/SP sequence shard.
However, it still contained a legacy draft-VL special case:
```python
if _EXTRA_CTX.is_draft_model and is_vl_model():
return tensor_model_parallel_all_reduce(x)
```
TP AllReduce preserves the global-token layout instead of restoring the
local EP/SP shard.
For Qwen3.5 MTP, this causes the draft model to return a tensor with an
unexpected token dimension, resulting in a deterministic shape mismatch
during profiling or execution, for example:
```text
4096 vs 1024
```
The real and fake implementations of this custom operation were also
inconsistent in this case:
- The real implementation returned the global-token shape through TP
AllReduce.
- The fake implementation always returned the local EP shard shape.
This special case originated from the FlashComm1 implementation. PR
#7683 explicitly restricted the draft-VL TP AllReduce bypass to non-EP
communication using `not is_ep_comm`.
After FlashComm1 was removed in #13946, `maybe_pad_and_reduce` became an
EP-only operation, but the legacy bypass remained without that guard.
This PR:
- Removes the obsolete draft-VL TP AllReduce bypass.
- Removes the corresponding unused imports.
- Makes the real implementation follow the same EP ReduceScatter
contract as the fake implementation.
- Adds a regression UT ensuring that draft-VL execution cannot bypass EP
ReduceScatter.
- Updates the existing four-card Qwen3.5 MTP test to explicitly cover:
- DP=2
- TP=2
- Expert parallelism
- Upstream MoE sequence parallelism
- MTP with 3 speculative tokens
The fix is intentionally limited to the EP/SP finalize communication
layer. It does not add model-specific logic or introduce another
sequence-parallel configuration flag.
Related PRs: #7683, #13946
### Does this PR introduce _any_ user-facing change?
Yes.
Qwen3.5 MoE models can now use MTP speculative decoding together with
DP, TP, EP, and upstream MoE sequence parallelism without failing
because of a token-dimension mismatch.
There are no API or configuration interface changes.
### How was this patch tested?
Regression coverage added:
- Added `test_sp_ep_reduce_scatter_draft_vl_keeps_ep_layout`.
- The test reproduces the historical draft-VL state and fails if the
EP/SP finalize path attempts to use TP AllReduce.
- The expected output remains the current EP rank's local token shard.
- Updated the existing Qwen3.5 four-card E2E case to explicitly use:
- `Qwen3.5-35B-A3B`
- DP=2
- TP=2
- Expert parallelism enabled
- `allgather_reducescatter`
- Qwen3.5 MTP with 3 speculative tokens
- `FULL_DECODE_ONLY`
Local static validation:
- Python syntax compilation passed for all three modified files.
- `git diff --check` passed.
- The final diff contains only the custom operation, regression UT, and
Qwen3.5 E2E test changes.
Hardware root-cause validation was performed on the equivalent fix:
| Configuration | Result |
| --- | --- |
| SP disabled + MTP enabled | Passed |
| SP enabled + MTP disabled | Passed |
| SP enabled + MTP enabled with the original bypass | Failed |
| SP enabled + MTP enabled after removing the draft-VL TP AllReduce
bypass | Passed |
Eager-mode shape tracing confirmed:
```text
Before finalize: (4096, 2048)
Legacy TP AllReduce result: (4096, 2048)
EP ReduceScatter result: (1024, 2048)
```
The complete repository UT and the updated four-card E2E test were not
executed in the local Windows workspace because it does not contain the
required vLLM, PyTorch, torch-npu, pytest, or NPU runtime environment.
They are left for the project CI and NPU test environment.
- vLLM main:
vllm-project/vllm@84030bb
---------
Signed-off-by: muziyuhui666 <lijianfu9@huawei.com>
…ject#16081) Remove the legacy draft VL TP all-reduce bypass from the EP sequence-parallel finalize path and add regression coverage. ### What this PR does / why we need it? This PR fixes a token-layout mismatch when Qwen3.5 MTP is used together with expert parallelism and upstream MoE sequence parallelism. With upstream MoE sequence parallelism enabled, `PrepareAndFinalizeWithAllGather` uses the following communication flow: ```text TP AllGather -> Attention -> TP ReduceScatter -> EP AllGather -> MoE -> EP ReduceScatter ``` Therefore, `maybe_pad_and_reduce` is an EP sequence-parallel finalize operation and must return the local EP/SP sequence shard. However, it still contained a legacy draft-VL special case: ```python if _EXTRA_CTX.is_draft_model and is_vl_model(): return tensor_model_parallel_all_reduce(x) ``` TP AllReduce preserves the global-token layout instead of restoring the local EP/SP shard. For Qwen3.5 MTP, this causes the draft model to return a tensor with an unexpected token dimension, resulting in a deterministic shape mismatch during profiling or execution, for example: ```text 4096 vs 1024 ``` The real and fake implementations of this custom operation were also inconsistent in this case: - The real implementation returned the global-token shape through TP AllReduce. - The fake implementation always returned the local EP shard shape. This special case originated from the FlashComm1 implementation. PR vllm-project#7683 explicitly restricted the draft-VL TP AllReduce bypass to non-EP communication using `not is_ep_comm`. After FlashComm1 was removed in vllm-project#13946, `maybe_pad_and_reduce` became an EP-only operation, but the legacy bypass remained without that guard. This PR: - Removes the obsolete draft-VL TP AllReduce bypass. - Removes the corresponding unused imports. - Makes the real implementation follow the same EP ReduceScatter contract as the fake implementation. - Adds a regression UT ensuring that draft-VL execution cannot bypass EP ReduceScatter. - Updates the existing four-card Qwen3.5 MTP test to explicitly cover: - DP=2 - TP=2 - Expert parallelism - Upstream MoE sequence parallelism - MTP with 3 speculative tokens The fix is intentionally limited to the EP/SP finalize communication layer. It does not add model-specific logic or introduce another sequence-parallel configuration flag. Related PRs: vllm-project#7683, vllm-project#13946 ### Does this PR introduce _any_ user-facing change? Yes. Qwen3.5 MoE models can now use MTP speculative decoding together with DP, TP, EP, and upstream MoE sequence parallelism without failing because of a token-dimension mismatch. There are no API or configuration interface changes. ### How was this patch tested? Regression coverage added: - Added `test_sp_ep_reduce_scatter_draft_vl_keeps_ep_layout`. - The test reproduces the historical draft-VL state and fails if the EP/SP finalize path attempts to use TP AllReduce. - The expected output remains the current EP rank's local token shard. - Updated the existing Qwen3.5 four-card E2E case to explicitly use: - `Qwen3.5-35B-A3B` - DP=2 - TP=2 - Expert parallelism enabled - `allgather_reducescatter` - Qwen3.5 MTP with 3 speculative tokens - `FULL_DECODE_ONLY` Local static validation: - Python syntax compilation passed for all three modified files. - `git diff --check` passed. - The final diff contains only the custom operation, regression UT, and Qwen3.5 E2E test changes. Hardware root-cause validation was performed on the equivalent fix: | Configuration | Result | | --- | --- | | SP disabled + MTP enabled | Passed | | SP enabled + MTP disabled | Passed | | SP enabled + MTP enabled with the original bypass | Failed | | SP enabled + MTP enabled after removing the draft-VL TP AllReduce bypass | Passed | Eager-mode shape tracing confirmed: ```text Before finalize: (4096, 2048) Legacy TP AllReduce result: (4096, 2048) EP ReduceScatter result: (1024, 2048) ``` The complete repository UT and the updated four-card E2E test were not executed in the local Windows workspace because it does not contain the required vLLM, PyTorch, torch-npu, pytest, or NPU runtime environment. They are left for the project CI and NPU test environment. - vLLM main: vllm-project/vllm@84030bb --------- Signed-off-by: muziyuhui666 <lijianfu9@huawei.com>
…ject#16081) Remove the legacy draft VL TP all-reduce bypass from the EP sequence-parallel finalize path and add regression coverage. ### What this PR does / why we need it? This PR fixes a token-layout mismatch when Qwen3.5 MTP is used together with expert parallelism and upstream MoE sequence parallelism. With upstream MoE sequence parallelism enabled, `PrepareAndFinalizeWithAllGather` uses the following communication flow: ```text TP AllGather -> Attention -> TP ReduceScatter -> EP AllGather -> MoE -> EP ReduceScatter ``` Therefore, `maybe_pad_and_reduce` is an EP sequence-parallel finalize operation and must return the local EP/SP sequence shard. However, it still contained a legacy draft-VL special case: ```python if _EXTRA_CTX.is_draft_model and is_vl_model(): return tensor_model_parallel_all_reduce(x) ``` TP AllReduce preserves the global-token layout instead of restoring the local EP/SP shard. For Qwen3.5 MTP, this causes the draft model to return a tensor with an unexpected token dimension, resulting in a deterministic shape mismatch during profiling or execution, for example: ```text 4096 vs 1024 ``` The real and fake implementations of this custom operation were also inconsistent in this case: - The real implementation returned the global-token shape through TP AllReduce. - The fake implementation always returned the local EP shard shape. This special case originated from the FlashComm1 implementation. PR vllm-project#7683 explicitly restricted the draft-VL TP AllReduce bypass to non-EP communication using `not is_ep_comm`. After FlashComm1 was removed in vllm-project#13946, `maybe_pad_and_reduce` became an EP-only operation, but the legacy bypass remained without that guard. This PR: - Removes the obsolete draft-VL TP AllReduce bypass. - Removes the corresponding unused imports. - Makes the real implementation follow the same EP ReduceScatter contract as the fake implementation. - Adds a regression UT ensuring that draft-VL execution cannot bypass EP ReduceScatter. - Updates the existing four-card Qwen3.5 MTP test to explicitly cover: - DP=2 - TP=2 - Expert parallelism - Upstream MoE sequence parallelism - MTP with 3 speculative tokens The fix is intentionally limited to the EP/SP finalize communication layer. It does not add model-specific logic or introduce another sequence-parallel configuration flag. Related PRs: vllm-project#7683, vllm-project#13946 ### Does this PR introduce _any_ user-facing change? Yes. Qwen3.5 MoE models can now use MTP speculative decoding together with DP, TP, EP, and upstream MoE sequence parallelism without failing because of a token-dimension mismatch. There are no API or configuration interface changes. ### How was this patch tested? Regression coverage added: - Added `test_sp_ep_reduce_scatter_draft_vl_keeps_ep_layout`. - The test reproduces the historical draft-VL state and fails if the EP/SP finalize path attempts to use TP AllReduce. - The expected output remains the current EP rank's local token shard. - Updated the existing Qwen3.5 four-card E2E case to explicitly use: - `Qwen3.5-35B-A3B` - DP=2 - TP=2 - Expert parallelism enabled - `allgather_reducescatter` - Qwen3.5 MTP with 3 speculative tokens - `FULL_DECODE_ONLY` Local static validation: - Python syntax compilation passed for all three modified files. - `git diff --check` passed. - The final diff contains only the custom operation, regression UT, and Qwen3.5 E2E test changes. Hardware root-cause validation was performed on the equivalent fix: | Configuration | Result | | --- | --- | | SP disabled + MTP enabled | Passed | | SP enabled + MTP disabled | Passed | | SP enabled + MTP enabled with the original bypass | Failed | | SP enabled + MTP enabled after removing the draft-VL TP AllReduce bypass | Passed | Eager-mode shape tracing confirmed: ```text Before finalize: (4096, 2048) Legacy TP AllReduce result: (4096, 2048) EP ReduceScatter result: (1024, 2048) ``` The complete repository UT and the updated four-card E2E test were not executed in the local Windows workspace because it does not contain the required vLLM, PyTorch, torch-npu, pytest, or NPU runtime environment. They are left for the project CI and NPU test environment. - vLLM main: vllm-project/vllm@84030bb --------- Signed-off-by: muziyuhui666 <lijianfu9@huawei.com>
What this PR does / why we need it?
Fix Qwen3.5 MoE MTP layer shared expert shape error when flash comm v1 is enabled.
fix #7996
Does this PR introduce any user-facing change?
No.
How was this patch tested?