TorchCompileModelWanVideoV2
This node technically utilizes PyTorch's torch。
Torch Compile Model Wan Video V2
TorchCompileModelWanVideoV2
The TorchCompileModelWanVideoV2 node is a tool for optimizing model inference performance. It leverages PyTorch's compilation capabilities to convert models into a more efficient execution format, aiming to improve computational speed during image or video generation. This node is an experimental node under the KJNodes/torchcompile category.
Node Functionality
Technically, this node utilizes PyTorch's torch.compile mechanism, supporting various backend compilers and optimization modes. It allows users to select specific model components (such as compiling only Transformer blocks) for compilation to reduce compilation time and increase success rate. Internally, the node adjusts PyTorch Dynamo configurations, such as cache size limits and parameter shape handling, to adapt to different hardware and model architectures.
Node Parameter Description - TorchCompileModelWanVideoV2
Inputs
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
model | MODEL | Yes | - | - | Receives the original model input to be optimized, of type MODEL. This is the object the node compiles and processes. |
Parameters
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
backend | COMBO | Yes | inductor | "inductor", "cudagraphs" | Selects the backend engine used for PyTorch compilation. Options are "inductor" or "cudagraphs", corresponding to different underlying optimization strategies. |
mode | COMBO | Yes | default | "default", "max-autotune", "max-autotune-no-cudagraphs", "reduce-overhead" | Used to trade off between compilation speed, memory usage, and runtime performance. |
fullgraph | BOOLEAN | Yes | False | - | Enable full graph mode |
dynamic | BOOLEAN | Yes | False | - | Enable dynamic mode |
compile_transformer_blocks_only | BOOLEAN | Yes | True | - | Compile only transformer blocks, faster compile and less error prone |
dynamo_cache_size_limit | INT | Yes | 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 PyTorch compilation, which can be directly used in subsequent generation steps. |
Usage Scenarios
In video generation or high-resolution image generation workflows, when users identify model inference as a performance bottleneck, this node can be inserted after model loading and before the sampler. By compiling the model, subsequent diffusion sampling steps can be accelerated, thereby reducing overall generation time. This is particularly useful for scenarios requiring batch generation or real-time preview.
Notes
Please note that this node has been marked as "deprecated". The developer recommends using the more advanced TorchCompileModelAdvanced node instead. It is an experimental feature, and its behavior may vary depending on the PyTorch version or hardware environment. Thorough testing is recommended before use.
TorchCompileModelWanVideoV2 Node Source Code Link
The TorchCompileModelWanVideoV2 node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.