KJNodes/torchcompilegenerated

TorchCompileModelFluxAdvancedV2

In terms of technical implementation, this node clones the input model and applies torch。

Torch Compile Model Flux Advanced V2

model
MODEL
backend
COMBO
fullgraph
mode
default
double_blocks
single_blocks
dynamic
dynamo_cache_size_limit
64
force_parameter_static_shapes
KJNodes

The TorchCompileModelFluxAdvancedV2 node is deprecated – use TorchCompileModelAdvanced instead. In its technical implementation, it clones the input model and applies torch.compile to its internal diffusion model part.

TorchCompileModelFluxAdvancedV2 is a node used for optimizing and accelerating model inference. It compiles the given diffusion model using PyTorch's torch.compile functionality, aiming to improve the model's runtime efficiency during image generation. This node provides various compilation options, allowing users to adjust optimization strategies based on hardware and requirements.

Node Functionality

In its technical implementation, this node clones the input model and applies torch.compile to its internal diffusion model part. It supports multiple backends (e.g., inductor) and compilation modes (e.g., max-autotune), and allows control over whether to compile specific modules within the model (such as single/double attention blocks). Furthermore, it can configure underlying parameters like PyTorch Dynamo's cache size and shape forcing staticization for more granular performance tuning.

Node Parameter Description - TorchCompileModelFluxAdvancedV2

Connection Inputs (Inputs)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
modelMODELYes--Receives the model input to be optimized. This parameter is the core input of the node, typically coming from an upstream model loading node.

Control Parameters (Parameters)

Parameter NameData TypeRequiredDefault ValueValue Range/OptionsDescription
backendCOMBOYesinductor"inductor", "cudagraphs"Selects the backend engine used for PyTorch compilation. Options are inductor (default) or cudagraphs, specifying the underlying optimization implementation.
modeCOMBOYes"default""default", "max-autotune", "max-autotune-no-cudagraphs", "reduce-overhead"max-autotune, max-autotune-no-cudagraphs, and reduce-overhead, used to trade off between compilation time, memory usage, and runtime speed.
fullgraphBOOLEANYesFalse-Enable full graph mode
double_blocksBOOLEANYesTrue-Compile double blocks
single_blocksBOOLEANYesTrue-Compile single blocks
dynamicBOOLEANYesFalse-Enable dynamic mode
dynamo_cache_size_limitINTNo640 - 1024 (step: 1)torch._dynamo.config.cache_size_limit
force_parameter_static_shapesBOOLEANNoTrue-torch._dynamo.config.force_parameter_static_shapes

Output

Parameter NameData TypeDescription
MODELMODELOutputs the model optimized by torch.compile, ready for use by subsequent sampling or processing nodes.

Usage Scenarios

In an image generation workflow, you can place this node after the model loading node and before the sampler node. For example, after loading a Stable Diffusion model, compile and optimize it using this node, then feed the optimized model into the sampler for image generation, aiming for faster generation speeds.

Notes

Please note that this node has been marked as "deprecated," and the developer recommends using its replacement node, TorchCompileModelAdvanced. It is still in an experimental stage, and its optimization effectiveness may vary significantly depending on the model, hardware, and specific parameters.

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

Comments

Sign in with GitHub to join the discussion.

Loading comments…