ComfyUI Node

FluxBlockSwap

Trade VRAM for speed when TaylorSeer's cache won't fit

By philipy1219·Created about a year ago·Updated 7 months ago· 60
FluxBlockSwap
    • block_swap_args
    double_block_swap0
    single_block_swap0

    TaylorSeer's standard cache is a hungry guest: on Flux fp8 at 1024² it wants an extra 2–6GB of VRAM depending on max_order. If your card is already hosting the full Flux stack, that's the difference between rendering and not. FluxBlockSwap is the release valve - a tiny config node that tells TaylorSeer to park some of Flux's transformer blocks on the CPU so the cache fits.

    The catch, and it's an honest one: you're buying VRAM with wall-clock time. Offloaded blocks have to shuffle between CPU and GPU, so you don't get the full speedup while blockswap is active. It's a knob for fitting, not for speed.

    How it works

    Flux's backbone is a DiT with 19 double-stream blocks (the joint text+image attention ones) and 38 single-stream blocks. FluxBlockSwap's two integers say "offload the first N of each to CPU":

    • double_block_swap (0–19) - leading double blocks parked off-GPU
    • single_block_swap (0–38) - leading single blocks parked off-GPU

    You'll see the freed amount printed as total_offload_memory: xxx MB in the console when the run starts. When sampling finishes, the blocks are moved back to the GPU automatically, so the next workflow isn't slowed down.

    Important: the node doesn't offload anything itself. It just emits a block_swap_args output that you wire into TaylorSeer (or TaylorSeerLite) as its optional block_swap_args input. A blockswap node alone in your graph does nothing - it's a settings carrier. The actual moving happens inside the TaylorSeer wrapper when it initializes its cache.

    What to set

    Start small - swap 2–4 double blocks and see if you fit. Maxing out every block gets you maximum VRAM relief but turns the run into a CPU-shuffle, which defeats the whole point of a 2x speedup node. If you need to offload more than a handful of blocks to run Flux at all, step back and ask whether the standard TaylorSeer is the right tool - TaylorSeerLite costs almost no VRAM at all and skips this whole trade.

    Install

    Same pack, same no-dependency story:

    cd ComfyUI/custom_nodes
    git clone https://github.com/philipy1219/ComfyUI-TaylorSeer
    

    Restart ComfyUI (or install via Manager, searching "ComfyUI-TaylorSeer"). No model files, no pip installs. Same version caveat as the rest of the pack: keep ComfyUI newer than commit c496e53, because this hooks into Flux internals that change between releases.

    Troubleshooting

    • Blockswap node connected but nothing offloads - check that block_swap_args actually feeds the TaylorSeer/TaylorSeerLite node. It's an optional input; it's easy to leave unplugged.
    • Still out of VRAM - you're likely overcommitting on max_order too. Order 0 cache + a couple of swapped blocks beats order 2 + everything swapped.
    • Notably slower than before - you've over-swapped. Dial the numbers back toward 0 until speed returns; you only want as much offload as it takes to fit.
    CategoryTaylorSeer

    Inputs (2)

    NameTypeDefaultDescription
    double_block_swapINT00–19Double block swap.
    single_block_swapINT00–38Single block swap.

    Outputs (1)

    NameTypeDescription
    block_swap_argsBLOCKSWAPARGS