Nodes/ComfyUI-productfix/Reset injected model patcher (middlek)
ComfyUI Node

Reset injected model patcher (middlek)

The fire-extinguisher node for a specific, well-known ComfyUI conflict

By MiddleKD·Created 2 years ago·Updated about a year ago· 21
Reset injected model patcher (middlek)
  • model
  • MODEL

Some ComfyUI nodes are features; some are janitors. ResetModelPatcherCalculateWeight is a janitor, and it exists because custom nodes spend a lot of effort stabbing each other in the back.

The problem it solves

Stable Diffusion models in ComfyUI are wrapped in a ModelPatcher, and one of its methods - calculate_weight - is a favorite injection point for other packs. LoRA-style merging, attention patching, and weights-offset tricks all hook it. The catch: some packs (the author names ComfyUI-Easy-Use as the example) get confused and throw errors when another node has already replaced calculate_weight. So you end up with a graph that's mathematically fine and operationally broken - a conflict between two packs neither of which is at fault.

This node restores the patcher's calculate_weight back to ComfyUI's original implementation. One input, one output, zero opinion.

How it works

It checks whether the model carries an original_calculate_weight attribute - the marker that says someone saved off the pristine method before injecting theirs. If it's there, the node restores both the instance method and the class-level ModelPatcher.calculate_weight to the originals. If there's nothing to restore, it returns the model untouched. So it's safe to drop into any graph; it only does work when there's actually something to undo.

The inputs and output

  • model - any MODEL.
  • Returns the same MODEL, cleaned up.

In the pack's shipped workflow it sits just upstream of the KSampler, resetting the patcher right before sampling runs - a belt-and-suspenders placement so the sampler sees a pristine calculate_weight no matter what Easy-Use or Impact Pack did earlier in the graph.

Install

Comes with the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/MiddleKD/ComfyUI-productfix
pip install -r requirements.txt

Restart, and it's under the productfix category. It needs no models and no extra dependencies beyond what the pack installs.

When to use it

If you're getting cryptic calculate_weight errors - the kind that mention a "missing key" or a patched method failing on a checkpoint load - and your graph mixes Easy-Use, Impact Pack, or similar patching nodes, drop this in front of the sampler. If nothing is wrong, it's a harmless passthrough.

Two honest caveats. First, it's a blunt instrument: it resets the entire patcher's weight calculation, so if some other node's legitimate hook was also sitting in calculate_weight, that hook gets reset too. Second, this whole pack is a tiny, single-developer project with almost no community footprint, so when the error isn't this specific conflict, don't expect the README to save you. But for the one job it names, it does exactly what it says.

Categoryproductfix

Inputs (1)

NameTypeDefaultDescription
modelMODEL

Outputs (1)

NameTypeDescription
MODELMODEL