Nodes/ComfyUI-HunyuanVideo-Foley/Hunyuan-Foley BlockSwap Settings
ComfyUI Node

Hunyuan-Foley BlockSwap Settings

Running a foley model on a GPU that has no business hosting it

By phazei·Created 12 months ago·Updated 3 months ago· 113
Hunyuan-Foley BlockSwap Settings
    • block_swap_args
    blocks_to_swap30
    use_non_blockingfalse
    prefetch_blocks1
    block_swap_debugfalse

    Hunyuan-Foley BlockSwap Settings is the pack's party trick, and it deserves the billing: it's what lets the whole foley stack run in under 4GB of VRAM. That's the difference between "this workflow is a 24GB-card thing" and "I can run it on the same laptop that does my SD 1.5." The trade is speed, and you should know the shape of it before you get excited.

    The mechanism is the same block-swap idea that Wan users know from low-VRAM video work: the diffusion transformer is a stack of blocks, and instead of keeping all of them on the GPU, you pin the heavy ones to CPU RAM and move them across to the GPU one at a time as the forward pass needs them. During denoising, block 5 is computing on the GPU while blocks 6 and 7 are already queued. It's memory-for-time, plain and simple - the README says a 5s clip can take up to 60 seconds under heavy swap, versus roughly 20 on a 3090 with room to spare. It fits, and then it's slow. That's the deal.

    This node is a pure settings node: it bundles its inputs into a BLOCKSWAPARGS object that you feed into the sampler's block_swap_args port. The sampler applies it right before denoising, so leaving the port empty just means "no block swap."

    The inputs:

    • blocks_to_swap (default 30, max 57) - the one that matters. The model has two variants: XXL with 54 swappable blocks (18 triple-stream + 36 single-stream) and the smaller XL with 36 (12 + 24). The default of 30 already puts a big chunk of the model on CPU. Start there, and if you still OOM, crank it up. The more you swap, the more RAM you need and the slower it gets.
    • prefetch_blocks (default 1, max 10) - how many blocks to stage on the GPU ahead of time to hide transfer latency. More prefetch = faster but more VRAM. If you're right at the edge, drop it to 0.
    • use_non_blocking (default off) - non-blocking memory transfers. Can be faster, but the tooltip warns it reserves more RAM. Only touch this if prefetch tuning isn't enough.
    • block_swap_debug - logging for performance. Turn it on once if you're curious what's being swapped; otherwise leave it.

    The honest advice

    If your card has 8GB or more, you probably don't need this node - the fp8 model gets you under 8GB on its own, and block swap will only slow you down. Its reason to exist is the sub-4GB crowd and people who want to share VRAM with other things. Also keep in mind that swapping needs system RAM to hold the blocks - the pack author's own recipe for the low-VRAM path assumes you've got the RAM headroom to back it. And note that it plays fine with torch.compile: the pack compiles individual blocks rather than the whole model specifically so the two can coexist.

    Install is the pack install (ComfyUI Manager, search ComfyUI-HunyuanVideo-Foley, or git clone https://github.com/phazei/ComfyUI-HunyuanVideo-Foley into custom_nodes, then restart). The example workflow in example_workflows/ shows it wired in, including on the same graph as the Torch Compile node. If your first run with block swap feels glacial, that's not a bug - that's what buying back 14GB of VRAM costs.

    Categoryaudio/HunyuanFoley

    Inputs (4)

    NameTypeDefaultDescription
    blocks_to_swapINT300–57Number of transformer blocks to offload to CPU. XXL has 54 blocks (18 triple + 36 single), XL has 36 (12 triple + 24 single).
    use_non_blockingoptBOOLEANfalseUse non-blocking memory transfer for offloading. Can be faster but reserves more RAM.
    prefetch_blocksoptINT10–10Number of blocks to prefetch to GPU ahead of time. Hides data transfer latency.
    block_swap_debugoptBOOLEANfalseEnable debug logging for block swapping performance.

    Outputs (1)

    NameTypeDescription
    block_swap_argsBLOCKSWAPARGS