Repository navigation
feat(lora): support kohya-format MiniMax H3 LoRAs - #9703
Conversation
Un-flatten lora_unet_* keys against the H3 Linear vocabulary so detection and conversion share the dotted native layout; unresolvable kohya keys reject the file. Move the kohya leaf check into kohya_key_utils for reuse by Krea-2 and H3.
JPPhoto
left a comment
There was a problem hiding this comment.
No merge blockers, but there is something to investigate:
invokeai/backend/patches/lora_conversions/minimax_h3_lora_constants.py:136: Flattened H3 keys pass the probe, which checks for any LoRA suffix atinvokeai/backend/model_manager/configs/lora.py:1238. A file withlora_downbut no matchinglora_upis accepted; conversion then raisesKeyErroratinvokeai/backend/patches/lora_conversions/minimax_h3_lora_conversion_utils.py:120. The equivalent dotted PEFT gap predates this PR. Effect: installation succeeds, then loading or generation fails. Likelihood: plausible for an incomplete or corrupt adapter. Recovery: replace and reinstall it. Test: assert the H3 probe rejects an unmatched Kohya pair.
Corner/impossible cases to note but not do anything about:
invokeai/backend/patches/lora_conversions/minimax_h3_lora_conversion_utils.py:109: If a file contains the same layer in dotted and flattened forms with different tensors, normalization overwrites one based on key order. Effect: one adapter weight is silently discarded. Likelihood: rare mixed-format file. Recovery: re-export one form. Test: assert duplicate normalized keys are rejected.
Suggested follow-up work (pre-existing):
invokeai/backend/patches/lora_conversions/minimax_h3_lora_constants.py:118: The existing H3 probe does not reject PEFTlora_magnitude_vector.weight;_normalize_lora_param_namesdrops that DoRA magnitude. Please make an issue: reject or support PEFT DoRA magnitude keys.
Probe and converter share one rule: each layer is exactly one lora_A/lora_B or lora_down/lora_up pair plus optional alpha. Half pairs, a layer in two spellings, mixed naming and stray tensors (incl. PEFT DoRA magnitudes) now fail with a clear error instead of crashing or being dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@JPPhoto thanks for the review. All three points are addressed in e8b8992. Unmatched pairs (main finding). Confirmed for both kohya and dotted keys. The probe and the converter now share one rule, Same layer in two spellings. Confirmed. It was also slightly worse than described: with A/B in one form and down/up in the other, nothing was overwritten, but the down/up pair was silently dropped. Grouping now un-flattens kohya keys and strips the PEFT prefix before checking for duplicates. Dotted vs. kohya, prefixed vs. unprefixed, and mixed A/B with down/up in one layer are all rejected. PEFT DoRA magnitude. Instead of only filing an issue, I folded the rejection into the same rule: any tensor that isn't a LoRA pair or All three published Turbo LoRA variants pass the new rule, and conversion output on real H3 LoRAs (published Turbo, kohya with |
JPPhoto
left a comment
There was a problem hiding this comment.
Approved! I am making an issue for two findings that pre-date this work and assigning to you. You're welcome.
Summary
MiniMax H3 LoRAs trained with kohya sd-scripts / musubi-tuner (e.g. Inner-Reflections/MiniMax-H3-Looping-Sketch-Anime) failed to install with "not recognized": they use flattened keys with per-layer alpha (
lora_unet_blocks_0_attn_qkv_proj.lora_down.weight,.alpha), while H3 LoRA identification only understood the dotted native layout used by the Turbo LoRA (blocks.0.attn.qkv_proj.lora_A.weight)..alphatensors are honored.lora_unet_key that does not reconstruct to an H3 Linear rejects the file instead of installing a LoRA that silently patches nothing.krea2_lora_constantstokohya_key_utilsso Krea-2 and H3 share it (no Krea-2 behavior change).Related Issues / Discussions
None.
QA Instructions
uv run --no-sync pytest tests/backend/patches tests/backend/model_manager tests/backend/minimax_h3 tests/app/invocations— 4610 passed.ruff@0.11.2check/format clean.minimax_h3_looping_sketch_anime_v1.safetensors(musubi-tuner, 600 tensors, rank 32, alpha 32):mainidentifies it asUnknown_Config; this branch identifies it only asLoRA_LyCORIS_MiniMaxH3_Config. It converts to 300 layers, each resolving to annn.Linearwith matching shape on a meta-deviceMiniMaxH3Transformer3DModelbuilt from the released transformer config.Review
No material findings. Known limitations shared with the existing dotted-key path, left out of scope: factorized LoKR /
.diffkeys are accepted at install but fail at load, non-lora_unet_foreign keys (e.g.lora_te_*) convert to no-op layers, and zero-padded block indices are not rejected.Checklist
What's Newcopy (if doing a release after this PR)🤖 Generated with Claude Code