feat(minimax-h3): single-file pruned/int8-convrot transformer support (PR 6) - #145
feat(minimax-h3): single-file pruned/int8-convrot transformer support (PR 6)#145lstein wants to merge 1 commit into
Conversation
e749171 to
9e02826
Compare
7bfba65 to
3ad2168
Compare
9e02826 to
af32451
Compare
3ad2168 to
a19f545
Compare
a19f545 to
1f1a342
Compare
|
Critical fix amended in Found by layer-wise A/B against the diffusers folder as ground truth on identical production-built packed inputs: first divergence at the token refiner (cos 0.43 after a bit-exact context_embedder), then bit-exact half-crossover proof ( Why nothing caught it: key/shape dry-runs can't see intra-tensor layout; the ground-truth weight audit sampled qkv (order verified) and fc2, but fc1 — the one other tensor with internal semantic layout — wasn't sampled, and no unit test pinned its content. A regression test with distinguishable halves now does, and the lesson is recorded: every FUSED tensor family in a converter needs a content-level ground-truth check, not just shape. |
Loads MiniMax's single-file FL2VA transformer repacks (Comfy-Org layout): bf16 or Comfy int8_tensorwise(+convrot) quantized, full or AdaLN-pruned. The 19.5 GiB pruned-int8 file stays int8-resident in VRAM (fits a 45 GiB card outright, vs ~53% partial load for the 62 GiB bf16 folder transformer). - Int8ConvrotLinear: int8 weight + per-channel scale buffers, dequantized and derotated per forward. ConvRot is a grouped-256 regular-Hadamard rotation folded into the stored weights; H is symmetric orthonormal, so derotation is the same grouped matmul (semantics verified against Comfy-Org/comfy-quants + comfy-kitchen; reimplemented, not copied). - MiniMaxH3PrunedTransformer3DModel: 'adaln curves' variant - the timestep MLP and full-width AdaLN inputs are replaced by a [1025, 8] fp32 curve table (lerp lookup, SiLU-free fp32 AdaLN projections), matching ComfyUI's reference semantics. Vendored transformer file untouched. - State-dict converter: remote-code -> vendored diffusers key layout, incl. fused-qkv row splitting (scales split with their rows) and comfy_quant marker fan-out. Verified key-for-key + shape-for-shape against the real 19.5 GiB checkpoint header (dry run, no tensor data). - Probe: Main_Checkpoint_MiniMaxH3_Config fingerprints on the H3-unique audio+video patch projections; ref2va excluded by filename; pruned detected via adaln_t_table. Stripped identification fixture generated from the real file's header. - Loader: transformer-only (Wan-GGUF precedent); shape-inferred config; strict load after swapping quantized linears. - Node: minimax_h3_model_loader v1.1.0 gains an optional 'Transformer (single file)' override; folder main keeps serving encoders + VAEs. Default-workflow pins bumped to match. - UI: checkpoint-format H3 mains hidden from the main picker and offered in a MiniMax H3 advanced section combobox; params persist v5 -> v6 (minimaxH3TransformerModel), migration + fixtures updated; wired through buildMiniMaxH3Graph + metadata. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1f1a342 to
ed05671
Compare
Summary
PR 6 of the MiniMax H3 stack (on top of #144): load Comfy-Org single-file H3 transformers — including the pruned int8-convrot fl2va (19.5 GiB) — as a checkpoint-format main model that overrides the transformer while the diffusers folder keeps providing the text encoder, tokenizer/processor, and both VAEs.
Why: the bf16 folder transformer is 62 GiB — on a 48 GB card only ~53% stays resident and every denoise step streams ~30 GiB from RAM. The pruned int8 file is fully resident with room to spare, and has ~40% fewer FLOPs (the AdaLN branches are replaced by a precomputed rank-8 time-embedding curve).
Format support (semantics verified against Comfy-Org/comfy-quants, comfy-kitchen, and ComfyUI's model code — reimplemented, not copied)
<layer>.comfy_quantJSON markers. Weights stay int8 in VRAM (Int8ConvrotLinearbuffers); dequant happens per forward in the compute dtype (~620 MB transient at the largest layer).adaln_t_table[1025, 8] lerped at t∈[0,1] replaces the time embedder; rank-8 AdaLN projections, no silu, fp32 modulation. Implemented as a subclass of the vendored transformer (vendored file untouched). Timestep-domain equivalence with ComfyUI verified in review (t = 1−σ, keyframe pin 0.999, unique-t dedup).Wiring
Main_Checkpoint_MiniMaxH3_Config(fingerprint:audio_patch_proj.weight+video_patch_proj.weight+blocks.0.attn.qkv_proj.weight— checked for collisions against every other family's single-file fingerprint, both directions); identification fixture included.SubModelType.Transformer(Wan-GGUF precedent) and errors helpfully for anything else; shape-inferred config (verified key-for-key/shape-for-shape against the real 19.5 GiB header).minimax_h3_model_loaderv1.1.0: optionaltransformer_modelfield (checkpoint-format H3 mains); default workflows' pinned versions bumped.Known limitations (review-documented)
_version4; this stack claims v5 (PR 4) and v6 (this PR), and the flux2 branch also claims v5 — whichever lands second renumbers.max_cache_vram_gbbypasses working-memory reservations.Testing
vite buildOK. Schema regen committed (node field).minimax-h3 / checkpoint / fl2va, pruned), select it under Advanced → Transformer (single file), run t2v; expect ~31 GiB VRAM steady state and no per-step streaming.🤖 Generated with Claude Code