mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #129] [CLOSED] HIP: optimize SVDQuant INT4 activation quantization #165
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#165
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/129
Author: @tangzzycc
Created: 8/22/2026
Status: ❌ Closed
Base:
main← Head:opt/hip-svdquant-preprocess📝 Commits (3)
2bf7b4bOptimize HIP SVDQuant INT4 quantization and WMMA LoRA-down4ff75ebAddress SVDQuant review feedback71fd9edperf(hip): use torch.mm for SVDQuant LoRA-down📊 Changes
4 files changed (+155 additions, -67 deletions)
View changed files
📝
comfy_kitchen/backends/hip/__init__.py(+8 -5)📝
comfy_kitchen/backends/hip/dlpack_bindings.cpp(+0 -24)📝
comfy_kitchen/backends/hip/ops/svdquant_w4a4.hip(+102 -38)📝
tests/test_hip_wmma.py(+45 -0)📄 Description
Summary
This PR improves the HIP preprocessing path used by
quantize_svdquant_w4a4:torch.mmfor LoRA-down, matching the existing CUDA backend, and remove the dedicated scalar HIP binding.The public Python API and output layout remain unchanged.
Implementation
Sixteen threads process each 64-element quantization group. Each thread loads and retains four smoothed values, participates in a 16-lane shuffle reduction, and writes four packed INT4 values through one 16-bit store. The existing scalar kernel remains available as a fallback for operands with different dtypes.
LoRA-down is dispatched through PyTorch's matrix multiplication path instead of the previous one-output-element-per-thread HIP kernel.
Performance
Measured on an AMD Radeon 8060S (
gfx1151) with ROCm 7.2. Each result uses 20 warmup iterations followed by 100 measured iterations and reports the median kernel time.Based on the minimum required input/output traffic, the large FP16/BF16 cases reach approximately 198-209 GB/s of effective bandwidth.
Architecture verification
The extension was successfully compiled for all currently supported gfx11/gfx12 targets:
Code-object inspection confirmed packed quantizer stores and no private-memory spills in the optimized quantization kernel. Runtime performance was measured on gfx1151; the remaining targets were validated through compilation and code-object inspection.
Validation
Result:
The tests cover signed and unsigned INT4 packing, quantization-group layout, transposed scales, padded rows, and LoRA-down results against
torch.mm.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.