Nodes/ComfyUI-SeedVR2_VideoUpscaler/SeedVR2 Torch Compile Settings
ComfyUI Node

SeedVR2 Torch Compile Settings

Free speed, if you're doing enough volume to earn it

By numz·Created about a year ago·Updated 7 months ago· 2,707
SeedVR2 Torch Compile Settings
    • TORCH_COMPILE_ARGS
    backendinductor
    modedefault
    fullgraphfalse
    dynamicfalse
    dynamo_cache_size_limit64
    dynamo_recompile_limit128

    This is the optional node in the SeedVR2 lineup - the one you add when you've got the pipeline working and now want it faster. It hands PyTorch's torch.compile a set of options, and the payoff the pack advertises is real: roughly 20–40% off the DiT and 15–25% off the VAE. That's a meaningful chunk of your render time for zero quality cost. But there's a catch that decides whether this node is worth adding at all, so let's get it out of the way first.

    torch.compile has to warm up, and the warm-up is slow. The first run pays a compilation tax - PyTorch traces your model and builds optimised kernels - and that one-time cost can wipe out the entire speedup if you only process one image. The compiled version is faster on every subsequent run with the same shapes. So the honest rule is: this node earns its place on batch jobs, long videos, or a folder of frames you're grinding through. For a single upscale or a short clip, skip it. You'll spend more time compiling than you save. The lowest click-through of the four nodes probably reflects exactly this - people find it, realise it's the advanced-optional one, and move on. That's the correct instinct most of the time.

    How it works

    torch.compile takes the eager, op-by-op PyTorch execution and fuses it into optimised kernels ahead of time, cutting Python overhead and squeezing more out of the GPU. This node doesn't compile anything itself - it's a settings bundle. You configure it, and its output carries those settings to the model loaders, which do the actual compiling when they run.

    The inputs and outputs that matter

    Two dials do the real work:

    • backend (default inductor) - inductor is the full-fat option, generating fused Triton kernels; it's what you want. cudagraphs is a lighter wrapper that skips the kernel optimisation.
    • mode (default default) - the speed-vs-compile-time trade. default compiles fast and still helps, which is right for testing. max-autotune compiles slowest but runs fastest, which is what you switch to for a real production batch. There are two more (reduce-overhead, max-autotune-no-cudagraphs) for edge cases.

    The rest you can mostly leave alone:

    • fullgraph (default off) - keep it off. Off allows graph breaks for compatibility; on demands a single unbroken graph and tends to fail on dynamic shapes.
    • dynamic (default off) - turn this on if you're processing varying resolutions or batch sizes, so it doesn't recompile for every new shape. Leave off when everything's a fixed size.
    • dynamo_cache_size_limit (default 64) and dynamo_recompile_limit (default 128) - safety valves for how many compiled versions get cached and how many recompiles it'll attempt before falling back to eager mode. The defaults are fine unless you're doing something unusual.

    The single output is TORCH_COMPILE_ARGS. You wire it into the torch_compile_args input on the DiT model loader, the VAE loader, or both - whichever stages you want compiled.

    How to install it

    It comes with the SeedVR2 pack, so install the pack once. ComfyUI Manager: search ComfyUI-SeedVR2_VideoUpscaler, install, restart. Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/numz/ComfyUI-SeedVR2_VideoUpscaler
    

    install its requirements.txt with ComfyUI's Python, and restart.

    One extra requirement specific to this node: you need PyTorch 2.0+ and, for the inductor backend, Triton installed. Triton ships with most CUDA PyTorch builds on Linux and Windows; if it's missing, compilation will fall over.

    Common issues & troubleshooting

    The first run is painfully slow, then it's fine. Working as intended - that's the compilation tax. If it never seems to pay off, you're probably not running enough frames to amortise it. This node is for volume; on a one-off it's a net loss.

    Compilation errors or it silently drops back to eager mode. Usually Triton isn't installed, or you're on mode=max-autotune / fullgraph=True and hit a shape it can't handle. Start with mode=default, backend=inductor, fullgraph=False and confirm that works before reaching for the aggressive settings.

    It keeps recompiling and never gets faster. You're feeding it changing input shapes. Flip dynamic on so it builds shape-flexible kernels instead of a fresh compile per resolution - and if you're deliberately varying sizes, that's the setting that makes this node usable at all.

    CategorySEEDVR2

    Inputs (6)

    NameTypeDefaultDescription
    backendCOMBOinductorCompilation backend: • inductor: Full optimization with Triton kernel generation and fusion (recommended) • cudagraphs: Lightweight wrapper using CUDA graphs, no kernel optimization
    modeCOMBOdefaultOptimization level (compilation time vs runtime performance): • default: Fast compilation with good speedup (recommended for development) • reduce-overhead: Lower overhead, optimized for smaller models • max-autotune: Slowest compilation, best runtime performance (recommended for production) • max-autotune-no-cudagraphs: Like max-autotune but without CUDA graphs
    fullgraphBOOLEANfalseCompile entire model as single graph without breaks. • False: Allow graph breaks for better compatibility (default) • True: Enforce no breaks for maximum optimization (may fail with dynamic shapes)
    dynamicBOOLEANfalseHandle varying input shapes without recompilation. • False: Specialize for exact input shapes (default) • True: Create dynamic kernels that adapt to shape variations Enable when processing different resolutions or batch sizes.
    dynamo_cache_size_limitINT640–1024Maximum cached compiled versions per function (default: 64). Controls how many shape variations to compile before stopping. • Increase: When processing many different input shapes (more memory usage) • Decrease: When recompilation cost outweighs benefits (faster fallback to eager)
    dynamo_recompile_limitINT1280–1024Maximum recompilation attempts before fallback to eager mode (default: 128). Safety limit to prevent infinite compilation loops. Only increase if you see 'hit config.recompile_limit' warnings and have bounded shape variations.

    Outputs (1)

    NameTypeDescription
    TORCH_COMPILE_ARGSTORCH_COMPILE_ARGStorch.compile optimization settings including backend, mode, and Dynamo configuration. Connect to DiT and/or VAE model loader nodes.