Skip to content

[CI] main2main 0703 commit: 1f486d9 - #10454

Merged
MengqingCao merged 11 commits into
vllm-project:mainfrom
zhangxinyuehfad:zxy_main2main_v0.22.1
Jul 6, 2026
Merged

[CI] main2main 0703 commit: 1f486d9#10454
MengqingCao merged 11 commits into
vllm-project:mainfrom
zhangxinyuehfad:zxy_main2main_v0.22.1

Conversation

@zhangxinyuehfad

@zhangxinyuehfad zhangxinyuehfad commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it?

vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py

vllm_ascend/distributed/weight_transfer/hccl_engine.py

  • Conditionally implement start_weight_update() and finish_weight_update() as no-op methods for non-0.23.0 releases.
  • Keep the NPU IPC weight transfer engine compatible with the updated WeightTransferEngine interface.
  • Upstream source: vllm#44353 (Weight sync refactor + move sparse nccl engine vllm#44353).

vllm_ascend/patch/platform/patch_torch_accelerator.py

  • Redirect torch.accelerator.get_memory_info() to torch.npu.mem_get_info() on non-0.23.0.
  • Avoid crashes caused by the unsupported C10 DeviceAllocator path when constructing MemorySnapshot.
  • Align with the existing NPU-specific memory API patches.
  • Upstream source: commit 747b068 (v0.24.0+ MemorySnapshot(device=device) path).

vllm_ascend/patch/worker/patch_qwen3_dflash.py

  • Wrap DFlashQwen3ForCausalLM._read_mask_embedding() to ignore optional mask embedding download failures.
  • Preserve the expected "mask embedding not present" behavior when the file is unavailable.
  • Upstream source: vllm#46104 ([Spec Decode] Support SWA + DFlash for MiMo vllm#46104).

vllm_ascend/worker/v2/model_runner.py

vllm_ascend/patch/worker/patch_v2/patch_input_batch.py

  • Forward is_padding and prompt_lens when constructing AscendInputBatch.
  • Match the updated upstream InputBatch interface and avoid initialization failures on newer releases.
  • Upstream source: vllm#40654 ([Core] Avoid seq_lens_cpu GPU->CPU sync vllm#40654).

vllm_ascend/patch/worker/patch_deepseek_v2.py


vllm_ascend/distributed/device_communicators/npu_communicator.py


vllm_ascend/ops/fused_moe/fused_moe.py


vllm_ascend/worker/worker.py

vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py

vllm_ascend/distributed/weight_transfer/hccl_engine.py

vllm_ascend/patch/platform/patch_weight_transfer_engine.py

  • Adapt WeightTransferEngineFactory.create_engine() and WeightTransferEngine.init() to support both legacy and current upstream signatures.
  • Keep weight transfer compatible across v0.23.0, v0.24.0, and newer upstream releases.
  • Upstream source: vllm#44353 (Weight sync refactor + move sparse nccl engine vllm#44353).

vllm_ascend/patch/worker/patch_deepseek_v2.py

  • Remove the upstream model-level all-gather path for DeepSeek-V2 on non-0.23.0.
  • Keep the implementation compatible with the Ascend MC2 dispatch flow.
  • Avoid tensor shape mismatches and residual concatenation failures introduced by the upstream refactor.
  • Related upstream changes:
  • vllm#41184 ([MoE Refactor] FusedMoE/MoERunner inversion refactor vllm#41184)

vllm_ascend/ops/fused_moe/fused_moe.py

  • Remove the unnecessary .contiguous() call after weight transposition on non-0.23.0.
  • Reduce transient NPU peak memory during MoE weight loading.
  • Prevent OOM caused by duplicate temporary tensor allocations.
  • Related upstream changes:
  • vllm#44589 (Remove unnecessary load_weights methods vllm#44589)

Does this PR introduce any user-facing change?

How was this patch tested?

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 updates the project to vLLM v0.22.1 and removes legacy compatibility code that was previously required for v0.21.0. The changes involve refactoring various components to use current vLLM APIs, streamlining internal logic, and ensuring consistency across the codebase by removing version-specific branches.

Highlights

  • Version Bump: Updated the project release version tag to v0.22.1.
  • Legacy Cleanup: Removed conditional logic and compatibility shims previously required for vLLM v0.21.0.
  • API Alignment: Refactored core components to align with newer vLLM APIs, including updates to DelegatingParser, routed experts handling, and scheduler block size configurations.
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.

Ignored Files
  • Ignored by pattern: .github/workflows/** (5)
    • .github/workflows/_selected_tests.yaml
    • .github/workflows/pr_test.yaml
    • .github/workflows/scripts/run_selected_tests.sh
    • .github/workflows/scripts/select_tests.py
    • .github/workflows/scripts/test_select_tests.py
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@zhangxinyuehfad zhangxinyuehfad added the ready enable e2e test for PR label Jun 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request updates the target vLLM version from v0.21.0 to v0.22.1 and cleans up the codebase by removing legacy compatibility code, conditional imports, and test skips associated with v0.21.0. The reviewer feedback is aligned with the repository style guide, providing a suggested PR Title '[CI][Misc] main2main v0.22.1' and a structured PR Summary to document these changes clearly.

Comment thread .github/vllm-release-tag.commit Outdated
@@ -1 +1 @@
v0.21.0
v0.22.1

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.

high

Suggested PR Title:

[CI][Misc] main2main v0.22.1

Suggested PR Summary:

### What this PR does / why we need it?

This PR updates the target vLLM version to `v0.22.1` and cleans up the codebase by removing compatibility layers, conditional imports, and test skips that were previously required for `v0.21.0`.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

CI passed with existing unit and E2E tests after removing the version-specific checks and skips.
References
  1. The repository style guide requires providing a suggested PR Title and PR Summary in markdown code blocks following a specific format. (link)

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

@zhangxinyuehfad
zhangxinyuehfad force-pushed the zxy_main2main_v0.22.1 branch 3 times, most recently from 5e6fd4d to 21cccaf Compare June 14, 2026 07:53
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 14, 2026
@zhangxinyuehfad
zhangxinyuehfad force-pushed the zxy_main2main_v0.22.1 branch from 21cccaf to 9a99536 Compare June 14, 2026 10:11
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@realliujiaxu realliujiaxu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets's merge this after v0.21.0 is released

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
… no-ops

vLLM 0.24.0+ (PR #44353) added start_weight_update and
finish_weight_update as abstract methods on WeightTransferEngine.
NPU IPC applies weights in-place via receive_weights's load_weights
callback, so both are no-ops. Guard them with a v0.23.0 version check
since the base class has no such methods in the older release.

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
…ve API

torch.accelerator.get_memory_info() routes through c10's
CachingDeviceAllocator and asserts the backend allocator is a
DeviceAllocator. NPU's caching allocator is not registered that way,
causing a crash in MemorySnapshot.__post_init__ → measure() when
MemorySnapshot(device=device) is constructed on v0.24.0+.

Redirect to torch.npu.mem_get_info() for NPU, matching the existing
pattern of patching torch.accelerator.memory_stats, memory_reserved,
reset_peak_memory_stats. Guard the patch with a v0.23.0 version check
since the call path only exists on newer releases.

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
vLLM's InputBatch (vllm/v1/worker/gpu/input_batch.py) was refactored
into a dataclass that requires two new fields: is_padding: torch.Tensor
and prompt_lens: torch.Tensor | None. The v2 model runner in
vllm-ascend constructs AscendInputBatch from prepare_inputs but
forgot to forward those two args, leading to a TypeError: missing 2
required positional arguments: 'is_padding' and 'prompt_lens' during
the first execute_model call.

Match the upstream signature by slicing self.input_buffers.is_padding
for is_padding and passing None for prompt_lens (R-SWA only,
not yet supported on Ascend).

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
Upstream DeepseekV2DecoderLayer (vLLM main) now constructs the
attention module with 
educe_results=not self.use_sequence_parallel_moe.
The vllm-ascend override of DeepseekV2MLAAttention.__init__
in patch/worker/patch_deepseek_v2.py did not declare the
parameter and did not forward it to the o_proj RowParallelLinear,
causing TypeError: unexpected keyword argument 'reduce_results'
when loading DeepSeek-V2/V3/R1 models.

Add 
educe_results: bool = True to the init signature and pass
it through to the o_proj. The RowParallelLinear parameter has
existed in vLLM since at least v0.23.0, so the change is compatible
across all supported versions without a version guard.

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
vLLM main introduced a fault-tolerance check in GPUModelRunner.__init__
that calls get_ep_all2all_manager() when data_parallel_size > 1 and
is_moe. The function asserts device_communicator.all2all_manager is
not None, which fails on NPU because NPUCommunicator does not
register one (NPU uses mc2 / all_gather for MoE communication
instead of the CUDA-style all2all manager).

Add a no-op _NpuAll2AllManager to NPUCommunicator that reports
support_fault_tolerance=False so the fault-tolerance path is
short-circuited. Safe across vllm versions: only main reads this
attribute; v0.23.0 and v0.24.0 never do.

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
vLLM main's FusedMoE refactor moved expert weights into a
RoutedExperts submodule, so w13_weight lives at
mlp.experts.routed_experts.w13_weight. vllm-ascend's
AscendMoERunner and downstream model loaders still look for
them at mlp.experts.w13_weight.

The previous _register_routed_expert_parameter_aliases
created a new nn.Parameter wrapping param.data and
wrapped process_weights_after_loading to pop the aliases.
This broke the gpt_oss TP=2 load because copy_/narrow on
the wrapper did not consistently reach routed_experts and
the pop timing clashed with the in-flight sharding.

Replace the wrapper with direct Parameter sharing: register
the same Parameter object on both the runner and
routed_experts via _parameters dict so any in-place update
propagates to both views. Drop the process_weights_after_loading
wrap. Apply the alias for all MoE models in vLLM main
(>=v0.24.0+ post-RoutedExperts), not just gpt_oss. v0.23.0
uses the separate AscendMoERunner in fused_moe_0_23_0.py and
is unaffected.

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
… vllm main

Commit 77a9c5ae2 ('Weight sync refactor + move sparse nccl engine #44353')
changed the WeightTransferEngineFactory.create_engine signature from
(config, parallel_config, model) to (config, vllm_config, device, model),
and WeightTransferEngine.__init__ similarly.

Add version-guarded code paths using vllm_version_is to maintain
compatibility with both v0.23.0/v0.24.0 and the current main branch.

Changes:
- worker.py: version-guard create_engine call in load_model
- npu_ipc_engine.py: version-guard __init__ signature
- hccl_engine.py: version-guard __init__ signature + add
  start_weight_update/finish_weight_update for main

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
…end MC2 dispatch

vllm main (post PR #41184 MoE Refactor) introduced an all-gather of
[hidden_states, residual] inside DeepseekV2Model.forward when
use_sequence_parallel_moe is False. This all-gather conflicts with
vllm-ascend's MC2 dispatch, which internally handles TP partitioning
via mc2_mask slicing in prepare_finalize.py.

When the model-level all-gather runs, it expands TP-partitioned
hidden_states to full size, but mc2_mask remains sized for the
partition, causing a shape mismatch in npu_moe_distribute_dispatch_v2:

  xActiveMask dim0 = 2 is not equal to x dim0 = 4

Fix: monkey-patch DeepseekV2Model.forward to remove the all-gather
path entirely. The MC2 dispatch handles TP partitioning internally,
so the model-level gather is both unnecessary and incompatible.

Also fixes a secondary crash: when residual is None (first layer,
first PP stage), the upstream code calls torch.cat([h, None])
which raises TypeError during torch.compile tracing.

The patch is guarded with vllm_version_is('0.23.0') since v0.23.0
does not have the problematic all-gather code.

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
Upstream PR #44589 (Remove unnecessary load_weights methods) changed
weight loading timing, causing all MoE weights to reside on NPU
simultaneously before process_weights_after_loading runs. For large
MoE models (e.g. Qwen3-Next-80B-A3B with TP=4), the .contiguous()
call after .transpose() doubles peak memory, triggering OOM.

Remove .contiguous() on non-v0.23.0 versions: .transpose(1,2) already
produces the correct logical layout as a zero-copy view. The subsequent
npu_format_cast / maybe_trans_nz handles the non-contiguous tensor and
produces contiguous NZ-format storage, avoiding the transient double
allocation.

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
w2_data = maybe_trans_nz(w2_data)
layer.w2_weight = torch.nn.Parameter(w2_data, requires_grad=False)
if not vllm_version_is("0.23.0"):
w13_data = self._maybe_pad_weight(layer.w13_weight.data).transpose(1, 2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why we need remove contiguous here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

  1. Peak memory reduction. After upstream PR #44589 changed the weight loading timing, all MoE weights reside on NPU simultaneously during process_weights_after_loading. .transpose(1,2) followed by .contiguous() materializes a full copy, doubling the memory footprint — causing OOM on large MoE models like Qwen3-Next-80B-A3B (TP=4).
  2. Redundant operation. .transpose(1,2) is already a zero-copy view with correct logical layout. The subsequent maybe_trans_nz() handles non-contiguous inputs and outputs contiguous NZ storage, so the intermediate .contiguous() is unnecessary.

Comment thread vllm_ascend/ops/fused_moe/fused_moe.py Outdated
w13_data = self._maybe_pad_weight(layer.w13_weight.data).transpose(1, 2).contiguous()
layer.w13_weight = torch.nn.Parameter(w13_data, requires_grad=False)
if not vllm_version_is("0.23.0"):
w13_data = self._maybe_pad_weight(layer.w13_weight.data).transpose(1, 2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ditto, why remove contiguous here?

Comment thread vllm_ascend/ops/fused_moe/fused_moe.py Outdated
Comment on lines +505 to +510
def _register_routed_expert_parameter_aliases(self) -> None:
alias_names = []
for name, param in self.routed_experts.named_parameters(recurse=False):
alias_param = torch.nn.Parameter(param.data, requires_grad=param.requires_grad)
alias_param.__dict__.update(param.__dict__)
self.register_parameter(name, alias_param)
alias_names.append(name)

original_process_weights = self._quant_method.process_weights_after_loading

@wraps(original_process_weights)
def wrapped_process_weights(layer, *args, **kwargs):
for name in alias_names:
self._parameters.pop(name, None)
return original_process_weights(layer, *args, **kwargs)

self._quant_method.process_weights_after_loading = wrapped_process_weights # type: ignore[method-assign]
object.__setattr__(self, name, param)

def _needs_routed_expert_parameter_aliases(self) -> bool:
vllm_config = get_current_vllm_config()
hf_config = getattr(vllm_config.model_config, "hf_config", None)
return getattr(hf_config, "model_type", None) == "gpt_oss"
return True

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

let's remove these 2 functions if we don't need to alia parameters

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yep

islice(self.layers, self.start_layer, self.end_layer),
start=self.start_layer,
):
if idx in self.aux_hidden_state_layers:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we could keep the same implementation with vLLM, cause the all-gather won't be triggered if we don't enable sp with the same way of vLLM. @linfeng-yuan please also take a look.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The patch is necessary, confirmed by experiment: removing it causes test_deepseek_v2_lite_fc1_tp2 to crash immediately (torch.cat([hidden_states, None]) → TypeError at deepseek_v2.py:1460).
vLLM SP and Ascend MC2 are mutually incompatible communication paths. vLLM SP requires model-level all-gather to expand hidden_states to full size; MC2 requires hidden_states to stay partition-shaped, with mc2_mask handling slicing internally. Enabling both causes xActiveMask dim0 != x dim0. This is also why platform.py:648-650 explicitly disables use_sequence_parallel_moe.
The per-layer all-gather in upstream is still needed for GPU non-SP paths, so it's not suitable for upstream removal. However, the missing residual is None guard in torch.cat is a cross-platform defect worth upstreaming. The current patch remains the cleanest fix for Ascend.

Signed-off-by: hfadzxy <starmoon_zhang@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants