mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #161] [CLOSED] [Feat][Ascend] Add ConvRot W4A4 linear backend #186
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#186
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/161
Author: @Big2Wheel
Created: 9/7/2026
Status: ❌ Closed
Base:
main← Head:codex/ascend-convrot-w4a4📝 Commits (10+)
5942faefeat(npu): add Ascend quantization backend1ecb943test(npu): include NPU in supported devices0bccee7refactor(ascend): clarify backend naming6ab910afeat(ascend): add INT8 linear backend91a5a3ftest(ascend): handle optional quant matmul8651a6dfeat(ascend): add fused rotate quant backendd8dd6d8fix(ascend): handle zero quantization scales9ad6f5efeat(ascend): add ConvRot W4A4 linear backendaaad462fix(ascend): guard RotateQuant feature limit8232c93test(ascend): cover fallback without RotateQuant📊 Changes
7 files changed (+1368 additions, -45 deletions)
View changed files
📝
README.md(+76 -38)📝
comfy_kitchen/__init__.py(+1 -0)➕
comfy_kitchen/backends/ascend/__init__.py(+595 -0)📝
comfy_kitchen/registry.py(+1 -1)📝
tests/conftest.py(+2 -2)➕
tests/test_ascend_backend.py(+668 -0)📝
tests/test_backends.py(+25 -4)📄 Description
What this PR does / why we need it
Adds an optional Ascend implementation of
convrot_w4a4_linear, prioritizing the eager reference's numerical behavior.Correctness revision
The previous implementation silently converted FP32 activations to BF16 before rotation/quantization, and narrowed all matmul results through FP16. An audit demonstrated changed INT4 activation codes, fixed-seed image divergence, and finite FP32/BF16 inputs producing non-finite outputs where eager remained finite.
This revision:
npu_quant_matmulwith a unit FLOAT scale, no per-token scale, and INT32 output;This is not a zero-copy packed-INT4 matmul implementation. It trades unpacking and reference-preprocessing cost for correctness. FP16 retains eager's own intermediate-range limitations; the implementation does not promise greater precision than the reference.
Correction of earlier claims
Both eager and Ascend paths quantize activations to A4. The earlier explanation that the image difference was expected simply because the optimized path quantizes activations was incorrect.
The previously reported 134.00 s / 2.73x result belongs to the superseded, numerically different implementation. It is withdrawn as a performance claim for the current revision. New diagnostic timings are not a repeated hot A/B benchmark and no speedup is claimed here.
Relationship to the other Ascend PRs
int8_linearAPI or change its semantics.After the predecessor stack lands, this PR can be rebased on
mainto leave the W4A4-specific changes.The branch also merges main through
21003fa, retaining both the upstream allocation-context import and optional Ascend registration to resolve their import conflict. The same regression suite passed again after this merge.Does this PR introduce any user-facing change?
Yes. Eligible Ascend ConvRot W4A4 calls use the correctness-first integer-accumulation implementation. Weights remain INT4-quantized on disk/in the caller, but the backend materializes INT8 values for matmul. No new mandatory dependency or opt-in environment variable is introduced.
How was this patch tested?
Hardware/runtime: one Ascend 910B3 (physical card 4), PyTorch 2.10.0+cpu with torch_npu 2.10.0.post4, CANN 9.1.0.
ruff check,ruff format --check, andgit diff --checkpassed.The ComfyUI validation checkout retains the existing local integration shim routing the custom node's mixed INT8 layers through Comfy Kitchen. It is identical between comparisons and is not part of this PR. No multi-seed quality, peak-memory, or general performance guarantee is implied by the fixed-seed test.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.