Patch Sage Attention KJ
The in-graph switch for a free speedup on Flux and Wan
- model
- MODEL
If you run Wan, Flux, or any of the big diffusion-transformer models, you've seen "SageAttention" thrown around as the free-speedup everyone swears by. This node is how you flip it on from inside a workflow instead of relaunching ComfyUI with a global flag. You wire your model through it, pick a backend, and attention gets computed the fast way. Reach for it when a model runs but runs slowly, and you'd like it faster without touching resolution, steps, or your sampler.
SageAttention is a quantized, memory-efficient replacement for the attention math that eats most of your inference time on these models - it quantizes the attention op much the way fp8 quantizes the weights. It lives in the same acceleration toolbox as fp8, TeaCache, and torch.compile, and it stacks with all of them. One 4090 report in the Wan community hit ~5:30 for an 81-frame clip with SageAttention, TeaCache, and torch.compile all on at once. The quality cost, when it works, is usually close to invisible.
It comes from KJNodes, the sprawling utility pack by Kijai - the same author behind ComfyUI-WanVideoWrapper, the IC-Light nodes, and roughly half the day-one fixes the video community runs. If a node accelerates or unblocks a new model, odds are decent his name is on it. The pack is deliberately kept light on dependencies, which matters a lot here (more below).
What it actually does
You feed a loaded model in, pick a backend, and it hands back a MODEL that computes attention with SageAttention. That's the whole job. Drop it between your model loader and your sampler and route the patched output onward - nothing else in the graph changes.
The catch that trips people up: this node does not go through ComfyUI's normal model-patching system. It's a global monkey-patch. Once you run the graph with it enabled, attention stays patched for the rest of the session, so muting or bypassing the node does not undo it. To actually turn it back off you set the mode to disabled and run again. Keep that in mind when you're A/B testing quality.
The inputs that matter
Really just one:
sage_attention- the backend. Start onautoand let it pick what your install supports.disabledis both "off" and the deliberate way to un-patch. Thesageattn_qk_int8_pv_fp16_*variants are the safe choice on older cards; the..._fp8_cuda/_fp8_cuda++variants are faster but want a modern NVIDIA card (Ada / RTX 40-series or newer, the same hardware that does native fp8);sageattn3/sageattn3_per_block_meanare SageAttention 3, newest and fastest, but need SA3 installed and Blackwell-class hardware.allow_compile(optional, off by default) - lets it coexist with torch.compile when you're compiling the model too.
The single output is MODEL.
Installing it
KJNodes is big and popular, so the easy path is ComfyUI Manager: search "KJNodes for ComfyUI", install, restart. Manual is just as quick:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt
Then restart ComfyUI. There are no model files to download - this node patches code, not weights.
Where people get burned
The number-one issue, and it's a rite of passage: ModuleNotFoundError: No module named 'sageattention'. KJNodes keeps its own dependencies minimal, so it does not bundle SageAttention. This node only flips the switch - the sageattention package (and its dependency, Triton) has to already be importable in the exact environment ComfyUI runs in. On Linux that's usually a pip install away. On Windows, Triton is famously painful, and people lean on a handful of unofficial Windows Triton wheels to get there. A ComfyUI version bump can also knock the package out of the path, so if it worked yesterday and dies today with that error, reinstall sageattention before you blame the node.
Second: it doesn't help every model, and it actively breaks some. SageAttention and Qwen-Image don't get along - the common report is all-black outputs, and the community advice is blunt: for Qwen, delete the node, it does nothing good. Z-Image Base has the same problem (black or matrix-code artifacts) while Z-Image Turbo is fine. And plenty of people wire it in expecting magic and see no speedup at all, because the win depends on the model and the rest of your stack. Because it's filed under KJNodes/experimental, treat it that way: eyeball an output against an un-patched run before you commit a whole batch. If quality looks off, disabled plus a re-run is your undo.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| sage_attention | COMBO | false | Patch the attention of the model passing through this node to use sageattn. To revert, run this node again with the disabled option. Requires the sageattention library to be installed. |
| allow_compileopt | BOOLEAN | false | Allow the use of torch.compile for the sage attention function, requires latest sageattn 2.2.0 or higher. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |