QMoE CUDA: Rename build options, refactor PrePack, add GPU kernels#28583
Open
tianleiwu wants to merge 3 commits into
Open
QMoE CUDA: Rename build options, refactor PrePack, add GPU kernels#28583tianleiwu wants to merge 3 commits into
tianleiwu wants to merge 3 commits into
Conversation
Rename cmake options to match the onnxruntime_USE_* naming convention: - onnxruntime_ENABLE_CUDA_FP4_QMOE -> onnxruntime_USE_FP4_QMOE - onnxruntime_ENABLE_CUDA_FP8_QMOE -> onnxruntime_USE_FP8_QMOE Also rename the corresponding C preprocessor defines: - ENABLE_CUDA_FP4_QMOE -> USE_FP4_QMOE - ENABLE_CUDA_FP8_QMOE -> USE_FP8_QMOE Fix CodeQL empty-except warning in test_qmoe_cuda.py by adding an explanatory comment and removing unused exception variable.
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.
Description
Follow-up refinements to QMoE CUDA EP (#28467): rename build options for consistency, fix CodeQL warnings, refactor
PrePackfrom nested lambdas into named helper methods, and replace CPU data-transformation loops with GPU kernels.Motivation and Context
PR #28467 introduced the QMoE operator with a 373-line
PrePackfunction containing 5 nested lambdas that performed weight/scale prepacking at model load time. Reviewer feedback requested:onnxruntime_ENABLE_CUDA_*cmake options toonnxruntime_USE_*for naming consistency.Key Changes
594642aENABLE_CUDA_FP4_QMOE→USE_FP4_QMOE,ENABLE_CUDA_FP8_QMOE→USE_FP8_QMOEin cmake, C++ defines, and 340+ generated .cu files594642atest_qmoe_cuda.pye8d364bPrePackTransposeAndPack,PrePackCopyToGpu,PrePackSwizzleBlockScales,PrePackRepackFP4Weights,PrePackComputeBiase8d364bQMoERepackFP4ColToRowKernel— repacks column-major FP4 packed weights to row-major on GPU (replaces per-expert CPU loop)e8d364bPrePackSwizzleBlockScalesnow calls existingLaunchQMoEBlockScaleInterleaveGPU kernel (replaces CPUSwizzleMXFPXBlockScalesToGpuloop)Impact
PrePackruns once duringInferenceSession::Initialize(), not on the inference hot path.Testing
onnxruntime_USE_FP4_QMOE=ON onnxruntime_USE_FP8_QMOE=ON(CUDA 13.0, SM90).libonnxruntime_providers_cuda.sovianm.test_qmoe_fp4_cuda.py,test_qmoe_wfp4afp8_cuda.py,test_qmoe_cuda.pycover the affected code paths.