feat: add INT8/INT4 quantization support for 2-stage ASM MoE kernels#2340
Open
feat: add INT8/INT4 quantization support for 2-stage ASM MoE kernels#2340
Conversation
…_2stage Old .co files expect the legacy KernelArgs size (up to ptr_SW + padding) and gdy = sub_X_cnt. The extended args (total_tgs, ps_deno, ptr_Qscl, ptr_Qzero, eLQQs) and gdy = sz_stp are only used by multix kernels. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: root <root@hjbog-srdc-24.amd.com>
The 1-stage g1u0 int8 smoothquant path was using moe_smoothquant_fwd with 3D tensor shapes (topk, M, model_dim), causing GPU memory access fault when passed to fmoe_int8_g1u0 which expects 2D input. Align with main branch behavior by using smooth_per_token_scaled_quant for all int8 smoothquant cases, with shape adjusted per 1-stage (2D) vs 2-stage (3D). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In expert parallelism mode, moe_smoothquant_fwd crashes with a GPU memory access fault because local_expert_hash remaps masked experts to -1, which causes out-of-bounds indexing into fc1_smooth_scale. Use smooth_per_token_scaled_quant instead, which safely handles expert mapping via smooth_scale_map_hash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Add INT8 per-token and INT4 (LQQ) quantization support for the 2-stage ASM MoE pipeline.
Changes
aiter/fused_moe_bf16_asm.py: Addasm_moe_stage2()wrapper, 2-stage ASM MoE pipeline with INT8/INT4 support, CSV-based kernel config lookup via pandas, refactored_run_asm_moe_a16()helpercsrc/py_itfs_cu/asm_moe_2stage.cu: AddKernel2Argsstruct for stage2 kernels, INT8/INT4 kernel launch paths with splitk support, new fields (total_tgs,ps_deno,ptr_Qscl,ptr_Qzero,eLQQs)csrc/include/moe_op.h: Addmoe_stage2_g1u1declarationcsrc/include/rocm_ops.hpp: Add INT8/INT4 MoE bindingsaiter/ops/moe_op.py: Registermoe_stage2_g1u1op.cokernels: Stage1 and stage2 binaries for INT8 per-token and INT4 LQQ quantization (gfx942, various tile sizes: 32x128 to 80x128)op_tests/test_moe_ep.py: Add INT8/FP8 smoothquant EP test casessmooth_per_token_scaled_quantfor both INT8 and FP8 smoothquant paths in EP mode.cokernel loading inasm_moe_2stageTest plan
test_moe_ep.pyINT8 smoothquant teststest_moe_ep.pyFP8 smoothquant tests