- Python 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| workflow | ||
| convert_minimax_h3_w4a8_streaming_v2.py | ||
| LICENSE | ||
| README.md | ||
minimax-h3-w4a8-quantizer
Makes W4A8 quants for MiniMax H3-based diffusion transformers with low VRAM by streaming tensors from disk. Written with GPT-5.6 Terra and then rewritten with Sol.
Rationale
Observation: Kijai's w4a8 version of H3 is excellent; nearly identical to the int8_convrot at half the memory cost.
Problem: People aren't making w4a8 versions of their H3 finetunes!
Solution: You're looking at it!
This is a Python script that converts a full-precision BF16 file for a Minimax H3-based model, and spits out a w4a8 version. It streams the weights from disk layer by layer, instead of loading the entire model at once, so you DON'T have to have 70GB of memory available to use it! (If you can use Kijai's w4a8 of the base model, you should be good to go.)
Samples are on CivitAI. the first video here is with my w4a8 quant of PinkCherry; the second is the official int8_convrot.
Directions
- If you don't already have it, install uv.
- Download the script (either
git clonethe repo or just click the .py file above and then click Download; if you're new to Forgejo it's next to the buttons that say Raw/Permalink/etc.) - Download a full-precision BF16 MiniMax H3 model. To replicate the videos above, use PinkCherry beta 0.6. Put it next to the script.
- Open a terminal in the same directory as the script (PowerShell will probably do) and the BF16 weights and run this, replacing with the name of the BF16 .safetensors file and with... whatever you'll remember.
uv run --script convert_minimax_h3_w4a8_streaming.py <MODEL> <QUANT>
By default, this script keeps adaln intact. If you want to make a pruned checkpoint, you can pass --prune-adaln, like so:
uv run --script convert_minimax_h3_w4a8_streaming.py --prune-adaln <MODEL> <QUANT>
To create the file used in the sample videos, I did this:
uv run --script convert_minimax_h3_w4a8_streaming.py --prune-adaln \
PinkCherry_fl2va_MiniMax_H3_bf16_beta-0.6.safetensors \
PinkCherry_fl2va_MiniMax_H3_w4a8_pruned_beta-0.6.safetensors
Once finished, put the resulting file in your diffusion_models folder, and give it a test! If it's to your liking, you can delete the BF16 weights to reclaim your disk space.
Using without uv
If for some reason you can't/don't want to use uv, you can make a Python venv to use this script with Python >=3.10. This is the "I know what I'm doing" path; please don't ask for help with this, I use uv specifically so I don't have to deal with Python venvs.
- numpy>=1.26,<3
- torch==2.7.1 (if you need CUDA then make sure to pass the right https://download.pytorch.org/whl/ index URL as well)
- triton==3.3.1
Then activate the venv and use python/python3 instead of uv run --script.
Caveats
- I haven't tested that this script prunes adaln in the exact way Kijai did. The outputs aren't degraded, and the safetensors index looks roughly right, but if you encounter unexpectedly broken outputs, leave a comment on CivitAI.
- I haven't tested this with anything that alters the model architecture in any arcane way, like 10Eros. You can try though. Report back!
- I also haven't tested with a ref2va model yet. Near as I can tell the actual architecture is the same, but I'll verify this as soon as I have a reason to, as so far there are no non-LoRA finetunes of ref2va yet, that I care about.
License and Terms of Use
This script is released under the Unlicense, a public-domain-equivalent license. This means you are allowed to use it for whatever you want with no need to credit me.
My two terms are "Don't Be A Dick" and "Don't Make It My Problem". They are not legally binding, obviously, but they inform how I will treat you.
Don't Be A Dick
If your usage of this script would be described by me or someone with my interests at heart as "a dick move", probably don't do it.
Don't Make It My Problem
If you have a problem with this, I'll help you if you're polite, but if you make your problems my problems, I will not help you.
Capische? Capische. Get outta my shop.