Nodes/RES4LYF/TorchCompileModels
ComfyUI Node Runs on cloud

TorchCompileModels

The generic torch.compile node for whatever doesn't have a dedicated one

By ClownsharkBatwing·Created 2 years ago·Updated 21 days ago· 1,222
TorchCompileModels
  • model
  • model
backend
fullgraphfalse
modedefault
dynamicfalse
dynamo_cache_size_limit64
triton_max_block_x0

RES4LYF ships dedicated torch.compile nodes for AuraFlow, Flux, and SD3.5, each tuned to that architecture's own quirks. TorchCompileModels is the one without a model family in its name - reach for it on anything those three don't cover, or when you specifically want its one extra knob the others don't expose.

How it works

Same core mechanism as the pack's other compile nodes: it traces your model's forward pass once and compiles it into optimized kernels via PyTorch's torch.compile, trading a slower first run for faster ones after. Attach it right after your model loader and it hands back a patched MODEL your sampler treats exactly the same as the original.

The inputs and outputs that matter

  • model (MODEL) in, model out.
  • backend - inductor (default, most compatible across setups) or cudagraphs (potentially faster, more brittle with dynamic shapes).
  • mode (default default) - default, max-autotune (much longer compile, highest ceiling), max-autotune-no-cudagraphs, or reduce-overhead.
  • fullgraph (tooltip: "Enable full graph mode") - force a single compiled graph rather than allowing silent eager fallbacks.
  • dynamic (tooltip: "Enable dynamic mode") - tolerate changing shapes (resolution, batch size) without a full recompile.
  • dynamo_cache_size_limit (default 64) - how many compiled graph variants get cached before torch._dynamo bails to eager.
  • triton_max_block_x (default 0) - a raw Triton kernel-tuning knob, capping block size along one axis. Not present on the pack's other compile nodes. Leave it at 0 (Triton's own "let it decide" default) unless you're chasing a specific performance regression on unusually large tensors or resolutions and actually know what you're tuning for.

How to install it

Via ComfyUI Manager: search RES4LYF, install, restart.

Manually:

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

Portable installs: use the embedded Python's pip.exe. No extra downloads for torch.compile itself - it ships with PyTorch - but inductor depends on Triton, which is notoriously finicky to get working on Windows.

Common issues & troubleshooting

Slow first generation, faster ones after. That's the compile tax working as intended, not a bug - expect it to be worst on max-autotune and best repaid by a pipeline that reuses the same shape repeatedly.

Breaks or does nothing useful when paired with LoRAs or other model patches applied afterward. torch.compile assumes a stable graph; a patch that changes the model after compiling can conflict with that. Try backing off before this node if something else touching the model starts breaking once you add compilation.

Errors mentioning Triton on Windows. Common friction with inductor-backed compiling on that platform in general - try backend=cudagraphs if inductor is giving you trouble and you're on Windows.

Tuning triton_max_block_x and seeing no change or a regression. This is an advanced, situational knob - leave it at 0 unless you have a specific reason to touch it; it's not a general speed dial.

CategoryRES4LYF/model_patches

Inputs (7)

NameTypeDefaultDescription
modelMODEL
backendCOMBO2 options: inductor, cudagraphs
fullgraphBOOLEANfalseEnable full graph mode
modeCOMBOdefault4 options: default, max-autotune, max-autotune-no-cudagraphs, reduce-overhead
dynamicBOOLEANfalseEnable dynamic mode
dynamo_cache_size_limitINT640–1024torch._dynamo.config.cache_size_limit
triton_max_block_xINT00–4294967296

Outputs (1)

NameTypeDescription
modelMODEL