mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #154] [CLOSED] [Feat][Ascend] Add Ascend RoPE and RMS-RoPE backend #182
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-kitchen#182
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-kitchen/pull/154
Author: @Big2Wheel
Created: 9/4/2026
Status: ❌ Closed
Base:
main← Head:codex/ascend-rope-rms-rope📝 Commits (6)
5942faefeat(npu): add Ascend quantization backend1ecb943test(npu): include NPU in supported devices0bccee7refactor(ascend): clarify backend naming5018b5efeat(ascend): add RoPE and RMS-RoPE backend436dcb7fix(ascend): validate required operator schemas4d5513afix(ascend): decouple backend capabilities📊 Changes
9 files changed (+1248 additions, -41 deletions)
View changed files
📝
README.md(+63 -38)📝
comfy_kitchen/__init__.py(+1 -0)➕
comfy_kitchen/backends/ascend/__init__.py(+379 -0)➕
comfy_kitchen/backends/ascend/rope.py(+365 -0)📝
comfy_kitchen/registry.py(+1 -1)📝
tests/conftest.py(+2 -2)➕
tests/test_ascend_backend.py(+137 -0)➕
tests/test_ascend_rope.py(+292 -0)📝
tests/test_backends.py(+8 -0)📄 Description
What this PR does / why we need it
Adds an optional Huawei Ascend backend for Comfy Kitchen's RoPE and RMS-RoPE APIs.
Supported public APIs:
apply_rope,apply_rope1,apply_rope_split_half, andapply_rope_split_half1rms_rope,rms_rope1,rms_rope_split_half, andrms_rope_split_half1The backend uses
torch_npu.npu_rotary_mulfor rotary embeddings andtorch_npu.npu_rms_normfor fused RMS normalization. It supports FP16/BF16, BNSD/BSND layouts, interleaved and split-half rotary conventions, packed-QKV strided views with a contiguous final dimension, GQA-style head counts, and partial rotary dimensions where exposed by the public API.Capability checks reject unsupported shapes, layouts, dtypes, and broadcast patterns before dispatch, allowing the registry to select another capable backend. Runtime operator errors are not silently swallowed.
Relationship to #151 and #153
This is a stacked PR that currently depends on #151, which introduces the generic Ascend backend registration, availability detection, and baseline quantization support. The PR-specific commits to review on top of #151 are the RoPE implementation and its two capability-validation follow-ups.
#153 is a sibling feature PR, not a dependency of this PR. Both #153 and this PR branch directly from #151:
After #151 merges, this branch will be rebased onto
main; the PR diff will then contain only the RoPE/RMS-RoPE changes. No INT8-linear changes from #153 are included here.Does this PR introduce any user-facing change?
Yes. On supported Ascend NPU installations, the registry can select the new Ascend implementation for compatible RoPE and RMS-RoPE calls. Other devices and unsupported Ascend call patterns retain the existing backend fallback behavior.
How was this patch tested?
Hardware: Huawei Ascend 910B3, restricted to one NPU with
ASCEND_RT_VISIBLE_DEVICES=7.Tests
Coverage includes FP16/BF16, BSND/BNSD, pair/single APIs, interleaved/split-half conventions, in-place/out-of-place behavior, packed QKV views, partial rotary dimensions, GQA head counts, input preservation, alias rejection, unsupported-call fallback, and automatic backend selection.
ruff checkandgit diff --checkalso pass for all changed Python files.Profiler verification
A torch profiler trace confirms that the implementation reaches the Ascend operators:
No layout-induced
contiguousoperation appears in the profiled supported path.Operator benchmark
Each measurement used 10 warm-up iterations and 30 synchronized measured iterations. Times include coefficient conversion and required dtype semantics.
[1, 4096, 30, 128][1, 4096, 30, 128][1, 12288, 16, 128][1, 12288, 16, 128]End-to-end workflow validation
Z-Image BF16 showed the expected operator dispatch (272 RMS-RoPE calls per request), but no stable end-to-end improvement, so no image-workflow speedup is claimed.
For a fixed-seed Wan2.2 14B text-to-video workflow at 640x640 and 81 frames (320 RoPE calls per request):
This is a 4.73% mean end-to-end reduction. Decoding both generated videos and comparing all 81 frames produced zero differing pixel values (
max_diff = 0).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.