{{ message }}
Add CPU QMoE 2-bit support and LUT GEMM fast path#28185
Draft
Add CPU QMoE 2-bit support and LUT GEMM fast path#28185
Conversation
…nto tlwu/qmoe_2bit_cpu
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.

PR: Add CPU QMoE 2-bit support and LUT GEMM fast path
Description
This PR adds
expert_weight_bits=2support to the CPU QMoE operator and introduces a fast path for supported block-wise shapes using MLAS LUT GEMM. It also tightens CPU-side validation, expands test coverage for non-trivial 2-bit behavior, and adds implementation notes for the CPU QMoE kernel.Summary of Changes
CPU QMoE Kernel
onnxruntime/contrib_ops/cpu/moe/moe_quantization_cpu.cconnxruntime/contrib_ops/cpu/moe/moe_quantization_cpu.honnxruntime/contrib_ops/cpu/moe/moe_helper.hhidden_size % pack_size == 0and inferredinter_sizedivisibility checks.Schema and Documentation
onnxruntime/core/graph/contrib_ops/contrib_defs.ccdocs/contrib_ops/cpu/qmoe.mdTests
onnxruntime/test/contrib_ops/moe_test.cconnxruntime/test/python/transformers/test_qmoe_cpu.pyTesting
ninja -C build/cu128/Release CMakeFiles/onnxruntime_providers.dir/home/tlwu/git/onnxruntime/onnxruntime/contrib_ops/cpu/moe/moe_quantization_cpu.cc.oninja -C build/cu128/Release CMakeFiles/onnxruntime_provider_test.dir/home/tlwu/git/onnxruntime/onnxruntime/test/contrib_ops/moe_test.cc.oMoETestsuite here.Motivation and Context
This work addresses CPU-provider support for QMoE 2-bit expert weights, matching the issue request for QMoE 2 bits on CPU. The PR also aligns the CPU implementation with how MLAS currently exposes optimized 2-bit execution: block-wise 2-bit shapes can use LUT GEMM, while unsupported shapes continue to use dequantize-plus-GEMM fallback paths.
Checklist