HunyuanVideoBlockSwap
The VRAM escape hatch for native HunyuanVideo
- model
- MODEL
HunyuanVideo 13B is a ~25GB fp16 diffusion transformer, and Tencent's official launch numbers were 45–60GB of VRAM. Even a 24GB 3090 OOMs at 720p. If you're determined to run it with ComfyUI's native HunyuanVideo loader on a 12–16GB card, the one trick that saves you is block swap - park part of the model in RAM and stream it through the GPU during sampling. That's the whole job of hvBlockSwap, and it does it in about twenty lines of real code.
There's a lineage worth knowing. kijai's ComfyUI-HunyuanVideoWrapper ships a HyVideoBlockSwap node with the exact same knobs - double_blocks_to_swap, single_blocks_to_swap, offload_txt_in, offload_img_in. This pack is essentially that idea ported to ComfyUI's native nodes, so you get the trick without adopting the whole wrapper. The author (fluffydiveX) has no other footprint to speak of - this is a "I needed it, so I shipped it" utility, not a maintained ecosystem. Keep your expectations at that level.
How it works
HunyuanVideo's DiT uses the same two-tier block layout as Flux: 20 double blocks (the big MMDiT ones) and 40 single blocks. The node clones your ModelPatcher, registers an ON_LOAD callback, and the moment the model loads it moves the first N double blocks and first M single blocks to the offload device - CPU/RAM by default. ComfyUI's loader then treats those as offloaded and shuffles them onto the GPU one at a time as the sampler asks for them. No magic, no prediction of which blocks you'll need next - just the classic "run a too-big model by swapping through PCIe" approach.
The inputs that matter
double_blocks_to_swap- default 20 (all of them), range 0–20. This is your main lever.single_blocks_to_swap- default 0, range 0–40. Add a few only if you're still OOM; singles are smaller, so they're lower-value swaps.offload_txt_in/offload_img_in- two booleans that also park the input projection layers. Handy for squeezing out the last few hundred MB.
The single output is a MODEL - wire it into the sampler exactly where your original model went. The default of 20 swapped double blocks is aggressive and a fine first try; most people settle around 16–20 and call it done. Remember the trade: every block you swap makes each step slower, because VRAM→RAM round-trips are the bottleneck now.
Where people get burned
- It only fires for ComfyUI's native HunyuanVideo loader (
comfy.model_base.HunyuanVideo). If you're on kijai's wrapper, you already have this built in - and this node won't see your model at all. - Wire it into any non-Hunyuan model and it silently does nothing; the isinstance check just bails. No error, no warning.
- It only shrinks VRAM during the diffusion pass. Video VAE decode is a separate OOM source that block swap can't touch.
- This is a tool for the 13B original. HunyuanVideo 1.5 (8.3B, ~14GB floor with offloading) mostly doesn't need it - on 1.5, skip the pack.
Install
No requirements.txt, no model downloads, zero dependencies beyond ComfyUI core - it only touches the HunyuanVideo checkpoint you already load. Either via ComfyUI Manager (search "ComfyUI-hvBlockswap") or:
cd ComfyUI/custom_nodes
git clone https://github.com/fluffydiveX/ComfyUI-hvBlockswap
Restart ComfyUI and the node appears as HunyuanVideoBlockSwap. Niche, tiny, and exactly the right tool if you're committed to native nodes and want the 13B model on a mid-size card.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| double_blocks_to_swap | INT | 200–20 | Number of double blocks to swap |
| single_blocks_to_swap | INT | 00–40 | Number of single blocks to swap |
| offload_txt_in | BOOLEAN | false | Offload txt_in layer |
| offload_img_in | BOOLEAN | false | Offload img_in layer |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |