KJNodes/experimentalgenerated

MiniMax H3 Chunk FeedForward(MiniMaxChunkFeedForward)

Chunks the MiniMax H3 feedforward (SwiGLU) over the packed token dim to reduce peak VRAM usage.

Mini Max Chunk Feed Forward

model
model
chunks
2
seq_threshold
4096
KJNodes

Description

MiniMaxChunkFeedForward reduces peak VRAM usage during MiniMax H3 inference by splitting the model's feedforward (SwiGLU) computation over the packed token dimension into multiple chunks. Each chunk is processed separately instead of materializing the full intermediate activation for every token at once, which lowers the memory high-water mark of that stage.

The patch is output-preserving: when the model is quantized, every chunk still runs through ComfyUI's fused INT8 kernel, and because activations are quantized per-token, the result matches what the unchunked model would produce.

This node lives in the KJNodes/experimental category. It patches the model in place and passes it through, so it can be dropped anywhere in a model chain before sampling.

Inputs

model

Type: MODEL (required)

The model to patch. The node attaches the chunked feedforward behavior to this model and returns it, so the usual pattern is to route your loader or model-patch chain through this node before the sampler.

chunks

Type: INT (required) Default: 2 Range: 1 – 64, step 1

Number of chunks to split the feedforward tokens into. More chunks mean lower peak VRAM, at the cost of slightly more overhead from the extra kernel launches and per-chunk bookkeeping. A value of 1 performs no splitting, effectively leaving the feedforward unchunked.

seq_threshold

Type: INT (required) Default: 4096 Range: 256 – 262144, step 256

Only chunk when the packed token count exceeds this value. Sequences at or below the threshold skip chunking entirely, so tiny batches and short sequences don't pay the per-chunk overhead. Raise it to restrict chunking to longer, memory-heavy runs; lower it to apply chunking more aggressively.

Outputs

MODEL output

The patched model, with the chunked feedforward applied when the token count exceeds seq_threshold. Connect it to your sampler or to further model patches as usual.

Usage Notes

  • Tune chunks against seq_threshold. Chunking only activates on sequences longer than seq_threshold (default 4096 tokens). If you are still hitting out-of-memory errors on long sequences, increase chunks; if you see a slowdown without a memory benefit, check that your sequences actually exceed the threshold, or lower it.
  • Quantized models keep their fast path. With a quantized model, each chunk still goes through ComfyUI's fused INT8 kernel rather than a fallback, so you are not trading away the optimized path to save memory.
  • Outputs should match the unchunked model. Per-token activation quantization means chunking does not change results: this is a memory optimization, not a quality or behavior change.
  • Chunking is a trade, not a free win. More chunks reduce peak VRAM but add a little overhead, so pick the smallest chunks value that keeps you within budget.
  • Experimental. This node is filed under KJNodes/experimental; behavior and defaults may change in future updates.

Comments

Sign in with GitHub to join the discussion.

Loading comments…