mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #86] [MERGED] rms_adaln and input_act kernels #135
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#135
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/86
Author: @kijai
Created: 7/27/2026
Status: ✅ Merged
Merged: 7/27/2026
Merged by: @comfyanonymous
Base:
main← Head:ltx2_kernels📝 Commits (3)
b7f20c6rms_adaln and input_act kernels5ea7a08For correctnes24e680eMerge branch 'main' into ltx2_kernels📊 Changes
16 files changed (+759 additions, -125 deletions)
View changed files
📝
comfy_kitchen/__init__.py(+31 -0)➕
comfy_kitchen/backends/_activations.py(+45 -0)📝
comfy_kitchen/backends/cuda/__init__.py(+64 -12)📝
comfy_kitchen/backends/cuda/dlpack_bindings.cpp(+48 -4)📝
comfy_kitchen/backends/cuda/dtype_dispatch.cuh(+14 -0)📝
comfy_kitchen/backends/cuda/ops/adaln.cu(+59 -47)📝
comfy_kitchen/backends/cuda/ops/int8_linear.cu(+56 -51)📝
comfy_kitchen/backends/cuda/utils.cuh(+11 -0)📝
comfy_kitchen/backends/eager/__init__.py(+10 -1)📝
comfy_kitchen/backends/eager/adaln.py(+24 -0)📝
comfy_kitchen/backends/eager/quantization.py(+7 -1)📝
comfy_kitchen/backends/triton/__init__.py(+11 -1)📝
comfy_kitchen/backends/triton/adaln.py(+27 -8)📝
comfy_kitchen/backends/triton/quantization.py(+3 -0)📝
tests/test_adaln.py(+173 -0)➕
tests/test_int8_input_act.py(+176 -0)📄 Description
Add rms_adaln and int8_linear(input_act=...)
Two fusions for RMSNorm-style DiTs (LTX), reusing existing kernels rather
than adding new ones. Tested in practice that when applied, this gives small but free speed boost for LTX2 inference.
rms_adaln(x, scale, shift, eps)—rmsnorm(x) * (1 + scale) + shift. Theexisting
adalnis LayerNorm-based and not substitutable. RMSNorm is LayerNormwith the mean pinned to zero, so
adaln.cuis templated onkSubtractMeanandboth share one kernel. All three backends. 3.0x over eager at 14080x4096.
int8_linear(..., input_act="gelu_tanh")— folds an MLP's activation intothe ConvRot INT8 quantizer, so
linear(act(proj(x)))stops round-tripping act'soutput through HBM. Costs +0.02 ms on the quantizer, removes a 0.25 ms kernel,
and drops FF peak VRAM 36%. One optional parameter, not a new op; paths that
can't fuse apply the activation eagerly, so all routes agree.
7.1% end to end on LTX2 in ComfyUI (1.84 -> 1.97 it/s, int8+ConvRot).
Notes
modulation_rowmoved toutils.cuh; must match_modulation.py, where adivide-vs-modulo mix-up is silent and only diverges for batch > 1.
backends/_activations.py, mirroring_modulation.py, keeping the enum in sync withint8_linear.cu.neither rounds the intermediate to the input dtype.
Testing
121 tests (62 new in
test_adaln.py, 22 intest_int8_input_act.py): broadcastat batch 1/2/3, per-token modulation, odd and large
D, both CUDA kernel paths,non-contiguous inputs, and every fallback route.
adalnoutput verifiedbyte-identical across 3 dtypes x 10 shapes.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.