mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #151] [MERGED] [Feat][Ascend] Add Ascend INT8 quantization backend #180
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#180
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/151
Author: @Big2Wheel
Created: 9/3/2026
Status: ✅ Merged
Merged: 9/24/2026
Merged by: @comfyanonymous
Base:
main← Head:codex/ascend-backend-base📝 Commits (3)
4cffd74feat(npu): add Ascend quantization backend4a1442ftest(npu): include NPU in supported devices3bab240refactor(ascend): clarify backend naming📊 Changes
7 files changed (+394 additions, -41 deletions)
View changed files
📝
README.md(+56 -38)📝
comfy_kitchen/__init__.py(+1 -0)➕
comfy_kitchen/backends/ascend/__init__.py(+187 -0)📝
comfy_kitchen/registry.py(+1 -1)📝
tests/conftest.py(+2 -2)➕
tests/test_ascend_backend.py(+137 -0)📝
tests/test_backends.py(+10 -0)📄 Description
What this PR does
Adds an optional
ascendbackend for Huawei Ascend NPU hardware to comfy-kitchen and registers the first INT8 quantization primitives:quantize_int8_rowwiseusingtorch_npu.npu_dynamic_quantquantize_int8_tensorwiseusing Ascend reductions andtorch_npu.npu_quantizedequantize_int8_simpledequantize_int8_simple_dtypeThe backend is registered only when torch-npu and an Ascend device are available. CPU, CUDA, HIP, and XPU installations do not gain a torch-npu dependency. The project-facing backend name is
ascend; the PyTorch device type remainsnpubecause that is the API defined by torch-npu.Constraint-based dispatch limits the Ascend implementation to supported devices and dtypes. FP32 inputs and stochastic rounding continue through the existing device-side eager implementation rather than copying tensors to CPU.
This is the backend-foundation part of Ascend support. INT8 Linear and additional fused operators will be proposed separately to keep review scope focused.
Related to Comfy-Org/ComfyUI#11909.
Why
Without an Ascend backend, comfy-kitchen cannot select torch-npu quantization operators. This change establishes the backend integration and validates the Q/DQ contract before adding Ascend INT8 matrix multiplication.
Testing
Tested on one Huawei Ascend 910B3 device with torch 2.10.0 and torch-npu 2.10.0.post4.
ruff check: passedgit diff --check: passedThe skipped tests require unavailable CUDA/HIP hardware.
Ascend profiler traces confirmed:
npu::npu_dynamic_quant/aclnnDynamicQuantV2npu::npu_quantize/aclnnQuantizeFor a BF16 tensor with shape
[8352, 3840](10 warmups, 30 measured iterations):Tests cover FP16/BF16, all-zero rows, supplied/recalculated scales, output dtypes, automatic backend selection, unsupported-call rejection, and device-side eager fallback.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.