Nodes/KJNodes for ComfyUI/MiniMax H3 Low VRAM Attention
ComfyUI Node Runs on cloud

MiniMax H3 Low VRAM Attention

The H3 attention patch with no extra install

By kijai·Created 3 years ago·Updated 3 days ago· 3,123
MiniMax H3 Low VRAM Attention
  • model
  • model
head_chunks4

This is the sibling of the MiniMax H3 Sage Attention patch that doesn't make you install anything. It cuts the peak VRAM of H3's self-attention without swapping in new kernels, which means the math is identical - the node description is blunt about it: "Output is identical to the unpatched model." Heads in a transformer are independent, so attending to them in smaller groups produces exactly the same result while the kernel's internal working set shrinks. No approximation, no quantization trade, no extra dependency.

It's marked experimental like the other H3 memory hacks, but it's the one I'd try first on a mid-range card - it's the least dramatic change and it composes with everything else.

How it works

Two tricks working together. First, it restructures the block and attention forwards so big tensors are freed the moment they're consumed: the normed block input is handed to attention in a way that lets it be deleted right after the qkv GEMM, and the fused qkv buffer is released before out_proj allocates its output. Second, it splits the heads into groups - head_chunks of them - so the kernel's internal transients (the int8 q/k copies, the fp32 accumulator) shrink by the group count. Because the attention is computed per head group and heads never interact, the result is bit-for-bit what you'd get unchunked.

A nice detail: even at head_chunks = 1 you still get the buffer-freeing restructure. And it plays well with the Sage Attention patch - if both are present, the sage patch reads the head_chunks setting and honors it, so you can stack the two without a fight.

The inputs that matter

  • model - the H3 model to patch. Loader in, model out to the sampler.
  • head_chunks - how many head groups to split attention into. Default 4, up to 56. More = lower peak, marginally more overhead. Dial it up until the OOM stops; heads are independent so you can't break anything by raising it.

Installing KJNodes

ComfyUI Manager (search KJNodes) or:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
cd ComfyUI-KJNodes
pip install -r requirements.txt

Restart. The pack's own deps are light, and this node needs nothing extra - that's the selling point. You still need a recent ComfyUI with native MiniMax H3 support, since it patches comfy.ldm.minimax attention internals.

Gotchas

Like the chunked feedforward node, this one fails soft: if the model isn't H3, it logs a warning and hands the model back unchanged. If you don't see lower VRAM, check the console for that warning before you assume it's broken. And remember it's a patch on the model path - it has to sit between the loader and the sampler.

One honest caveat: this attacks the attention bill. If your OOM actually comes from the feedforward side - very possible on long sequences - this node won't fix it. That's what MiniMax H3 Chunk FeedForward is for, and the two stack cleanly: chunk the FFN for the big middle, split heads here for the attention peak. Together they're the "make H3 fit on a consumer card" kit, minus the sageattention install.

CategoryKJNodes/experimental

Inputs (2)

NameTypeDefaultDescription
modelMODEL
head_chunksINT41–56Number of head groups to split the attention call into. Kernel-internal transients scale down with this; heads are independent so the result is unchanged.

Outputs (1)

NameTypeDescription
modelMODEL