KJNodes/torchcompilegenerated

TorchCompileModelWanVideoV2

This node technically utilizes PyTorch's torch。

Torch Compile Model Wan Video V2

model
MODEL
backend
inductor
fullgraph
mode
default
dynamic
compile_transformer_blocks_only
dynamo_cache_size_limit
64
force_parameter_static_shapes
KJNodes

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 NameData TypeRequiredDefault ValueRange/OptionsDescription
modelMODELYes--Receives the original model input to be optimized, of type MODEL. This is the object the node compiles and processes.

Parameters

Parameter NameData TypeRequiredDefault ValueRange/OptionsDescription
backendCOMBOYesinductor"inductor", "cudagraphs"Selects the backend engine used for PyTorch compilation. Options are "inductor" or "cudagraphs", corresponding to different underlying optimization strategies.
modeCOMBOYesdefault"default", "max-autotune", "max-autotune-no-cudagraphs", "reduce-overhead"Used to trade off between compilation speed, memory usage, and runtime performance.
fullgraphBOOLEANYesFalse-Enable full graph mode
dynamicBOOLEANYesFalse-Enable dynamic mode
compile_transformer_blocks_onlyBOOLEANYesTrue-Compile only transformer blocks, faster compile and less error prone
dynamo_cache_size_limitINTYes640 - 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 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.

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

Comments

Sign in with GitHub to join the discussion.

Loading comments…