Skip to content

Add mixed-width INT2/INT4 QMoE builder support - #2624

Merged
David Fan (jiafatom) merged 3 commits into
mainfrom
jiafa/add-mixed-width-qmoe
Sep 28, 2026
Merged

David Fan (jiafatom) merged 3 commits into
mainfrom
jiafa/add-mixed-width-qmoe

Conversation

@jiafatom

@jiafatom David Fan (jiafatom) commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add structured quant_config.moe.fc1_type / fc2_type overrides for mixed-width QMoE export
  • extend the existing blockwise quantizer with symmetric raw INT2 QMoE packing and emit projection-specific runtime attributes
  • decode GPT-OSS MXFP4 experts and requantize them for integer mixed-width export
  • preserve existing INT4, INT8, and native MXFP4 paths; no new projection-specific legacy extra options are introduced

INT2 and mixed-width QMoE currently require the CUDA EP, block size 64 or 128, symmetric weights, and no zero points. A no-op INT4/INT4 projection override remains on the existing INT4 path and keeps block size 32 valid.

Depends on microsoft/onnxruntime#32761 for CUDA mixed-width QMoE runtime support.

Validation

  • 172 passed, 3 skipped across quant config, QMoE weights, and GPT-OSS loader tests
  • added coverage for no-op INT4 overrides and unsigned projection descriptor rejection
  • modified Python files compile successfully
  • git diff --check upstream/main...HEAD passes

The skipped tests require standalone QMoE/CUDA pack pybind exports that are not available in the local wheel.

@jiafatom
David Fan (jiafatom) requested a review from a team as a code owner September 25, 2026 20:49
Copilot AI lite review requested due to automatic review settings September 25, 2026 20:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved validation, configuration compatibility, and supported-type issues must be addressed.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity · 3 Low severity

Open (5)
What changed in this PR

Adds INT2 and mixed-width INT2/INT4 QMoE export support, including GPT-OSS MXFP4 decoding, quantization, configuration, and documentation.

Changes:

  • Adds FC1/FC2 projection overrides and validation.
  • Implements symmetric INT2 blockwise quantization.
  • Adds GPT-OSS MXFP4 decoding and expanded tests/documentation.
File Description
test/​python/​models/​test_gptoss_loader.py Tests MXFP4 decoding.
test/​python/​builder/​test_quant_config.py Tests configuration behavior.
test/​python/​builder/​test_qmoe_weights.py Tests mixed-width quantization and attributes.
src/​python/​py/​models/​README.md Documents new options.
src/​python/​py/​models/​quantization/​quant_config.py Adds INT2 and projection configuration.
src/​python/​py/​models/​quantization/​cuda_quantizer.py Implements INT2 QMoE quantization.
src/​python/​py/​models/​loaders/​gptoss.py Decodes MXFP4 experts.
src/​python/​py/​models/​builders/​phi.py Applies projection-specific widths.
src/​python/​py/​models/​builders/​gptoss.py Supports integer GPT-OSS requantization.
src/​python/​py/​models/​builders/​base.py Emits mixed-width attributes and weights.
src/​python/​py/​models/​builder.py Validates QMoE options.
src/​python/​py/​models/​builder_config.py Maps structured and legacy configuration.
docs/​ModelBuilderConfiguration.md Documents structured configuration fields.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/python/py/models/builder.py Resolved
Comment thread src/python/py/models/loaders/gptoss.py Resolved
Comment thread docs/ModelBuilderConfiguration.md Resolved

@tianleiwu Tianlei Wu (tianleiwu) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mixed-width QMoE attribute mapping and focused tests look solid, but the current head has three blocking correctness issues. Two newly added guards regress the existing dense INT2 DFlash path and account for the 14 builder-test failures reproduced locally and in CI. The accepted block-size set also needs to enforce ORT's contraction-dimension divisibility requirement. I also left one non-blocking duplicate-key cleanup.

Comment thread src/python/py/models/builders/base.py Resolved

@tianleiwu Tianlei Wu (tianleiwu) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous blocking findings are addressed on the current head. Dense INT2 remains available to DFlash, ORT-backed INT2 quantization is preserved, mixed-width CUDA QMoE now validates contraction-dimension divisibility, and the duplicate dtype entry is removed. I also rechecked the cumulative packing, projection-width, and GPT-OSS decode/requantize paths. Local validation passed with 1260 builder tests and 5 GPT-OSS loader tests; high-signal Ruff checks, diff checks, and all current CI checks are green.

@jiafatom
David Fan (jiafatom) merged commit f965a95 into main Sep 28, 2026
65 checks passed
@jiafatom
David Fan (jiafatom) deleted the jiafa/add-mixed-width-qmoe branch September 28, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants