HunyuanVideo Torch Compile Settings
Squeeze more speed out of the transformer
- torch_compile_args
torch.compile traces your model's computation graph and generates optimized kernels for it, instead of running PyTorch's normal eager-mode Python loop. On a model as heavy as HunyuanVideo, that can be a real speedup - but it's not free, and this node is purely a settings bundle: it doesn't do anything by itself. Connect its output to compile_args on HyVideoModelLoader (or HyVideoVAELoader, which also accepts compile args) and that's what actually triggers compilation.
The node's own description is the most important line in this whole article: it requires Triton, and torch 2.5.0 is recommended. If you don't have Triton installed, skip this node entirely rather than fight with it.
The inputs that matter
backend-inductor(default, the standard PyTorch compiler backend) orcudagraphs, a lighter-weight alternative that captures and replays GPU operation sequences.mode-default,max-autotune,max-autotune-no-cudagraphs, orreduce-overhead.max-autotunesearches harder for the fastest kernel configuration at the cost of a much longer first-run compile;defaultis the sane starting point.fullgraph- forces the whole model to compile as one graph rather than falling back to eager mode wherever compilation hits something it can't trace. Stricter, and more likely to just fail outright on an unsupported op rather than silently degrade.dynamic- lets the compiled graph handle varying input shapes (different resolutions or frame counts) without recompiling each time. Leave off if you always run the same width/height/frame count and want the tightest optimization.dynamo_cache_size_limit(default 64) - how many distinct compiled graph variants PyTorch will cache before falling back. Relevant mainly if you're varying shapes a lot.compile_single_blocks/compile_double_blocks(both default on) - compile the transformer's main block stacks, where the bulk of compute happens.compile_txt_in/compile_vector_in/compile_final_layer(all default off) - the smaller peripheral layers. Left off by default because they're a small fraction of total compute; the compile overhead usually isn't worth it for them.
Output: torch_compile_args.
How to install it
Ships with the pack - no separate download. ComfyUI Manager: search ComfyUI-HunyuanVideoWrapper, install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-HunyuanVideoWrapper
pip install -r ComfyUI-HunyuanVideoWrapper/requirements.txt
then restart. Triton is the extra piece this node needs beyond the pack itself - it's a separate install (pip install triton on Linux; noticeably more friction on Windows), and it's the same dependency the wrapper's sageattn attention mode needs.
Common issues & troubleshooting
Errors mentioning Triton, or the compile step just fails. Triton isn't installed, or isn't a version that plays well with your torch install. This is a well-known rite of passage across the ComfyUI ecosystem, and it's worse on Windows than Linux. If you don't want to deal with it, don't use this node - the wrapper runs fine without compilation, just slower.
First generation after connecting this node is much slower than normal, then later ones are fast. That's compilation happening - it's a one-time (per shape) cost, not a per-run cost. Don't judge the speedup from your first generation.
Changed resolution or frame count and it recompiled from scratch. Expected unless dynamic is enabled - each distinct input shape triggers its own compile pass. If you're iterating across different sizes, either turn dynamic on (some speed cost) or accept the recompile tax each time you change shape.
It compiled fine but you don't see much speedup. Try max-autotune for a more aggressive search, and make sure compile_single_blocks/compile_double_blocks are both on - those are where most of the model's compute lives.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| backend | COMBO | inductor | 2 options: inductor, cudagraphs |
| fullgraph | BOOLEAN | false | Enable full graph mode |
| mode | COMBO | default | 4 options: default, max-autotune, max-autotune-no-cudagraphs, reduce-overhead |
| dynamic | BOOLEAN | false | Enable dynamic mode |
| dynamo_cache_size_limit | INT | 640–1024 | torch._dynamo.config.cache_size_limit |
| compile_single_blocks | BOOLEAN | true | Compile single blocks |
| compile_double_blocks | BOOLEAN | true | Compile double blocks |
| compile_txt_in | BOOLEAN | false | Compile txt_in layers |
| compile_vector_in | BOOLEAN | false | Compile vector_in layers |
| compile_final_layer | BOOLEAN | false | Compile final layer |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| torch_compile_args | COMPILEARGS | — |