Universal Block Swap
Run bigger models than your VRAM deserves
- model
- model
You have an 8GB card and a 24GB model, and you want them to coexist. Block swap is the trick that makes it happen: instead of keeping every transformer block of a diffusion model in VRAM, you shove some blocks into system RAM and swap them through the GPU during the forward pass. Universal Block Swap is a node that applies that to "any DiT that fits the pattern" - no per-model patching required.
What it does
The node takes your loaded model and offloads a configurable number of transformer blocks from GPU to CPU. Two inputs matter:
blocks_to_swap(default 10) - how many blocks to move to system RAM. More blocks offloaded = less VRAM used and slower inference. 0 disables the behavior entirely.offload_embeddings- also offload compatible embedding and projection layers, squeezing out a bit more headroom.
Output is the patched model, ready to feed your sampler just like the original. The node uses ComfyUI's native weight-casting/offload system rather than rolling its own, which is reassuring - it's the same mechanism that powers ComfyUI's built-in --blocks_to_swap-style handling, just exposed as a graph node that works without command-line flags.
The "Universal" in the name does real work here: the source detects the model architecture, counts its transformer block groups, and applies the swap callback to whatever blocks it finds. So it handles SD, SDXL, Flux, WAN, and the other DiT-style models without you telling it which layout each one uses. There's also automatic detection of ComfyUI's native dynamic VRAM handling, so it tries not to fight the system's own memory management - when native dynamic VRAM is already active, it plays nice instead of double-offloading.
Why it's worth knowing
This is a "you don't need it until you do" node. If your card comfortably fits the model, leave it alone - block swapping only costs speed (moving weights across the PCIe bus is slow; community wisdom on the same idea: "the performance penalty for shuffling memory from VRAM to RAM is huge"). But when a model is just barely too big, swapping 10–20 blocks is often the difference between an OOM at step 3 and a slow-but-complete generation. It's also the polite alternative to teardown-style tiling for the transformer stage - a complement, not a competitor, to tiled VAE decoding.
Install it
Ships in ComfyUI_Eclipse. ComfyUI Manager → search "Eclipse" → Install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/r-vage/ComfyUI_Eclipse
No extra models to download; deps are the pack's usual (opencv-python, pilgram, PyYAML, aiohttp; portable installs may need pip install -r custom_nodes/ComfyUI_Eclipse/requirements.txt). It's under Eclipse → Tools (the README calls the category "Block Swap" in the utilities list).
Gotchas
The swap count is a tuning dial, not a set-and-forget. Start around 10 and watch both VRAM usage and iteration speed - if you're not near OOM, drop it; if the generation is crawling, you've swapped too much. Also, more offload doesn't linearly shrink the failure: there's a sweet spot per model, and past it you're paying huge speed penalties for headroom you don't need. And because it swaps transformer blocks, don't expect it to fix VRAM problems in the VAE or text encoder stages - those live outside the transformer and need their own treatment (tiled decode, encoder offload). Know which stage is eating your memory before you blame the swap.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | The diffusion model to apply block swapping to. | |
| blocks_to_swap | INT | 100–100 | Number of transformer blocks to offload from GPU to CPU. Higher values save VRAM but reduce inference speed. Set to 0 to disable. |
| offload_embeddings | BOOLEAN | false | Also offload compatible embedding and projection layers. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |