Extensions/H3 MoE (MiniMax-H3 shared + 8 experts)
ComfyUI Extension

H3 MoE (MiniMax-H3 shared + 8 experts)

Run the Agnes shared-expert + 8-expert MoE variant of MiniMax-H3 FL2VA, and build the experts file from your own compatible H3 model (int8, w3a8-w6a8, INT4 convrot, bf16).

By Winnougan·Created 2 days ago·Updated about 24 hours ago· 5
Winnougan/ComfyUI-H3-MoE
Nodes—
On cloudLocal install
Stars5
Updatedabout 24 hours ago
Readme

ComfyUI nodes to run the Agnes shared-expert + 8 routed experts variant of MiniMax-H3 FL2VA, and to build the experts file from your own compatible H3 model. Experimental community port; the MoE conversion, router and LoRA are by Agnes-AI, MiniMax-H3 is by MiniMax. Not affiliated with either. This repo contains code only, no model weights.

What it does

<img width="764" height="508" alt="01 ComfyUI MOE workflow for MiniMax-H3" src="https://github.com/user-attachments/assets/379eb9b8-c40a-4b1a-b5d3-2091f40a9bec" /> <img width="764" height="264" alt="02 Dense versus MoE comparison" src="https://github.com/user-attachments/assets/c9ceb410-ac8d-421c-a76d-cc9bce8e7808" /> <img width="764" height="284" alt="03 Checking square counts, then moving on to the Build node pipeline" src="https://github.com/user-attachments/assets/ff9f03ec-05c7-422c-9bc2-b0964444ec50" /> <img width="764" height="252" alt="04 block map" src="https://github.com/user-attachments/assets/b0eb1c16-be02-4fc6-9647-5bbffa0209aa" /> <img width="764" height="312" alt="05 Correcting block count estimates and drawing the diagram" src="https://github.com/user-attachments/assets/969ac4dc-d682-41f6-a191-e1c29ac6dbab" />

Blocks 15-34 of MiniMax-H3 FL2VA have their feed-forward layers replaced by one shared expert (3,072 neurons, always on) plus one of eight private experts (6,144 neurons each), chosen per token by a learned router: out = shared(x) + expert_e(x). Each token runs 9,216 of the dense layer's 14,336 neurons (64%) in those blocks. Attention and the other blocks are unchanged.

This is not a memory-saving feature and no speed-up is claimed. ComfyUI's dynamic VRAM manages your base model's weights as usual; the experts are kept in system RAM by this pack and copied to the GPU block by block. Benchmark on your own hardware.

Nodes

  • H3 MoE Build Experts: cuts the experts out of a dense H3 file and writes an experts file (about 17 GB, int8). Can bake up to four extra LoRAs into the experts, each with its own strength (see LoRAs and MoE).
  • H3 MoE Apply (shared + 8 experts): routes blocks 15-34 through the experts. Place it right after the model loader.
  • H3 MoE Free Cache: releases the experts from system RAM.

Install

  1. Clone into ComfyUI/custom_nodes/: git clone https://github.com/Winnougan/ComfyUI-H3-MoE
  2. Put Agnes's init.json and step-60.safetensors in ComfyUI/models/h3_moe/.
  3. Restart ComfyUI.

Prebuilt experts files for some bases and finetunes are on Hugging Face: Winnougan/MiniMax-H3-MoE-Experts. Each file only works with the base it was built from.

Use

  1. Add H3 MoE Build Experts, choose your base model, init.json and the router LoRA (step-60.safetensors), set an output name that identifies the base, and run it (a few minutes). If a file with that name already exists the node skips the build unless overwrite is on.
  2. Optional: pick up to four LoRAs in the extra_lora slots to bake them in (see below). Use a new output name for every combination.
  3. Press R to refresh the node list.
  4. Load your base with Load Diffusion Model, add H3 MoE Apply after it, and select the experts file. Always pair an experts file with the exact base it was built from.
  5. In the console you should see [H3 MoE] block 15: MoE forward is running. Turn on log_routing in the Apply node to also print how many tokens each expert receives.

LoRAs and MoE

In blocks 15-34 the dense feed-forward layers (mlp.fc1 / mlp.fc2) are no longer used, so a normal LoRA has nothing to patch there: its FFN weights for those blocks are skipped during the render (you may see lora key not loaded warnings). The rest of the same LoRA (attention, AdaLN, and the FFN of blocks outside 15-34) still applies normally.

