Qwen2/3 MoE + GGUF model support (restored) #42854
Open
+66
−19
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?
This commit restores Qwen2/3 MoE + GGUF support in Transformers v5.
In this version, handling of MoE tensors are significantly changed so that support for all MoE + GGUF models ... (okay, actually) Qwen2/3 MoE models in Transformers v4 is now broken in v5.
This commit now adopts new tensor handling, along with extended
TensorProcessorwith capabilities to handle not only tensor data but also tensor mappings.In this process, Qwen2/3 MoE-specific hack is moved to
Qwen2MoeTensorProcessor, making the main function to look more model-agnostic.This is fully tested on Qwen2 MoE
Qwen1.5-MoE-A2.7B(with 14.3B total parameters) and partially on Qwen3 MoEQwen3-30B-A3B-Thinking-2507(due to memory constraints).Future Possibilities
Portions of this change is written to be model-agnostic and easily replaceable.
If we decide to add more GGUF support to MoE models, we'd better to have either a mix-in or an utility. In this case, a part of
Qwen2MoeTensorProcessorcan be copied to that with small modification.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.
@Cyrilvallez @SunMarc @MekkCyber