TorchCompileModelFluxAdvancedV2
In terms of technical implementation, this node clones the input model and applies torch。
Torch Compile Model Flux Advanced V2
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 Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
model | MODEL | Yes | - | - | 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 Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
backend | COMBO | Yes | inductor | "inductor", "cudagraphs" | Selects the backend engine used for PyTorch compilation. Options are inductor (default) or cudagraphs, specifying the underlying optimization implementation. |
mode | COMBO | Yes | "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. |
fullgraph | BOOLEAN | Yes | False | - | Enable full graph mode |
double_blocks | BOOLEAN | Yes | True | - | Compile double blocks |
single_blocks | BOOLEAN | Yes | True | - | Compile single blocks |
dynamic | BOOLEAN | Yes | False | - | Enable dynamic mode |
dynamo_cache_size_limit | INT | No | 64 | 0 - 1024 (step: 1) | torch._dynamo.config.cache_size_limit |
force_parameter_static_shapes | BOOLEAN | No | True | - | torch._dynamo.config.force_parameter_static_shapes |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| MODEL | MODEL | Outputs 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.
TorchCompileModelFluxAdvancedV2 Node Source Code Link
The TorchCompileModelFluxAdvancedV2 node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.