Repository navigation
[Perf] diffusion: fused gate/up + SwiGLU MLP on comfy_kitchen INT8 for Qwen-Image 2.1 - #44196
Merged
mickqian merged 3 commits intoOct 18, 2026
Merged
Conversation
…en INT8 The INT8 MLP ran three GEMMs and a standalone SiLU-mul. ComfyUI runs the same checkpoint as one [gate | up] GEMM and a down-projection that applies the SwiGLU inside its quantizer (int8_linear input_act="swiglu"). Do the same on the comfy_kitchen backend. Like pack_qkv_weights, post_load_weights (and .to() round trips) move gate_layer/proj weights and row scales into one storage while the parameters keep their names and shapes. LoRA wrappers, offload placeholders, TP > 1, torch.compile and the JIT backend keep the separate projections. The fused quantizer keeps silu(gate) * up in FP32 instead of rounding it to BF16, so outputs are not bitwise the previous path; they sit slightly closer to an FP32 reference, and match ComfyUI's call. Steady model time with comfy_kitchen, 8 steps x 3 seeds: +4.5-4.8% on RTX 4090, +4.2-4.4% on RTX 5090, +2.5-3.2% on H200 (CFG 1 and 4).
niehen6174
marked this pull request as ready for review
October 14, 2026 06:10
niehen6174
requested review from
AgainstEntropy,
BBuf,
BowenBao,
HaiShaw,
OrangeRedeng,
kevin-mii,
mickqian,
ping1jing2 and
yichiche
as code owners
October 14, 2026 06:10
Collaborator
Author
|
/rerun-failed-ci |
This comment has been minimized.
This comment has been minimized.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
On the comfy_kitchen INT8 backend, Qwen-Image 2.1's MLP ran three GEMMs plus a standalone SiLU-mul:
gate_layer,proj,silu(gate) * upwritten to HBM in BF16, thenout. ComfyUI runs the same checkpoint as one[gate | up]GEMM and a down-projection that applies the SwiGLU inside its quantizer (int8_linear(..., input_act="swiglu")).Modifications
convrot_int8_comfy_kitchen.py: addcomfy_kitchen_swiglu_mlp, which makes the two kitchen calls. The linear method'sapplyis unchanged.qwen_image21.py:pack_gate_up_weights()runs frompost_load_weightsand from_apply, so packing survives.to()and CPU offload. It puts thegate_layer/projINT8 weights and row scales into one storage each. This mirrorspack_qkv_weights: parameters keep their names and shapes, and no reference to the shared storage is kept.packed_gate_up()re-derives the stacked views on every forward.Accuracy Tests
silu(gate) * upin FP32 instead of rounding it to BF16 first, so outputs are not bitwise the previous path.test_convrot_int8_backends.py) checks:Speed Tests and Profiling
Qwen-Image 2.1 INT8 checkpoint, comfy_kitchen backend, SGLD ComfyUI workflow, 8 steps × 3 seeds. Steady model-time gain:
H200, B200 and RTX 5090 default to the JIT backend, where this path is inactive. RTX 4090 (sm89) always uses comfy_kitchen.
Checklist
CI States
Latest PR Test (Base): ✅ Run #39116725304
Latest PR Test (Extra): ❌ Run #39116725117
Latest PR Test (AMD ROCm 10): ⏳ Run #39116725108