Omit Non Finite
Quietly delete the NaN weights so your merge doesn't fall apart
- a (delta|param|weight)
- recipe
Omit Non Finite (class Omit Non Finite Mecha Recipe) is a tiny cleanup node with a very specific job: for each tensor in the merge, if it contains a NaN or an infinity, that tensor gets skipped entirely. If it's finite, it passes through. One input, one output, no knobs that matter - and yet it's quietly one of the more useful nodes in the pack when things go wrong.
Model merging occasionally produces garbage at the tensor level. A merge method hits a division by a near-zero, a scale factor runs away, or you're blending a model that already had a poisoned weight baked in - and suddenly some of your merged tensors are NaN or inf. Samplers tend to react to that by producing black images, static, or silently degraded output. This node is the surgical response: instead of throwing away the whole merge, drop just the corrupt tensors.
How it works
At merge time, sd-mecha checks each tensor in the recipe against isfinite(). A clean tensor passes through. A tensor with any NaN or inf raises a "non-finite key" signal that the merge engine treats as skip this key - meaning the merged checkpoint simply won't include that tensor's output, and the merge proceeds with everything else. It's a per-key filter, not a whole-model abort.
The inputs that matter:
- a (delta|param|weight) (
MECHA_RECIPE, required) - the recipe to clean. Works in any merge space, so you can drop it anywhere in a chain. - recipe (output) - the input, with non-finite keys omitted. Same merge space as the input.
Where you actually want it: downstream of the aggressive math - after a Multiply Quotient that might produce degenerate ratios, after a Scale with extreme alphas, or after combining deltas where one contributor was corrupted. Slap an Omit Non Finite between the risky part of the graph and the final merge and you convert "merge collapses" into "merge survives, minus a few keys."
Install
This ships in the Mecha Merge Node Pack (ljleb/comfy-mecha):
- ComfyUI Manager → Install Custom Nodes → search "mecha" → Mecha Merge Node Pack, or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ljleb/comfy-mecha.git
pip install -r comfy-mecha/requirements.txt
Restart ComfyUI; the node is under mecha. The pack's only dependency is sd-mecha==1.1.7, and there are no model downloads.
Common issues
- Dropped keys mean missing tensors, not zeroed ones. The result just doesn't contain those keys. In practice that means the saved model falls back to defaults or to whatever the loader fills in - usually fine, occasionally surprising. If a merge is "missing" something after this node, that's the reason.
- It's a safety net, not a fix. If you regularly need Omit Non Finite, the merge method upstream is producing NaNs on purpose; you'd rather fix the alpha than sweep the result. But as a tripwire for the occasional bad run, it's perfect.
- Silent by design. Nothing warns you how many keys got dropped. If you want to know, run the same merge with and without the node and compare sizes - a few hundred KB lighter usually means a few tensors were culled.
This is the rare node that's genuinely better as an insurance policy than as a headline feature. Keep it on the shelf, wire it in the moment a merge starts producing black frames, and move on with your day.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| a (delta|param|weight) | MECHA_RECIPE | — | |
| merge_checkpointingopt | BOOLEAN | false | Speeds up an entire branch of a merge graph that does not change often in exchange of memory. - true: store the first output of this recipe node on cpu memory in fp16. On subsequent workflow executions, as long as the inputs do not change, the cached keys are returned after being cast to the original device and dtype. - false: do not store the output. The recipe and its inputs will re-execute on subsequent workflow executions. Note that the memory used to checkpoint the output is distinct from the cache feature. In general, you probably want to either use this *or* a cache unit, but not both at the same time because the memory adds up. The difference between merge checkpointing and cache is that merge checkpointing completely re-merges from scratch if any input changes. Merge checkpointing is also generally much faster than cache in the fast path. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| recipe | MECHA_RECIPE | — |