ClownpileModelWanVideo
Torch.compile speedups for Wan video
- model
- MODEL
The name is a pun on "compile," and that's exactly what it does. It wraps your Wan video model in torch.compile, PyTorch's just-in-time compiler, which fuses the model's operations into optimized kernels so each sampling step runs faster. On long video generations - where you're paying for every frame across every step - a compile speedup is real time saved, not a rounding error. If you're generating Wan video and your GPU can support it, this is one of the cheaper wins available.
It sits in front of your sampler: model in, faster model out. Nothing about your prompts, samplers, or outputs changes - it's a pure performance wrapper. RES4LYF is heavily invested in Wan (temporal conditioning, regional prompting, long single-shot generations), so a Wan-specific compile node fits the pack's video ambitions.
How it works
torch.compile traces the model, then generates and caches specialized machine code for the shapes and operations it sees. The first run after you enable it is slower - that's the compilation happening - and subsequent runs at the same settings are faster because they reuse the cached kernels. This node exposes the knobs that control how aggressive that compilation is and which parts of the model get compiled. The output is a MODEL you wire onward exactly like the original.
The inputs that matter
model(MODEL) - your Wan model. The one required connection.mode(defaultdefault) - the compile aggressiveness.defaultis the safe balance;max-autotunesearches harder for fast kernels (longer compile, potentially faster runtime);reduce-overheadtargets per-call overhead. Start withdefault.backend(defaultinductor) - the compiler backend.inductoris the standard PyTorch one and the right pick for almost everyone;cudagraphsis the alternative.compile_transformer_blocks(defaulttrue) - compile the heavy transformer blocks, which is where the speedup lives. Leave it on.skip_self_attn_blocks(default a list of block indices) - lets you exclude specific blocks from compilation, an escape hatch for blocks that don't compile cleanly.force_recompile(defaultfalse) - throw away the cache and recompile. Useful after changing settings; costs you a fresh compile.
fullgraph, dynamic, and dynamo_cache_size_limit are lower-level controls best left at defaults unless you're chasing a specific compile error. Output is a single MODEL.
Installing RES4LYF
ComfyUI Manager: search RES4LYF, install, restart. Or clone:
cd ComfyUI/custom_nodes
git clone https://github.com/ClownsharkBatwing/RES4LYF
pip install -r RES4LYF/requirements.txt
Portable users: embedded pip under python_embedded/Scripts/. Restart, hard-refresh with F5. No model downloads from the pack itself.
Common issues
The first generation was slower, not faster. Expected - that's compilation. The payoff is on the next runs at the same resolution and settings. If you only ever do one-off single renders, compile overhead can outweigh the gain; this shines on repeated or long generations.
It recompiles every time / on every resolution change. torch.compile specializes on input shapes, so changing resolution or frame count triggers a recompile. Keep your dimensions stable across a batch to stay on the cached kernels, and raise dynamo_cache_size_limit only if you're deliberately juggling many shapes.
Compile errors, especially on Windows. torch.compile with the inductor backend needs Triton, which is far smoother on Linux than on Windows. If compilation fails outright, that toolchain is the first thing to check - and you can fall back by not compiling (skip this node) while you sort it out.
A specific block won't compile. That's what skip_self_attn_blocks is for - exclude the offending blocks and keep the rest of the speedup. If all else fails, force_recompile after a clean restart clears a stale cache.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| 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 |
| skip_self_attn_blocks | STRING | 0,1,2,3,4,5,6,7,8,9, | For WAN only: select self-attn blocks to disable. Due to the size of the self-attn masks, VRAM required to compile blocks using regional WAN is excessive. List any blocks selected in the ReWanPatcher node. |
| compile_transformer_blocks | BOOLEAN | true | Compile all transformer blocks |
| force_recompile | BOOLEAN | false | Force recompile. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |