Repository navigation
MiniMax-H3-Image: fused blocks and tabulated AdaLN modulation (0.18.0) - #29
Merged
Merged
Conversation
Add MiniMaxH3ImageTransformer2DModel to the minimax_h3 fused family. tabulate_modulation replaces the per-block AdaLN projections, the timestep MLP and the output-norm projection with tables for the model's fixed timesteps (13.0 of 33.1 billion parameters); add_modulation_tables builds the empty tables before a tabulated checkpoint loads. fuse_linears no longer keeps every replaced projection alive until it returns, so a text encoder no longer holds its packed weights twice on the device during fusion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
MiniMaxH3ImageTransformer2DModel(Diffusers pull request 15230) to theminimax_h3fused family. The image model has the MiniMax-H3 blocks, so the fused prologues, attention and epilogues are the same.MiniMax-H3-Image samples six fixed timesteps (and one noise level for reference images), and its per-block AdaLN projections read only the timestep embedding.
minimax_h3.tabulate_modulation(model, timesteps)computes their outputs for those timesteps from the loaded weights and replaces the projections, the timestep MLP and the output-norm projection with tables: 13.0 of the 33.1 billion transformer parameters (26 GB in BF16) are not stored.add_modulation_tablesbuilds the empty tables before a tabulated checkpoint loads, andinstallruns the forward with table lookups. A timestep outside the table raisesValueError.fuse_linearsno longer keeps the replaced projections alive until it returns. Before, it iterated over a list of all modules, so a text encoder could hold up to twice its packed weights on the device during fusion.Tests: the tabulated forward matches the original forward (tiny model), the tables load into an empty skeleton, and an unknown timestep raises.
Validation on an RTX PRO 6000 Blackwell (Torch 2.12.1, CUDA 13.0) with the GPTQ W4A8 checkpoint WaveCut/MiniMax-H3-Image-OrbitQuant-W4A8: a 2048×2048 image takes 2.94 s end to end (six transformer steps 2.15 s) with a 27.3 GiB device peak, and LPIPS against the BF16 original is 0.182 over 18 prompts. With the PyTorch allocator capped at 30.5 GiB, the transformer and the text encoder now load and run resident; before the
fuse_linearschange the same load ran out of memory during text-encoder fusion.