interrupt on NaN
Stop wasting a full render on a run that's already broken
- model
- MODEL
If a diffusion model's forward pass ever produces a NaN (an invalid, not-a-number value), you don't find out until the VAE decodes it - and what comes out is a flat black frame, every time. It's a well-known failure mode independent of this pack: older pre-Turing GPUs that don't handle fp16 cleanly, a bad xformers build, or - the reason this node exists in the first place - TensorRT occasionally throwing a NaN mid-run. Without this node, you sit through the full step count and only find out at the very end, when the image comes back black.
interrupt on NaN is a small model-patch safety net that watches for that failure as it happens instead of after the fact. Per the README: "tensor rt would sometimes throw a random black image. What this node does is that it cancels the sampling if any invalid value is detected. Also useful if you want to test Uncond Zero with bogus scales."
How it works
Wire it into your model chain like any other patch node - a natural spot is right after Uncond Zero, since the author's own suggested use is stress-testing that node's scale value without burning a full render every time you push it too far. It watches for invalid values during sampling and reacts based on the replace_values toggle.
The inputs and outputs that matter
model(MODEL) in,model(MODEL) out.replace_values(default true) - this is the one to actually read, because the default behavior isn't what the node's name implies. With it on, the node doesn't interrupt anything - it quietly replaces the invalid values with 0 and lets sampling continue. Flip it off if you want the node to actually do what its name says: cancel the sampling run the moment it detects a NaN, rather than papering over it.
How to install it
Via ComfyUI Manager: search Uncond-Zero-for-ComfyUI, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/Extraltodeus/Uncond-Zero-for-ComfyUI
then restart. No models to fetch, nothing heavy - it's a lightweight patch, same install as the rest of the pack.
Common issues & troubleshooting
"It's not interrupting anything." Check replace_values first - at its default of true, the node is designed to zero-out and continue, not stop. That's a reasonable default if you'd rather get a result than nothing, but it means you won't see a hard cancel unless you turn it off.
You're still getting black frames with this node installed. If replace_values is on, a NaN gets replaced with 0 rather than propagated - but if the underlying cause is producing NaNs on every step (not a one-off), zeroing values out step after step can still degrade the output badly, even if it's not a flat black frame anymore. That points at a root cause worth fixing rather than papering over: check for a pre-Turing GPU running fp16, or a stale xformers install, before assuming this node alone will fix it.
Is this bug still around? The author's own note in the README is that they hadn't seen the random-TensorRT-black-image bug "since the latest updates" as of writing. Treat this node less as "a bug you need" and more as cheap insurance - especially useful while you're deliberately pushing Uncond Zero's scale into territory you haven't tested yet.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| replace_values | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |