Nodes/KJNodes for ComfyUI/Model Patch Torch Settings
ComfyUI Node Runs on cloud

Model Patch Torch Settings

The fp16-accumulation toggle with a bad name

By kijai·Created 3 years ago·Updated a day ago· 2,908
Model Patch Torch Settings
  • model
  • MODEL
enable_fp16_accumulationfalse

The name is doing this node no favors - a 0.31% click rate on 322 impressions says people scroll right past it. But if you've ever launched ComfyUI with the --fast flag for the speed boost, then had to remove it and restart because you switched to a model that doesn't support fp16 accumulation, this is the node you actually wanted. Someone on r/comfyui asked exactly that - "is there a way to disable the --fast aka fp16 accumulation with a node?" - and the answer was: "Yes. KJNodes has a node named 'Model Patch Torch Settings.' Not a great name on that node... having FP16 in the node name would make it easier to find." That's the whole story in one exchange.

What it does

--fast in ComfyUI flips torch's allow_fp16_accumulation on, which is a meaningful, free-ish speedup on models that tolerate it. The problem is it's a global launch flag: on for everything or off for everything, and changing it means restarting Comfy. This node makes it a per-model setting instead. Its description: "Adds callbacks to model to set torch settings before and after running the model." So it flips the torch setting right before your model runs and puts it back after - scoped to this model, no restart, no leaking the setting into your next generation.

Why you'd want it scoped: fp16 accumulation helps a lot of models and breaks a few. Qwen is the usual example that doesn't support it. With a global flag you're stuck picking one behavior for your whole session; with this node you enable it on the Flux graph and leave it off on the Qwen graph, in the same running instance.

Inputs and outputs

Dead simple. Model in, patched MODEL out, with one toggle:

  • enable_fp16_accumulation (default off) - on flips the setting for this model's run, off leaves it stock.

That's the entire node. Wire it into your model chain before the sampler.

Where it fits versus the loader

If you're using DiffusionModelLoaderKJ, that loader already has an enable_fp16_accumulation checkbox and you don't need this node too. ModelPatchTorchSettings is the standalone version for when you're loading your model with the stock loader (or any other loader) and just want to bolt the toggle on afterward. Same effect, different placement.

Installing it

Ships in kijai's KJNodes pack.

  • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r requirements.txt, and restart.

Nothing to download; it patches the model you pass in.

Common issues

The biggest "issue" is just finding it - search your node menu for "Torch Settings," not "fp16," because the name buries the thing it does. Beyond that: it only helps if fp16 accumulation actually applies to your setup. On models that don't support it, flipping it on does nothing useful and can hurt output quality, so if a generation looks off right after you added this node, turn the toggle back off. And it's a speed lever, not a quality one - nobody's output gets better from fp16 accumulation, it just runs faster on the models that can take it. Note the node lives in the experimental category, which is kijai's way of saying "handy, but I reserve the right to change it."

CategoryKJNodes/experimental

Inputs (2)

NameTypeDefaultDescription
modelMODEL
enable_fp16_accumulationBOOLEANfalseEnable torch.backends.cuda.matmul.allow_fp16_accumulation, requires pytorch 2.7.0 nightly.

Outputs (1)

NameTypeDescription
MODELMODEL