Nodes/ComfyUI-HunyuanVideo-Foley/Hunyuan-Foley Torch Compile
ComfyUI Node

Hunyuan-Foley Torch Compile

A ~30% speedup you have to wait two minutes to get

By phazei·Created 12 months ago·Updated 3 months ago· 113
Hunyuan-Foley Torch Compile
    • TORCH_COMPILE_CFG
    backendinductor
    fullgraphfalse
    modedefault
    dynamicfalse
    dynamo_cache_limit64

    This node exists to make the slow part of HunyuanVideo-Foley less slow, and the honest pitch is in the author's own node description: "If you change anything like duration, or batch, it'll compile again and takes about 2 minutes on a 3090. Saves about 30% of the time."

    So: ~30% faster repeat runs, paid for with a ~2-minute compile on the first run - and again every time you change something that reshapes the graph, like duration or batch size. If you're generating a few variations and moving on, that compile tax is real. If you're in a loop churning out the same-length clips with different prompts and seeds, it pays for itself fast. It's the classic torch.compile trade, wrapped in a ComfyUI-friendly config object.

    It's a pure settings node: no model loading, no heavy lifting. It just bundles a handful of knobs into a TORCH_COMPILE_CFG output that you feed into the sampler's torch_compile_cfg port. The sampler applies it lazily, right before denoising, and the node compiles the transformer blocks (the triple-stream and single-stream blocks) rather than the whole model - that's deliberate, and it's why block swap can still work on top of it.

    The inputs you'll actually touch:

    • backend - only inductor is offered. Not a real choice; don't hunt for options that aren't there.
    • mode - default, reduce-overhead, or max-autotune. The middle one shaves overhead at the cost of a little more memory; max-autotune hunts harder for the best kernels and costs the most compile time. The default is fine for almost everyone.
    • dynamic - true/false/None. The author's tooltip says it best: "Allow shape dynamism; safer when duration/batch vary." If you know your shapes are stable, false compiles tighter. If you keep changing duration, true avoids recompiles at the price of slower code.
    • fullgraph - keep it off, per the tooltip ("stricter; usually keep off"). There's nothing here you want to debug.
    • dynamo_cache_limit - a cap on torch's graph cache to stop shape variants from exploding into thousands of compiled graphs. The default 64 is fine; you'll know if you need to touch it.

    The gotchas

    Two, and both are pack-specific. First: the compile progress bar appears in the console, and it's per-signature - if you see it re-appear partway through a run, a new input shape triggered a new compile. That's expected, not a hang.

    Second, and this is the one that'll burn you: on a 3090 or lower, torch compile only works with the fp8_e5m2 model file. The README is explicit about it. If you're on a 30-series card, load the e5m2 safetensor in the Model Loader and set quantization to match - otherwise this node's compile step can fail or produce garbage, and the sampler will silently fall back to the eager model.

    Install is just the pack install (ComfyUI Manager or git clone https://github.com/phazei/ComfyUI-HunyuanVideo-Foley into custom_nodes). It needs PyTorch 2.7+ - torch.compile isn't available in older builds, and the node checks for it. One more thing to remember: compiled graphs eat system RAM while they're live, so if you're running this and block swap on a small machine, keep an eye on memory, not just VRAM.

    Categoryaudio/HunyuanFoley

    Inputs (5)

    NameTypeDefaultDescription
    backendCOMBOinductor1 options: inductor
    fullgraphBOOLEANfalseCapture entire graph (stricter); usually keep off
    modeCOMBOdefault3 options: default, reduce-overhead, max-autotune
    dynamicCOMBOfalseAllow shape dynamism; safer when duration/batch vary
    dynamo_cache_limitINT6464–8192TorchDynamo graph cache size to limit graph explosion

    Outputs (1)

    NameTypeDescription
    TORCH_COMPILE_CFGTORCH_COMPILE_CFG