KJNodes/torchcompilegenerated

TorchCompileControlNet

This node internally uses torch。

Torch Compile Control Net

controlnet
CONTROL_NET
backend
COMBO
fullgraph
mode
default
KJNodes

TorchCompileControlNet node, which internally uses torch.compile.

TorchCompileControlNet is a utility node designed to optimize the inference performance of ControlNet models. It leverages PyTorch's just-in-time compilation technology to convert ControlNet models into a more efficient execution format, aiming to improve the processing speed of image generation workflows.

Node Functionality

This node internally uses the torch.compile function to compile the input ControlNet model. It allows users to select different compilation backends (such as inductor or cudagraphs) and optimization modes (such as max-autotune), and supports enabling full graph mode for more aggressive optimization. The compilation process is one-time, and the node internally tracks the compilation state to avoid redundant operations.

Node Parameter Description - TorchCompileControlNet

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
controlnetCONTROL_NETYes--: Input the ControlNet model to be compiled and optimized.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
backendCOMBOYesinductor"inductor", "cudagraphs": Select the backend engine used for PyTorch compilation. Options are inductor or cudagraphs.
modeCOMBOYesdefault"default", "max-autotune", "max-autotune-no-cud...: Select the compilation optimization mode. Options are default, max-autotune, max-autotune-no-cudagraphs, or reduce-overhead.
fullgraphBOOLEANYesFalse-Enable full graph mode

Output

Parameter NameData TypeDescription
CONTROL_NETCONTROL_NET: Outputs the compiled and optimized ControlNet model.

Usage Scenarios

In workflows requiring rapid iteration or batch image generation, you can connect this node after the ControlNet loader and before the sampler. By compiling the ControlNet, you can significantly reduce the time consumed per sampling or multiple samplings while maintaining generation quality. This is particularly suitable for real-time applications or large-scale content creation scenarios that have requirements for generation speed.

Notes

This node is marked as an experimental feature. Its compilation effectiveness and stability may vary depending on the PyTorch version, hardware drivers, and specific models. If compilation fails, the node will throw a runtime error. You need to check environment compatibility or try different compilation parameter combinations.

The TorchCompileControlNet node is from the ComfyUI-KJNodes node package.

Comments

Sign in with GitHub to join the discussion.

Loading comments…