mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #219] Add prequantized INT8 GEMM with indexed BF16 gate and residual #234
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#234
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/219
Author: @Tokha233
Created: 9/30/2026
Status: 🔄 Open
Base:
main← Head:cuda/indexed-gate-epilogue📝 Commits (5)
dc7c739Add prequantized INT8 GEMM with indexed BF16 gate and residual5f7290dFix indexed gate fallback layout and wheel licensef5e8698Merge main and retain indexed operator exportsd3b3ec2Avoid unused indexed-gate output allocation on fallback62609ccSync indexed gate exports with Kitchen 0.2.40📊 Changes
14 files changed (+1074 additions, -1 deletions)
View changed files
📝
NOTICE(+7 -0)📝
comfy_kitchen/__init__.py(+2 -0)📝
comfy_kitchen/backends/cuda/CMakeLists.txt(+1 -0)📝
comfy_kitchen/backends/cuda/dlpack_bindings.cpp(+42 -0)➕
comfy_kitchen/backends/cuda/ops/cutlass_gemm_indexed_gate.cu(+223 -0)➕
comfy_kitchen/backends/cuda/ops/indexed_gate.cuh(+155 -0)➕
comfy_kitchen/indexed_gate.py(+129 -0)➕
docs/benchmarks/gate-api-benchmark.json(+210 -0)➕
docs/benchmarks/indexed-gate-wheel.json(+11 -0)➕
docs/benchmarks/int8-indexed-gate.md(+52 -0)➕
docs/benchmarks/source-sha256.json(+11 -0)📝
pyproject.toml(+1 -1)➕
tests/benchmark_int8_indexed_gate.py(+72 -0)➕
tests/test_int8_indexed_gate.py(+158 -0)📄 Description
This introduces an opt-in prequantized
int8_gemm_indexed_gateoperation for diffusion branches with a compact gate table. It fuses indexed gate loads and residual addition into the INT8 GEMM epilogue, avoiding the BF16 branch and expanded gate intermediates.The contract intentionally rounds the scaled GEMM result to BF16 before the FP32 FMA with BF16 gate/residual and final BF16 rounding. Existing
int8_linearand column-broadcast residual semantics are unchanged. This uses the existing Stream-K implementation and does not duplicate #215's N-banded scheduling work.RTX 5090 D v2 measurements
Main
19ea55b(Kitchen0.2.36), CUDA13.0.88, PyTorch2.12.0+cu130; pinned upstream CUTLASS. Baseline: existing fused-dequant GEMM + gate gather + torch.addcmul. Candidate: public API including validation/fallback overhead. Eight alternating groups of ten warmed calls, CUDA events, exact BF16 outputs in every case.M1024 cases use the ordinary chain after the fused tile regressed in testing; measured wrapper overhead was 0.5–0.9%. No whole-model speedup or perceptual quality improvement is claimed: consumers must explicitly use this API. Full samples, a reproduction script and the contract are in
docs/benchmarks/int8-indexed-gate.md.API and validation
Prepared with AI assistance; measurements were run on the stated hardware. Feedback on whether this should later be integrated into the broader linear API is welcome; this PR keeps the new numerical/indexing contract separate.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.