From 6bbc566a5211afb9f9b6d0865fffc2570b235540 Mon Sep 17 00:00:00 2001 From: silveroxides Date: Sat, 31 Oct 2026 19:57:42 +0100 Subject: [PATCH] Support bare LoRA A/B suffixes without .weight in MiniMax H3 converter --- nodes/minimax_h3_lora_convert.py | 4 ++-- tests/test_minimax_h3_lora_convert.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/nodes/minimax_h3_lora_convert.py b/nodes/minimax_h3_lora_convert.py index 8609ecb..017d73b 100644 --- a/nodes/minimax_h3_lora_convert.py +++ b/nodes/minimax_h3_lora_convert.py @@ -15,7 +15,7 @@ from .quantization_guard import inspect_low_bit_input from .uel_io import atomic_uel_writer _FACTOR_RE = re.compile( - r"^(?P.+)\.(?:lora_(?P[AB])|lora\.(?Pdown|up))(?:\.default)?\.weight$" + r"^(?P.+)\.(?:lora_(?P[AB])|lora[._](?Pdown|up))(?:\.default)?(?:\.weight)?$" ) _BLOCK_RE = re.compile(r"^transformer_blocks\.(?P\d+)\.(?P.+)$") _REFINER_RE = re.compile(r"^token_refiner\.refiner_blocks\.(?P\d+)\.(?P.+)$") @@ -54,7 +54,7 @@ def _target_module(module: str) -> tuple[str, str | None, bool]: Returns: (target_module, qkv_part, is_swiglu_fc1) """ - clean_mod = module.removeprefix("transformer.") + clean_mod = module.removeprefix("base_model.model.").removeprefix("transformer.") match = _BLOCK_RE.fullmatch(clean_mod) if match: prefix = f"diffusion_model.blocks.{match.group('index')}" diff --git a/tests/test_minimax_h3_lora_convert.py b/tests/test_minimax_h3_lora_convert.py index e9c36b8..ed23e9a 100644 --- a/tests/test_minimax_h3_lora_convert.py +++ b/tests/test_minimax_h3_lora_convert.py @@ -202,3 +202,25 @@ def test_lora_down_up_suffixes_supported(converter, tmp_path): assert "diffusion_model.blocks.0.attn.qkv_proj.lora_B.weight" in converted assert "diffusion_model.blocks.0.mlp.fc1.lora_A.weight" in converted assert "diffusion_model.blocks.0.mlp.fc1.lora_B.weight" in converted + + +def test_bare_lora_ab_without_weight_suffix_supported(converter, tmp_path): + source = tmp_path / "source_bare_ab.safetensors" + output = tmp_path / "output_bare_ab.safetensors" + + original = _make_source_tensors("token_refiner.refiner_blocks.0") + modified = { + k.replace(".default.weight", ""): v + for k, v in original.items() + } + + save_file(modified, str(source)) + report = converter.convert_minimax_h3_diffusers_lora(str(source), str(output)) + assert "MiniMax H3 Diffusers LoRA conversion complete" in report + converted = load_file(str(output)) + + assert "diffusion_model.token_refiner.blocks.0.attn.qkv_proj.lora_A.weight" in converted + assert "diffusion_model.token_refiner.blocks.0.attn.qkv_proj.lora_B.weight" in converted + assert "diffusion_model.token_refiner.blocks.0.mlp.fc1.lora_A.weight" in converted + assert "diffusion_model.token_refiner.blocks.0.mlp.fc1.lora_B.weight" in converted +