You can now bake up to four LoRAs into the experts so their FFN weights for blocks 15-34 take effect:

  1. In H3 MoE Build Experts, pick a LoRA in any of the four extra_lora slots (from ComfyUI/models/loras) and set its strength (-4.0 to 4.0). Leave a slot on None, or its strength at 0, to skip it.
  2. Use a new output name for each combination, then build. The baked LoRAs and strengths are recorded in the experts file's metadata (extra_loras).
  3. In your workflow, load the same LoRAs as usual. Their FFN part for blocks 15-34 is already inside the experts and is not applied twice; everything else in the LoRA applies normally.

How it works: each expert is a slice of the dense neurons, so the LoRA's change is sliced with the same neuron indices and added to each expert before the final int8 requantization.

Things to know:

  • The strength is fixed when you build. Build with the strength you plan to use.
  • Every LoRA combination is its own experts file of about 17 GB.
  • Strengths add up. When stacking several LoRAs (for example a turbo LoRA, a character and a style), start the character and style lower and compare against the dense model with the same LoRAs loaded normally.
  • Supported LoRA formats: lora_A / lora_B (or lora_down / lora_up) with an optional alpha. If alpha is missing it is treated as equal to the rank. The node stops with a clear message if a LoRA has no FFN weights for the selected blocks or its shapes do not fit the model, and warns if only some blocks are covered.
  • Not yet verified on every LoRA type. Compare a render against dense with the same LoRA before relying on it.

Comparison: character LoRA baked vs. loaded normally

Same base model, prompt, seed and settings (8 steps). Both runs use H3 MoE Apply and load the same two LoRAs in the workflow: an 8-step turbo fusion LoRA and a character LoRA. The only difference is the experts file.

| | Experts file | Result | |---|---|---| | A: LoRAs baked in | Built with the turbo fusion and character LoRAs in the extra_lora slots (strength 1.0 each) | The character keeps her look | | B: normal LoRA load only | Built without extra LoRAs | The FFN part of the LoRAs is skipped in blocks 15-34 and the character drifts: she is not the same person |

A, baked (MiniMax_H3_00042_.mp4):

<!-- Drag MiniMax_H3_00042_.mp4 into the GitHub editor and paste the generated link here -->

https://github.com/user-attachments/assets/2b6f914e-ba9c-46dd-a422-b3ea20496148

B, normal load (MiniMax_H3_00037_.mp4):

<!-- Drag MiniMax_H3_00037_.mp4 into the GitHub editor and paste the generated link here -->

https://github.com/user-attachments/assets/a237ec70-ef67-42ad-acfb-8fc05f77dfab

Run log for A: all 20 MoE blocks (15-34) ran through the experts; 8 steps took 6:07 and the whole prompt 462 s on an RTX 3070 8 GB. This is one character, one seed and one prompt, so treat it as a single data point, not a guarantee: check your own LoRAs the same way. You can also confirm a bake with check_baked_lora.py (it prints the extra_loras metadata and how many of the 40 FFN layers each LoRA covers).

Command line (repeat --extra-lora PATH:STRENGTH up to as many times as you need):

python h3_moe_convert.py --base base.safetensors --init init.json --lora step-60.safetensors --out h3_moe_experts_mymodel.safetensors --extra-lora turbo.safetensors:1.0 --extra-lora character.safetensors:0.8

Supported bases

int8 (convrot or tensorwise), w3a8/w4a8/w5a8/w6a8 convrot, INT4 convrot, and bf16/fp16 H3 files with FL2VA layer sizes (hidden 5,376, FFN 14,336). Weight names with a prefix such as model.diffusion_model.blocks.15... are detected automatically. fp8, mxfp8 and nvfp4 files are refused.

The router and LoRA were trained on the original FL2VA weights. Reported working: FL2VA, REF2VA and several finetunes (see the Hugging Face page for the list). Some merges show visible artifacts, so convert each model and compare against the dense version before trusting it. A pruned model works only if its FFN is still 14,336 wide; the builder checks this and says so if the layout does not match init.json.

Limitations

  • About 17 GB of system RAM is held for the experts, on top of your base model. 32 GB of RAM or more is recommended; 16 GB will not fit.
  • LoRAs that patch the FFN of blocks 15-34 only take effect if baked in at build time (up to four per experts file).
  • Experts files are tied to the base they were built from, and to the LoRAs and strengths baked into them.
  • Bypass other nodes that patch mlp.forward.

Licenses

Code: MIT. The Agnes checkpoint, MiniMax-H3 and any finetune have their own licenses. MiniMax's license Q&A says the H3 open-weight license is currently limited to the EU, UK, South Korea and US; check the full terms before using or redistributing anything derived from the weights.