Nodes/XB_ToolBox/XB-BOX - Sage + BlockSwap (Golden Duo)
ComfyUI Node

XB-BOX - Sage + BlockSwap (Golden Duo)

The 'golden duo' that runs big models on small cards

By wjluoxiao·Created 5 months ago·Updated 6 days ago· 302
XB-BOX - Sage + BlockSwap (Golden Duo)
  • model
  • model
sage_preset关闭
blocks_to_swap10

The pack calls this one the "Golden Duo," and the marketing is doing a real job of hiding how simple and useful it is. XB_Sage_BlockSwap takes two of the pack's VRAM tricks and fuses them into one node: SageAttention (make the attention math faster) plus block swapping (push the first N transformer blocks off the GPU into system RAM, so the model actually fits). One node in, one patched model out. That's the whole thing.

Why would you want both at once? Because on a consumer card they solve opposite halves of the same problem. Sage gives you back speed; block swap gives you back memory by trading speed for space. Combined, a 14B–22B video model that would hard-OOM on a mid-range GPU becomes runnable - slower than native, but runnable, which is the entire genre of "extreme VRAM optimization" this pack exists for.

Inputs

  • model - a MODEL from any loader (UNet, DiT, or checkpoint). It accepts the checkpoint-level model too, unlike the pure-UNet XB_UNetBlockSwap.
  • sage_preset - the same 11-option preset ladder as XB_SageAttentionAccelerator. 关闭 (off) means "block swap only, no attention patch" - important: the pack's tooltip spells this out, so off isn't "node disabled," it's "skip the Sage half."
  • blocks_to_swap - how many core blocks to offload to system RAM. 0 = block swap off. The tooltip is the honest contract: more blocks = less VRAM, but slower. Start at 10 and nudge up only if you still OOM.

Output is the patched model - same type in, wire it to your sampler.

How it actually works

The node clones your model and registers a callback that fires when ComfyUI loads it onto the GPU. At load time it finds the model's block list (it hunts across transformer_blocks, double_blocks, single_blocks, down_blocks, and friends), then physically moves the first blocks_to_swap blocks to the offload device while the rest go to VRAM. Every sampling step, ComfyUI's normal on-demand loading drags a block back in when it's needed. It's the same principle as --lowvram, but surgical: only the blocks you chose are evicted.

The traps worth knowing

  • Model blacklist. The source carries a hard blocklist - Lumina, ZImage, HunyuanDiT, ErnieImage - that it refuses to physically swap, because their architectures break under module.to() moves. It logs a message and skips; you'll see a slowdown-free, no-op pass.
  • --enable-dynamic-vram sleeps it. If you launch ComfyUI with dynamic VRAM enabled, this node detects it and goes inert. Not a bug - you don't want two offloaders fighting.
  • The Sage half needs pip install sageattention. If it's missing or fails on ROCm, the node's graceful fallback means block swap still runs; you just don't get the attention speedup. On RDNA3, built-in presets fall back to SDPA.

Install the pack (Manager → XB_ToolBox, or git clone https://github.com/wjluoxiao/XB_ToolBox.git), restart, look under "XB_ToolBox/VRAM_Hacks". For the actual node, no extra pip deps beyond sageattention for the speedup half.

CategoryXB_ToolBox/VRAM_Hacks

Inputs (3)

NameTypeDefaultDescription
modelMODEL输入模型(UNet / DiT / Checkpoint)
sage_presetCOMBO关闭SageAttention 加速模式。关闭=仅分块不加速。
blocks_to_swapINT100–200卸载到系统内存的核心模块数量。0=关闭分块,数值越大越省显存但越慢。

Outputs (1)

NameTypeDescription
modelMODEL