You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, this PR aims to add the MiMo-V2-Flash model to the Transformers library Fixes#42954
MiMo-V2 is "The last of the SOTAs" that isn't natively supported by the Transformers library, so I hope we can make this work.
Code Agent Policy
The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result, we ask that new users do not submit pure code agent PRs at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.
PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.
This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read CONTRIBUTING.md.
I confirm that this is not a pure code agent PR.
Before submitting
This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
Only pinging HF engineers who were involved in the PRs mentioned below:
Modular Sensei @vasqu , I took your comments from the other PR, to find the best candidates to inherit from. Although see #45144 (comment) for some important points.
Afaik, MiMo in the codebase is a bit novel as it's the only hybrid SWA that combines both dual theta RoPE and dual head
dims + attn sinks (like gpt-oss). Most similar models are either one or the other, but not both.
So modularity wasn't easy mode pass, pass, pass.
I added some verbose NOTES for context/choices, and make the review easier. I'll obviously remove these once things are settled.
The main modular anchor was to follow minimax M2 for the newer changes/V5/fused MoE LoC: 584 (modular) vs 692 (generated) - saved 108 LoC (15.6%)
Important points:
edit: CI TRF009 is temporarily ignored to allow this
I'm currently importing the modules to make dual eager attention functions work temporarily, while waiting for #45141 to be fixed.
This would allow disentanglement between sink and non-sink layers. Allowing users to benefits from SDPA/FA2/flex backends for the non-sink GA layers.
MiMoV2FlashTopKRouter:
Atm it is not a modular implementation inheriting from the existing DeepseekV3TopKRouter in transformers, for two reasons:
If it makes sense to change this masking in the repo for DSV3, then I can try to inherit something.
The class atm combines the 2 split DeepseekV3TopkRouter and DeepseekV3MoE.route_tokens_to_experts() to serve as a drop-in replacement in MixtralSparseMoeBlock, and simply override self.gate. This follows the newer pattern used by MiniMax-M2 for fused expert etc...
[For maintainers] Suggested jobs to run (before merge)
run-slow: auto, mimo_v2_flash
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
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.
What does this PR do?
Hello, this PR aims to add the MiMo-V2-Flash model to the Transformers library
Fixes #42954
MiMo-V2 is "The last of the SOTAs" that isn't natively supported by the Transformers library, so I hope we can make this work.
Code Agent Policy
The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
we ask that new users do not submit pure code agent PRs at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.
PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.
This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read
CONTRIBUTING.md.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
Only pinging HF engineers who were involved in the PRs mentioned below:
Modular Sensei @vasqu , I took your comments from the other PR, to find the best candidates to inherit from. Although see #45144 (comment) for some important points.
@ArthurZucker for gpt-oss similarity and text model
For reference, there were already 2 previous PRs (1 closed and 1 non modular/abandoned):
Afaik, MiMo in the codebase is a bit novel as it's the only hybrid SWA that combines both dual theta RoPE and dual head
dims + attn sinks (like gpt-oss). Most similar models are either one or the other, but not both.
So modularity wasn't easy mode pass, pass, pass.
I added some verbose NOTES for context/choices, and make the review easier. I'll obviously remove these once things are settled.