-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Auto-enable grouped MoE on loaded / PEFT'd models via loader hook #6727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f9d010d
c0bc6ef
51f07a6
0085ca4
ef8d27b
ec6fe59
bd7d58d
25a03e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3743,4 +3743,17 @@ def _for_training(m): | |
|
|
||
| from .rl import PatchFastRL | ||
|
|
||
| # Auto-enable grouped-GEMM MoE (tf<5 ModuleList experts) on built / PEFT'd models. Wrap the | ||
| # loader leaves before PatchFastRL so downstream patchers see the wrapped versions. Guarded. | ||
| try: | ||
| from unsloth_zoo.temporary_patches.moe_grouped_modulelist import wrap_loader_for_grouped_moe | ||
| FastLlamaModel.from_pretrained = staticmethod( | ||
| wrap_loader_for_grouped_moe(FastLlamaModel.from_pretrained) | ||
| ) | ||
|
Comment on lines
+3750
to
+3752
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a user loads an existing LoRA/PEFT adapter repo through Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Covered by the post-attach auto_enable_grouped_moe re-eval in the FastLanguageModel loader path, which runs after PeftModel.from_pretrained on the loaded-adapter path. Same re-eval now added to the vision path in 25a03e2. |
||
| FastLlamaModel.get_peft_model = staticmethod( | ||
| wrap_loader_for_grouped_moe(FastLlamaModel.get_peft_model) | ||
| ) | ||
| except Exception: | ||
| pass | ||
|
|
||
| PatchFastRL(FastLanguageModel = FastLlamaModel) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2207,3 +2207,16 @@ def check_dataset_for_missing_videos( | |
| warnings.warn(error_msg, stacklevel = 2) | ||
|
|
||
| return missing | ||
|
|
||
|
|
||
| # Auto-enable grouped-GEMM MoE (transformers<5 ModuleList experts); see llama.py. | ||
| try: | ||
| from unsloth_zoo.temporary_patches.moe_grouped_modulelist import wrap_loader_for_grouped_moe | ||
| FastBaseModel.from_pretrained = staticmethod( | ||
| wrap_loader_for_grouped_moe(FastBaseModel.from_pretrained) | ||
| ) | ||
|
Comment on lines
+2215
to
+2217
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 25a03e2. The FastModel / FastVisionModel is_peft path now re-runs auto_enable_grouped_moe after PeftModel.from_pretrained, so an expert-LoRA block restores the original loop while an attention-only adapter keeps the grouped path, matching the FastLanguageModel loader path. |
||
| FastBaseModel.get_peft_model = staticmethod( | ||
| wrap_loader_for_grouped_moe(FastBaseModel.get_peft_model) | ||
| ) | ||
| except Exception: | ||
| pass | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In normal installs using the declared
unsloth_zoo>=2026.6.7dependency, this module path does not resolve, and the broadexceptsilently skips the whole wrapping block. That means transformers<5 ModuleList MoE models loaded through this path (and the matchingvision.pyblock) keep using the old expert-loop implementation instead of the intended grouped-GEMM patch, so the new auto-enable behavior is effectively a no-op unless users happen to have an unpublished zoo build.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional. The import is a guarded no-op until unsloth-zoo#837 lands, which ships this exact module (temporary_patches/moe_grouped_modulelist.py). This loader change is meant to land independently and activate once the zoo side merges, so the path already points at the shipped module.