Repository navigation
Add mixed-width INT2/INT4 QMoE builder support - #2624
Conversation
There was a problem hiding this comment.
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
Open (5)
No-op INT4 projection overrides are incorrectly rejected · New Unsupported unsigned projection descriptors are accepted · New Decoder method is implemented outside the Model class · New QMoE quantization helper improperly uses a staticmethod · New QMoE quantization helper uses a prohibited private method name · New
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.
18ed9df to
553bc9a
Compare
Tianlei Wu (tianleiwu)
left a comment
There was a problem hiding this comment.
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.
Tianlei Wu (tianleiwu)
left a comment
There was a problem hiding this comment.
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.


Summary
quant_config.moe.fc1_type/fc2_typeoverrides for mixed-width QMoE exportINT2 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 skippedacross quant config, QMoE weights, and GPT-OSS loader testsgit diff --check upstream/main...HEADpassesThe skipped tests require standalone QMoE/CUDA pack pybind exports that are not available in the local wheel.