mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[GH-ISSUE #280] INT8 linears on sm_121 (GB10 / DGX Spark) run at ~37% of tensor-core peak via cutlass_int8_dequant; a fused-dequant Triton GEMM reaches ~88%, bit-identical #75
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#75
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?
Originally created by @kanthai on GitHub (Oct 26, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-kitchen/issues/280
Summary
On NVIDIA GB10 (DGX Spark, sm_121), comfy-kitchen 0.2.37 sends INT8 tensorwise linears to
_C.cutlass_int8_dequant. It sustains about 72 TOPS, slower than the BF16 GEMM on the same chip. Themma.syncINT8 peak at the clock we run (1989 MHz) is 196 TOPS. A simple Triton GEMM with an int32 accumulator and the dequant (x_scale·w_scale + bias) fused into the epilogue reaches about 170 TOPS (88% of peak). Its output is bit-identical to the CUTLASS kernel. End to end, this makes INT8 checkpoints faster than BF16/FP8 on GB10 instead of slower.Related: #98 (same class of problem — CUTLASS INT8 dequant picking a poor config for tall MiniMax H3 shapes — on an RTX A6000) and #237 (sm86 tile chooser; its description notes the generic
select_fused_int8_configthresholds were fitted on Ada and Blackwell). GB10 is Blackwell but with a very different memory system (unified LPDDR5x), which may be why the Blackwell fit misses here.Question for maintainers: would you take a Triton fallback for sm_121, or would you rather add an sm_121 entry to the CUTLASS tile chooser (like #237 does for sm86)? We can share the sweep data either way.
Environment
comfy-kitchen 0.2.37 (0.2.40 routes the same way), torch 2.14.0+cu130, triton 3.8.0, ComfyUI 0.41.3, NVIDIA DGX Spark: GB10 with 48 SMs, sm_121, unified LPDDR5x (~273 GB/s).
Measured
mma.syncpeaks at 1989 MHz: NVFP4 391, INT8 = FP8 196, BF16 98 TOPS.Where the time goes (installed sources)
comfy_kitchen/backends/cuda/__init__.py:321:_cuda_device_supports_cutlass_int8_dequantreturns True for everymajor >= 8, so sm_121 takes the CUTLASS path._C.cutlass_int8_dequant(...)call sites are at about lines 1009, 1192 and 2221 (int8 GEMM,scaled_mm,int8_linear).COMFY_KITCHEN_DISABLE_CUTLASS=1(cuBLAS int32 GEMM + separate dequant) reaches about 105 TOPS but needs about 3 GB of int32 scratch for H3 shapes. That round-trip is expensive at ~273 GB/s.Kernel used
Triton, an int32 accumulator over K, fp32 epilogue:
acc * x_scale[m] * w_scale[n] (+ bias[n])→ the output dtype.Config: BM=128, BN=128, BK=64, num_warps=8, num_stages=4, grouped launch G=8, with int64 row/column offsets. Without int64, M·N or M·K past 2^31 elements wraps in int32. That happens with CFG batches or long video clips (M ≥ 74.9k at N = 28672).
The sweep found this config best, or within 1%, on every H3 linear shape at 29k and 36k tokens. Residual-fused calls, M < 128, K not a multiple of 16 and non-contiguous tensors stay on CUTLASS (so anything CUTLASS declines still takes comfy-kitchen's stock cuBLAS route).
Results (same graphs, same seeds)
Without the faster kernel, INT8 on GB10 is slower than BF16. With it, Comfy-Org's int8_convrot releases are the fastest and the most faithful option on this hardware: in our tests, NVFP4 W4A4 visibly changes content. For example, a Krea2 fine-tune made INT8 from the official BF16 gets 21.7 dB PSNR vs BF16, against 17.0 dB for FP8, at 9.6 vs 17.8 s/img.
For contrast, on an RTX PRO 2000 Blackwell (sm_120, 34 SMs, PCIe), stock CUTLASS INT8 is already good: 1308 ms/forward vs Triton 1509. The gap seems specific to GB10 (low memory bandwidth, unified memory), not to all of Blackwell.
Exactness
INT8×INT8 accumulation in int32 is exact. The epilogue computes in fp32 in the same order as the CUTLASS epilogue (
acc * xs * ws + bias). The evidence that the outputs match:torch.equalagainst_C.cutlass_int8_dequant;How we deploy it now
We deploy it as a
.pth-loaded proxy aroundcomfy_kitchen.backends.cuda._Cthat swaps onlycutlass_int8_dequant, with the same signature. It is version-guarded to comfy-kitchen 0.2.37 and falls back to stock on any Triton import or build failure. We would much rather this lived upstream behind a capability check (for example sm_121 / integrated GPUs, or a measured-throughput gate).Source of the proxy and kernel, the benchmark tools and the full write-up: https://github.com/kanthai/gb10-comfyui-tuning (
patches/ck_int8_patch.py,docs/02-int8-triton-gemm.md).