TorchCompileControlNet
Squeeze extra speed out of your ControlNet with torch.compile
- controlnet
- CONTROL_NET
This wraps a loaded ControlNet with PyTorch's torch.compile(), the same general acceleration lever the community already leans on for Wan and other video models - "JIT compilation: startup overhead, but a real per-frame speed improvement" once it's warmed up, in the community's own shorthand. This node applies exactly that idea to ControlNet specifically, instead of the diffusion model itself.
The trade is the same one it always is with torch.compile: the first run after compilation is slower, sometimes significantly, because PyTorch is generating and optimizing kernels for your exact shapes. Every run after that, on the same input shapes, gets the speedup. Change resolution, batch size, or ControlNet hint-image dimensions mid-session, and you pay the compile cost again. This is worth it if you're running many generations at a fixed resolution; it's actively counterproductive if you're constantly changing sizes between runs.
The inputs and outputs that matter
controlnetin,CONTROL_NETout - same type both ends, compiled.backend-inductor(PyTorch's general-purpose compiler, the one most people want) orcudagraphs(a lighter option that just captures CUDA graphs to cut launch overhead, without the deeper kernel fusioninductordoes).fullgraph(default off) - forces the entire compiled region into a single graph, erroring out on any "graph break" instead of silently falling back to eager execution for the part it couldn't capture. Stricter, and faster if it succeeds - but you'll actually see the failures instead of them being quietly absorbed.mode-default,reduce-overhead(uses CUDA graphs, good for smaller models where launch overhead dominates),max-autotune(spends real extra time at compile searching for the fastest kernel configuration - expect a genuinely long first run), ormax-autotune-no-cudagraphs(the same autotuning search, without CUDA graph capture, for cases where CUDA graphs cause problems).
How to install it
Standard KJNodes install: ComfyUI Manager → search "KJNodes for ComfyUI" → install, or cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt, then restart. Nothing extra to download for this node - it uses PyTorch's built-in compiler, which you already have.
Common issues & troubleshooting
The first generation after wiring this in feels stuck or hung. It isn't - that's compilation happening, and with max-autotune in particular, the first-run cost is real and can be substantial. Give it time before assuming something's broken; every subsequent run at the same shape will be fast.
Recompiling constantly and never actually getting faster. If your resolution or ControlNet hint size changes between runs, torch.compile recompiles from scratch every time - you're paying the warm-up cost repeatedly and never banking the payoff. Keep your working resolution stable within a session if you want this to actually help.
fullgraph: true throws errors it wasn't throwing before. That's the point of the setting - it refuses to silently fall back when it hits something it can't capture as one graph. If you're chasing maximum performance, that's useful information; if you just want it to work, leave fullgraph off and let it fall back quietly where it needs to.
Mysterious compile errors, especially on Windows. inductor's codegen leans on Triton under the hood, the same dependency that makes SageAttention notoriously painful to get working on Windows in this ecosystem (maintained essentially single-handedly by one community member's unofficial builds). If you're hitting inexplicable compile failures on Windows specifically, you're very likely running into the same underlying Windows-Triton fragility that shows up everywhere else torch.compile or Triton-based attention gets used - not a bug unique to this node.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| controlnet | CONTROL_NET | — | |
| backend | COMBO | 2 options: inductor, cudagraphs | |
| fullgraph | BOOLEAN | false | Enable full graph mode |
| mode | COMBO | default | 4 options: default, max-autotune, max-autotune-no-cudagraphs, reduce-overhead |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| CONTROL_NET | CONTROL_NET | — |