Add fused MoE support to SelectiveMixedPrecision heuristics - #2645
Open
Ti-Tai Wang (titaiwangms) wants to merge 4 commits into
Open
Add fused MoE support to SelectiveMixedPrecision heuristics#2645Ti-Tai Wang (titaiwangms) wants to merge 4 commits into
Ti-Tai Wang (titaiwangms) wants to merge 4 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1d9a8b1f-9b83-4a52-bfe4-92437196e1c1
Copilot started reviewing on behalf of
Ti-Tai Wang (titaiwangms)
September 1, 2026 18:39
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Olive’s SelectiveMixedPrecision fixed heuristics to support explicitly recognized fused-MoE (Qwen3/Qwen3.5) expert output projections, and enforces a “double opt-in” so MoE-capable quantizers must explicitly enable MoE when consuming a plan that requires it.
Changes:
- Add
moe: truesupport to fixedSelectiveMixedPrecisionMLP heuristics by resolving fused expertdown_projtargets viaLayerWrapper+ canonicaliter_quant_targetsidentities, and emitmixed_precision_info.requires_moewhen expert overrides are produced. - Add fail-closed validation and consumer-side enforcement in PyTorch quantization utilities so required MoE overrides can’t be silently skipped (unless already materialized by a compatible prior Olive checkpoint).
- Add unit tests and documentation covering supported MoE layouts, rejection paths, and the double-opt-in workflow.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
olive/passes/pytorch/selective_mixed_precision.py |
Adds moe config, MoE-aware fixed-heuristic targeting, and emits requires_moe metadata. |
olive/passes/pytorch/quant_utils.py |
Validates/propagates requires_moe, enforces consumer opt-in, and delays parameter mutation until after validation. |
olive/common/hf/wrapper.py |
Adds fail-closed LayerWrapper.get_expert_output for supported fused-expert output parameter resolution. |
test/passes/pytorch/test_selective_mixed_precision.py |
Adds MoE planning and end-to-end RTN consumption tests (including rejection and hybrid cases). |
test/passes/pytorch/test_quant_utils.py |
Adds tests for requires_moe enforcement, malformed metadata rejection, and required-target survival checks. |
test/common/test_hf_wrapper.py |
Adds tests validating LayerWrapper.get_expert_output behavior and fail-closed errors. |
docs/source/features/quantization.md |
Documents MoE selective mixed precision support and the required double opt-in behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1d9a8b1f-9b83-4a52-bfe4-92437196e1c1
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1d9a8b1f-9b83-4a52-bfe4-92437196e1c1
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
Add explicit, fail-closed fused-MoE support to the fixed
SelectiveMixedPrecisionheuristics.moe: truesupport tohigh_precision_mlp_downandhigh_precision_mlp_down_qkvfor explicitly recognized Qwen3/Qwen3.5 fused K-last expert layouts.LayerWrapperand canonicaliter_quant_targetsidentities, emitting whole per-layerexperts.down_projoverrides rather than per-expert precision.high_precision_lm_headas a legal MoE no-op, and reject score-based algorithms withmoe: trueuntil their parameter-level scoring is implemented separately.mixed_precision_info.requires_moeand require an explicitmoe: trueon the first MoE-capable RTN, GPTQ, or KQuant consumer. Validate that required expert overrides survive skip/component selection and are actually selected or already materialized before mutating parameters.This is the first implementation stage for #2638. A follow-up will generalize SNR/IQE scoring to fused parameter targets; KLD-gradient requires separate routing/gradient/memory design.
Checklist before requesting a review
lintrunner -a.Release note:
SelectiveMixedPrecisionfixed heuristics can now plan higher precision for supported fused Qwen MoE expert output projections with explicit downstream MoE opt-in and fail-closed validation.(Optional) Issue link
Part of #2638.