mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #124] Round fused SwiGLU to the storage dtype before ConvRot. #159
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#159
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/124
Author: @niehen6174
Created: 8/20/2026
Status: 🔄 Open
Base:
main← Head:fix/int8-swiglu-match-eager📝 Commits (1)
860255dRound fused SwiGLU to the storage dtype before ConvRot.📊 Changes
3 files changed (+33 additions, -7 deletions)
View changed files
📝
comfy_kitchen/backends/cuda/ops/int8_linear.cu(+7 -2)📝
comfy_kitchen/backends/hip/hadamard.h(+14 -2)📝
tests/test_int8_input_act.py(+12 -3)📄 Description
Summary
int8_linear(..., input_act="swiglu")is supposed to equalint8_linear(silu(gate)*up, ...).The fused CUDA/HIP quantizer left
silu*upin fp32, so ConvRot's per-row absmaxdiverged from the eager chain (which materializes BF16/FP16). One LSB of scale
rewrites the whole INT8 row.
This PR rounds silu and the multiply to the storage dtype before the rotation.
Accuracy
Kitchen unit shapes + MiniMax-H3 fc2 (
N=5376,K=14336), isolated build of this patch,F.silu(gate)*upthenint8_linearvs fused:Same H3 t2va, 50 NFE, seed=42, INT8+FA, old fused kernel (fp32 product) vs
unfused INT8 (eager SwiGLU then quantize):
That is a different diffusion sample, not a slightly noisier tensor.
After this PR, fc2 is bit-exact, so that pair should be identical (PSNR 99).
Speed (why keep the fuse)
H3 fc2, M=32700, RTX 4090 D, CUDA event, 50 DiT blocks/step:
silu*mul+int8_linearinput_act=swiglu(this PR)20 NFE exclusive 4090 D (SGLang, earlier run with the old fuse; wall-clock
should match because the extra rounding is register-only):
Test plan
CUDA+bf16
int8_linear(x, input_act="swiglu")musttorch.equalthe eager chain.FP16/BF16 fused INT8 codes must equal
quantize(silu(gate)*up).Files
comfy_kitchen/backends/cuda/ops/int8_linear.cu— CUDA quantizercomfy_kitchen/backends/hip/hadamard.h— HIP mirrortests/test_int8_input_act.py— require bit-exact on the fused CUDA path🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.