Attention Override (Per Model)
SageAttention Is Breaking One of Your Models? Stop Restarting
- model
- MODEL
You launched ComfyUI with --use-sage-attention, everything got faster, and then one model started spitting out garbage. Patchy images, matrix-code lines, sometimes pure black frames. Before you rip SageAttention out and restart - which is the fix everyone first reaches for - know that this node exists to save you the restart.
Attention Override (Per Model) does exactly one thing: it tells ComfyUI to use a different attention implementation for the single model you route through it, while the rest of your workflow keeps humming along on the fast path. It's a thin, dependency-free utility from EnviralDesign, and for a specific recurring pain it's the cleanest answer going.
The pain it solves is real
This isn't a theoretical node. SageAttention - the memory-efficient attention package that's become the default speed lever for big video and image models - is known to break specific checkpoints. The canonical example is Z-Image Base: release-day testing confirmed severe artifacts across 3090, 4090, and 5090 hardware, patchy/blurry output, and black frames, all traced back to SageAttention. Turbo was fine; Base wasn't. People with multiple workflows were left maintaining separate ComfyUI launch scripts - one with Sage, one without - or globally disabling it and losing the speedup everywhere.
There's a thread on r/comfyui from January 2026 titled "I think it is time that we can set attention for each inference without restart," complaining about exactly this. This node is that feature, delivered as a per-model override instead of a per-workflow one.
How it works
Under the hood it's honest plumbing. The node clones your model (model.clone()) and writes a key into the model's transformer_options: optimized_attention_override. ComfyUI's attention code checks for that key on every attention call, and when it's present, runs your chosen attention function instead of the global default. No patching, no monkeying with startup flags, no rebuild.
Because it works on a clone, only the model passed through it is affected. The original model object is untouched, and the node doesn't call anything outside ComfyUI's own attention implementations.
The inputs that matter
There are two, and one of them is just the model you want to fix:
- model - the MODEL you want to override. Wire this in after your model loader (and any patching/LoRA nodes) and feed the output to your KSampler's model input.
- mode - the dropdown. Five choices:
disabled(default),sdpa,pytorch,sage,flash.
The ones you'll actually set:
sdpa(or its aliaspytorch) - forces PyTorch's scaled dot-product attention for this model. This is the opt-out mode. If ComfyUI is running with global SageAttention and one model hates it,sdpais what you want.disabled- removes the per-model override so the model falls back to ComfyUI's global attention choice. Trap alert:disableddoes not turn off global SageAttention. If you launched with--use-sage-attention, disabled means "let the global Sage win," so it won't fix a broken model.sage/flash- force those implementations, but only if they're actually installed. Otherwise the node raises an error at execution.
The output is a single MODEL - the patched clone - and it goes straight into your sampler chain.
Installing it
Dead simple, and this is the nice part: the pack has zero dependencies. No SageAttention, no Triton, no flash-attn, no model downloads. The override just selects between attention functions that must already exist in your ComfyUI install.
Via ComfyUI Manager: search for comfy-sageattention-optout-customnodes. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/EnviralDesign/comfy-sageattention-optout-customnodes
Then restart ComfyUI. The node lives under loaders/model in the node menu.
Troubleshooting
- "SageAttention is not available in this ComfyUI environment" when you pick
sage- that's the node being honest: SageAttention isn't installed. It won't install it for you. On Linux that's usuallypip install sageattention; on Windows it's the notorious Triton/compile saga that eats weekends. - "Install flash-attn" when you pick
flash- same deal, flash-attn isn't present. - Model still broken in
disabledmode - read the trap above; you wantsdpa. - Wrong model got fixed - the override travels with the cloned model. If the node sits before a model merge or switch, the override goes with that branch. Put it directly on the path to the sampler whose model is broken.
If you're running a mixed workflow where Z-Image or another Sage-hating checkpoint shares a graph with models that benefit from it, this node is the difference between one workflow and two installs. Small, boring, and exactly right.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| mode | COMBO | disabled | 'disabled' removes the per-model override and falls back to ComfyUI's global attention choice. 'sdpa' and 'pytorch' both force PyTorch attention for this model. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |