mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #36] [MERGED] feat: svdquant w4a4 + awq w4a16 kitchen native (CORE-31) #95
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#95
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/36
Author: @HK416-TYPED
Created: 4/21/2026
Status: ✅ Merged
Merged: 5/29/2026
Merged by: @comfyanonymous
Base:
main← Head:feat/svdquant-w4a4-kitchen-native📝 Commits (10+)
c9cdad7Add SVDQuant W4A4 + AWQ W4A16 eager backends and public APIf3206d1Add kitchen-native CUDA int4 MMA kernels for SVDQuant W4A4b6a587dAdd TensorCoreAWQW4A16Layout for modulation-style W4A16 linears671a5ebAdd CUDA backend for AWQ W4A16 with tiered M-routing3367e73Fix ruff lint: lowercase math var locals + minor cleanup12df742Fix remaining ruff lint: cuda/init.py + tensor/init.py8e8456bAdd SVDQuant W4A4 tile-packed runtime support07b4a60Fix bf16 W4A4 fast-accum CUDA compile01b1104Avoid bf16 hfma2 overload in W4A4 fast accumcf8c5cdFix SVDQuant W4A4 test ruff lint📊 Changes
15 files changed (+4481 additions, -1 deletions)
View changed files
📝
comfy_kitchen/__init__.py(+101 -0)📝
comfy_kitchen/backends/cuda/CMakeLists.txt(+3 -1)📝
comfy_kitchen/backends/cuda/__init__.py(+370 -0)📝
comfy_kitchen/backends/cuda/dlpack_bindings.cpp(+208 -0)➕
comfy_kitchen/backends/cuda/ops/awq_w4a16.cu(+617 -0)➕
comfy_kitchen/backends/cuda/ops/quantize_svdquant_w4a4.cu(+186 -0)➕
comfy_kitchen/backends/cuda/ops/scaled_mm_svdquant_w4a4.cu(+764 -0)➕
comfy_kitchen/backends/cuda/ops/svdquant_utils.cuh(+256 -0)📝
comfy_kitchen/backends/eager/__init__.py(+46 -0)➕
comfy_kitchen/backends/eager/awq.py(+108 -0)➕
comfy_kitchen/backends/eager/svdquant.py(+364 -0)📝
comfy_kitchen/tensor/__init__.py(+16 -0)➕
comfy_kitchen/tensor/awq_w4a16.py(+217 -0)➕
comfy_kitchen/tensor/svdquant_w4a4.py(+595 -0)➕
tests/test_svdquant_w4a4.py(+630 -0)📄 Description
Add SVDQuant W4A4 + AWQ W4A16 int4 quantization support for Qwen-Image-Edit and similar SVD-LoRA / AWQ-modulation checkpoints. Built as kitchen-native row-major backends.
Targets sm_80+ (Ampere).
SVDQuant W4A4
comfy_kitchen.quantize_svdquant_w4a4/scaled_mm_svdquant_w4a4astorch.library.custom_opentry points with eager pure-PyTorch reference.TensorCoreSVDQuantW4A4Layoutdispatchingaten.t/aten.mm/aten.addmm/aten.linearover int4 qdata +proj_down/proj_up/smooth_factor+ per-groupweight_scale.m16n8k64int4 MMA GEMM + fused activation quantize over kitchen-native row-major tensors; fp32 accumulator (fp16 overflows at production Qwen scale ≈ 28 — see kernel header).act_unsignedend-to-end for post-GELUfc2layers:u4.s4MMA variant ++0.171875shift applied at the layer (kernel API stays shift-free).[-7, 7](skip-8) to match nunchaku'sabsmax/7dequant-symmetric contract.addmm_(faster than kernel fusion for R=96; seescaled_mm_svdquant_w4a4docstring for the precision tradeoff and the cuBLASLt upgrade path ifneeded).
AWQ W4A16
comfy_kitchen.gemv_awq_w4a16as a single op covering both GEMV (M ≤ 8) and GEMM regimes — kernel routes internally.TensorCoreAWQW4A16Layoutdispatchingaten.t/aten.mm/aten.addmm/aten.linearover kitchen-native uint4 qdata + per-groupwscales/wzeros.mma.m16n8k16.f32.bf16.bf16.f32with cooperative dequant of int4 weight tile to bf16 in shmem. No 113 MB intermediate W workspace. shmem stride padded 8 b16 to breakthe 128-byte ldmatrix bank conflict.
limit is a follow-up tuning task).
out.add_(bias)), mirroringscaled_mm_svdquant_w4a4's epilogue contract.Tests
tests/test_svdquant_w4a4.py— 16 tests: quantizer clamp contract, signed/unsigned MMA dispatch,lora_xseparation, cross-shape smoke.Verification
ops.gemv_awqon a real r96 modulation tensor — max-abs / max-magnitude ≤ 0.65% at all M (within bf16 ULP precision floor).variant families (balanced / fast / mid / quality × ranks 32/64/96/128 × base/lightning4/lightning8) all sample successfully with the right
(steps, cfg)per distillation contract.ontract, signed/unsigned MMA dispatch, lora_x separation, cross-shape smoke.Model repository
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.