Repository navigation
Pin the eager experts implementation in moe=True quantized checkpoints - #2740
Open
Oke Iyanuoluwa Enoch (Iyanuoluwa007) wants to merge 2 commits into
Open
Oke Iyanuoluwa Enoch (Iyanuoluwa007) wants to merge 2 commits into
Oke Iyanuoluwa Enoch (Iyanuoluwa007) wants to merge 2 commits into
Conversation
transformers picks the grouped_mm fused-experts forward by default, even on CPU. It transposes the expert weight, which a storage-only QuantTensor can't do, so running a reloaded Rtn/Gptq/KQuant(moe=True) checkpoint crashed with "Shape-movement / view ops ... are not supported on an Olive QuantTensor". save_pretrained doesn't persist the experts implementation, so finalize() now writes "experts_implementation": "eager" to the saved config.json (after save_metadata, which rewrites that file). from_pretrained then loads the checkpoint with the eager forward, which uses the weight without moving it. Fixes microsoft#2619
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused shared-path fix addresses the reported crash with regression coverage and no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes #2619 by making MoE-quantized checkpoints default to eager experts during native PyTorch inference.
Changes:
- Persists the eager setting after shared quantization finalization saves metadata.
- Adds a regression test covering checkpoint reload and inference.
- Updates documentation to explain the new default.
| File | Description |
|---|---|
| test/passes/pytorch/test_rtn.py | Tests default reload and inference for an MoE-quantized checkpoint. |
| olive/passes/pytorch/quant_utils.py | Pins eager experts in saved configuration for moe=True. |
| docs/source/features/quantization.md | Documents the eager default and explicit overrides. |
Review effort: Balanced
5 tasks
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describe your changes
After
Rtn,GptqorKQuantwithmoe=True, reloading the checkpoint and callingmodel(...)crashes with:transformers selects the
grouped_mmfused-experts forward by default (even on CPU), and its_grouped_linearcallsweight.transpose(-2, -1), which the storage-onlyQuantTensordeliberately rejects. Theeagerimplementation works, but users had to know to callmodel.set_experts_implementation("eager")themselves.finalize()(shared by all three passes) now writes"experts_implementation": "eager"to the savedconfig.jsonformoe=Trueruns, sofrom_pretrainedloads the checkpoint with the eager forward by default.save_pretraineddoes not persist the implementation choice, andsave_metadatarewritesconfig.json, so the key is written after both.The quantization docs section that described the manual workaround now explains this default instead.
This only addresses the inference crash (item 1 of the issue). Making
QuantTensorsupport a transpose (and whetherbatched_mmis affected) stays with the transposed-layout design in #2621.Checklist before requesting a review
test_rtn_moe_checkpoint_runs_with_default_experts_implementation: quantizes a tiny local Qwen3-MoE whose config uses the default implementation, reloads it and runs a forward pass. Without the fix it fails with theQuantTensorRuntimeError above.)test_rtn.py,test_kquant.py,test_gptq_moe.py,test_selective_mixed_precision.py: 278 passed, 3 skipped)lintrunner -a(ruff 0.15.11 check and format on changed files)Checkpoints quantized with
moe=Truenow load with theeagerexperts implementation, so native PyTorch inference works without callingset_experts_implementation("eager")manually.(Optional) Issue link
Fixes #2619