Nodes/RES4LYF/ClownpileModelWanVideo
ComfyUI Node Runs on cloud

ClownpileModelWanVideo

Torch.compile speedups for Wan video

By ClownsharkBatwing·Created 2 years ago·Updated 18 days ago· 1,222
ClownpileModelWanVideo
  • model
  • MODEL
backendinductor
fullgraphfalse
modedefault
dynamicfalse
dynamo_cache_size_limit64
skip_self_attn_blocks0,1,2,3,4,5,6,7,8,9,
compile_transformer_blockstrue
force_recompilefalse

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 (default default) - the compile aggressiveness. default is the safe balance; max-autotune searches harder for fast kernels (longer compile, potentially faster runtime); reduce-overhead targets per-call overhead. Start with default.
  • backend (default inductor) - the compiler backend. inductor is the standard PyTorch one and the right pick for almost everyone; cudagraphs is the alternative.
  • compile_transformer_blocks (default true) - 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 (default false) - 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.

CategoryRES4LYF/model

Inputs (9)

NameTypeDefaultDescription
modelMODEL
backendCOMBOinductor2 options: inductor, cudagraphs
fullgraphBOOLEANfalseEnable full graph mode
modeCOMBOdefault4 options: default, max-autotune, max-autotune-no-cudagraphs, reduce-overhead
dynamicBOOLEANfalseEnable dynamic mode
dynamo_cache_size_limitINT640–1024torch._dynamo.config.cache_size_limit
skip_self_attn_blocksSTRING0,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_blocksBOOLEANtrueCompile all transformer blocks
force_recompileBOOLEANfalseForce recompile.

Outputs (1)

NameTypeDescription
MODELMODEL