Skip to content

fix(npu): adapt colocate patch for vllm-ascend and vllm version upgrade#318

Open
miracle0517 wants to merge 1 commit into
vllm-project:ascendfrom
miracle0517:ascend_colocate
Open

fix(npu): adapt colocate patch for vllm-ascend and vllm version upgrade#318
miracle0517 wants to merge 1 commit into
vllm-project:ascendfrom
miracle0517:ascend_colocate

Conversation

@miracle0517

@miracle0517 miracle0517 commented Jul 3, 2026

Copy link
Copy Markdown

Summary

  • Update the NPU colocate patches for 0.22.1rc1 vLLM and vllm-ascend versions.
  • Reduce transformers log noise in the NPU Qwen3-4B run script.

Test

  • Tested Qwen3-4B colocate on the A2 machine
  • Rebuild image from docker/Dockerfile.npu
image image

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

Copy link
Copy Markdown

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 configures line endings for patch files, cleans up commented-out lines in the vllm-ascend.patch file, adds a patch to disable flash attention rotary embedding on NPU platforms, and sets TRANSFORMERS_VERBOSITY=error in the Qwen3 NPU execution script. The feedback highlights a potential risk in using hasattr(current_platform, "is_npu") to check for NPU platforms, as it could cause performance regressions on other platforms if is_npu is added to the base platform class in the future. A safer alternative using getattr with a default fallback callable is suggested.


self.apply_rotary_emb_flash_attn = None
- if not current_platform.is_cpu() and find_spec("flash_attn") is not None:
+ if not current_platform.is_cpu() and find_spec("flash_attn") is not None and not hasattr(current_platform, "is_npu"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Using not hasattr(current_platform, "is_npu") to check if the platform is not an NPU is risky and not future-proof. If a future version of vLLM adds the is_npu method to the base Platform class (returning False by default, similar to is_xpu or is_hpu), then hasattr(current_platform, "is_npu") will evaluate to True on all platforms, including CUDA. This would cause the condition to evaluate to False on CUDA, silently disabling the flash attention rotary embedding and leading to a significant performance regression.\n\nA safer and more robust approach is to check if the attribute exists and call it, or use getattr with a default callable:\nnot getattr(current_platform, "is_npu", lambda: False)()

+        if not current_platform.is_cpu() and find_spec("flash_attn") is not None and not getattr(current_platform, "is_npu", lambda: False)():

@miracle0517 miracle0517 changed the title [WIP] fix(npu): adapt colocate patch for vllm-ascend and vllm version upgrade fix(npu): adapt colocate patch for vllm-ascend and vllm version upgrade Jul 8, 2026

@CalvinXKY CalvinXKY 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.

LGTM

@Meihan-chen

Meihan-chen commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Version adaptation looks good. Going forward (not blocking): could the colocate weight sync migrate to fully reuse the native NPUIPCWeightTransferEngine instead of maintaining the custom _patch_npu_colocate_worker / update_weights_chunk path? Would save carrying this patch long-term. Context: #285 (comment) — worth tracking as a follow-up on your side? cc @CalvinXKY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants