Skip to content

Rename only MiniMax-M3-VL's MoE block, so a save keeps the dense and vision mlp keys - #49786

Merged
IlyasMoutawwakil merged 3 commits into
mainfrom
fg-split/fix-minimax-m3-vl-save-mapping
Oct 27, 2026
Merged

IlyasMoutawwakil merged 3 commits into
mainfrom
fg-split/fix-minimax-m3-vl-save-mapping

Conversation

@IlyasMoutawwakil

@IlyasMoutawwakil IlyasMoutawwakil commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

🤗 Transformers CI

What. The .block_sparse_moe. to .mlp. rename, reversed on save, turned every .mlp. key into
.block_sparse_moe., the dense and vision ones too. The pattern now names the MoE block's children. The reverse
mapping test, skipped until now, runs on the composite model, as for Llava.

Why we need it. MiniMax-M3 MXFP8 support (#49780) blocked on it. Its tiny-checkpoint test
(IlyasMoutawwakil/tiny-random-MiniMaxM3-MXFP8) loads the checkpoint, saves it back and compares the keys. The
save wrote the dense and vision MLP weights under MoE names, so the saved checkpoint no longer matched the original.
save_pretrained on MiniMax-M3-VL does the same on main. The un-skipped reverse-mapping test catches it.

Depends on. #49772 (the reversed group needs its escaped dots).

How tested. tests/models/minimax_m3_vl -k "reverse_loading or save_load".

The comments and docstrings that say why each change exists are there for readability. Feel free to ask for any of them to go if it's self-evident.

🤖 Generated with Claude Code

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@IlyasMoutawwakil
IlyasMoutawwakil force-pushed the fg-split/fix-minimax-m3-vl-save-mapping branch from daad369 to 5dd6ef5 Compare October 20, 2026 16:04
Comment thread src/transformers/conversion_mapping.py Outdated
WeightRenaming(source_patterns=r"\.block_sparse_moe\.", target_patterns=r"\.mlp\."),
# Only the MoE block. Otherwise a save would also rename the dense and vision `.mlp.` keys.
WeightRenaming(
source_patterns=r"\.block_sparse_moe\.(experts\.|gate\.|shared_experts\.|e_score_correction_bias$)",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need the $?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, no other key under the moe block starts with e_score_correction_bias, so it matches without it. dropped it

@IlyasMoutawwakil
IlyasMoutawwakil removed this pull request from stack #49788 October 20, 2026 16:25
@IlyasMoutawwakil
IlyasMoutawwakil force-pushed the fg-split/fix-minimax-m3-vl-save-mapping branch from 5dd6ef5 to b506cb2 Compare October 20, 2026 17:34
@IlyasMoutawwakil
IlyasMoutawwakil force-pushed the fg-split/fix-minimax-m3-vl-save-mapping branch from b506cb2 to 9c63025 Compare October 21, 2026 07:24
@IlyasMoutawwakil
IlyasMoutawwakil marked this pull request as ready for review October 21, 2026 07:37
@IlyasMoutawwakil
IlyasMoutawwakil force-pushed the fg-split/fix-minimax-m3-vl-save-mapping branch from ffef87f to 43f32c4 Compare October 21, 2026 07:53
@IlyasMoutawwakil
IlyasMoutawwakil removed this pull request from stack #49798 October 21, 2026 08:59
@IlyasMoutawwakil
IlyasMoutawwakil force-pushed the fg-split/fix-minimax-m3-vl-save-mapping branch 2 times, most recently from 5a70522 to 19d9f5c Compare October 23, 2026 13:35
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: minimax_m3_vl

@Cyrilvallez Cyrilvallez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the pattern since we need to repass over e_score_correction_bias anyway, that way the first pattern does not contain any \. litteral dots inside the capturing groups and it's a bit more readable than doing 2 patterns for the same e_score_correction_bias key.
I don't mind still merging the linked PR for litteral dots in capturing groups though, as it makes the system more robust in general even if not used here

Base automatically changed from fg-split/fix-reverse-escaping to main October 27, 2026 10:38
IlyasMoutawwakil and others added 3 commits October 27, 2026 10:38
…ision mlp keys

The `.block_sparse_moe.` -> `.mlp.` rename reversed on save turned every
`.mlp.` key back into `.block_sparse_moe.`, the dense and vision ones too.
Name the MoE block's children in the pattern; the reversed group keeps its
escaped dots. Run the reverse-mapping test that was skipped, on the composite
model only, as for Llava.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No other key under the MoE block starts with `e_score_correction_bias`, so the alternative matches without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@IlyasMoutawwakil
IlyasMoutawwakil force-pushed the fg-split/fix-minimax-m3-vl-save-mapping branch from 2429e29 to 98a71e8 Compare October 27, 2026 10:38
@IlyasMoutawwakil
IlyasMoutawwakil enabled stacked auto-merge October 27, 2026 10:41
@IlyasMoutawwakil
IlyasMoutawwakil added this pull request to the merge queue Oct 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 27, 2026
@IlyasMoutawwakil
IlyasMoutawwakil added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit 820b153 Oct 27, 2026
122 checks passed
@IlyasMoutawwakil
IlyasMoutawwakil deleted the fg-split/fix-minimax-m3-vl-save-mapping branch October 27, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants