Repository navigation
[CK] [FlyDSL] Optimize MI308 MoE Down kernels and add BF16 support (2/3) - #5932
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Three unresolved critical findings concern compact task-buffer sizing and out-of-range quantization accesses.
Review effort: Lite
Findings: 3
Open (3)
What changed in this PR
Optimizes gfx942 FlyDSL MoE Down kernels and adds BF16 dispatch support, with refreshed tuning configurations.
Changes:
- Adds specialized Down kernels and compact GPU task scheduling.
- Enables BF16 default-kernel dispatch and validation.
- Updates quantization, reduction helpers, and model tuning CSVs.
| File | Summary |
|---|---|
csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py |
Adds BF16 tuning filters. |
aiter/ops/flydsl/kernels/moe_gemm_2stage/quant.py |
Adds quantization helpers; critical out-of-range atom accesses remain unresolved. |
aiter/ops/flydsl/kernels/moe_gemm_2stage/moe_reduce.py |
Adds stride-aware reduction helpers. |
aiter/ops/flydsl/kernels/moe_gemm_2stage/gemm2.py |
Adds default Down and BF16 support. |
aiter/ops/flydsl/kernels/moe_gemm_2stage/gemm2_common.py |
Adds specialized kernel primitives. |
aiter/ops/flydsl/kernels/moe_gemm_2stage/gemm2_8x1_compact.py |
Adds compact task tables; allocator and builder policies remain mismatched. |
aiter/ops/flydsl/kernels/moe_gemm_2stage/__init__.py |
Exposes kernel APIs. |
aiter/ops/flydsl/kernels/moe_gemm_2stage_gfx942_utils.py |
Updates gfx942 utilities. |
aiter/ops/flydsl/fused_moe_gfx942.py |
Integrates dispatch and BF16 validation. |
aiter/configs/model_configs/qwen3_5_397b_fp8_ptpc_tuned_fmoe.csv |
Refreshes Qwen 397B FP8 tuning. |
aiter/configs/model_configs/qwen3_5_35b_fp8_ptpc_tuned_fmoe.csv |
Refreshes Qwen 35B FP8 tuning. |
aiter/configs/model_configs/qwen3_5_125b_fp8_ptpc_untuned_fmoe.csv |
Adds Qwen 125B FP8 untuned configurations. |
aiter/configs/model_configs/qwen3_5_125b_fp8_ptpc_tuned_fmoe.csv |
Adds Qwen 125B FP8 tuned results. |
aiter/configs/model_configs/qwen3_5_125b_bf16_untuned_fmoe.csv |
Adds Qwen 125B BF16 untuned configurations. |
aiter/configs/model_configs/qwen3_5_125b_bf16_tuned_fmoe.csv |
Adds Qwen 125B BF16 tuned results. |
aiter/configs/model_configs/minimax_m3_fp8_ptpc_tuned_fmoe.csv |
Refreshes MiniMax FP8 tuning. |
aiter/configs/model_configs/hunyuan3_fp8_per_tensor_tuned_fmoe.csv |
Refreshes Hunyuan FP8 tuning. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
The new whole-MoE FlyDSL configs all use cu_num=80, so _iter_csv_cases() filters them out on the default MI300X/MI35X CI runners. Passing CI therefore does not validate these paths. Please add automated MI308 numerical regression coverage, including compact-task split thresholds, empty/single-expert cases, E=2048, capacity limits, topology changes, and padded reduction. The existing local checks should be preserved as repeatable regression tests. |
1, compatible old csv format string 2, cu_count as a runtime arg 3, tail_capacity as a parameter for compact_m64_tasks 4, add test
…lvm.target_features` to workaround `target-features:-packed-fp32-ops`; fix cross-group lds race condition without correct `s_waitcnt lgkmcnt`
Added
|


Summary
Part 2/3, follows #5795 (PR1, merged). Optimize FP8 MoE Down projection on MI308X/gfx942 and enable BF16 whole-MoE dispatch through the existing default kernels.
Changes
1x4_64x256and8x1_compact. Compact dispatch builds M256 full tasks and M64 tail tasks on the GPU without host readback.QuantType.No) support batch1, fixed BN64 decode and default prefill. BF16 tile/LDS limits are checked before compilation, specialized Down stays FP8-only, and unsupported BF16 configs are filtered during tuning.kernels/moe_gemm_2stage/gfx9_fp8/are grouped by wave layout:gemm2_1x4.py(four-wave M64×N256),gemm2_8x1.pyandgemm2_8x1_compact.py(eight-wave and compact). Shared helpers live incommon.py;gemm2.pykeeps main's Down kernels and only adds thedown_pathdispatch.Performance
MI308X/gfx942 (80 CUs, PTL format:VECTOR,F8), ROCm 7.2.4, FlyDSL 0.3.4.1, default MoE sorting,
AITER_FLYDSL_MOE_BF16_RTA_SIMPLIFIED=1. Values are the per-shape GPU kernel-time sums that--run_configreports (10 warmups, 51 iterations, rotating inputs, IQR filtering); Down and aux split the same trace by kernel. Each value is the geometric mean over shapes of the median of three alternating-order rounds; negative means faster.Tuning. Main (
42e87267a838, includes #5795) and this PR were tuned on the same shapes from empty CSVs with every kernel family available on gfx942 (TUNE_ONLY=flydslv2,cktile,flydsl,asm), except ASM stage1 (AITER_FMOE_TUNE_EXCLUDE_KERNELS=fmoe_stage1). Several ASM stage1 kernels return NaN or wrong results end to end when device memory is not zeroed; #3987 traced one to padded sorted rows left unwritten. Known cases (prefixfmoe_stage1_bf16_pertokenFp8_g1u1_, NaN-filled memory, E=513 shapes):16x64_5tg_pf3(#3987),16x128_4tg_pf2/pf3,32x64_4tg_pf2/pf3,32x128_3tg_pf2/pf3,64x64_2tg_pf3and64x128_2tg_pf2/pf3. ASM 1-stage stays in the search. After the last eight-wave Down change (no register spills up to inter_dim 640), the whole-MoE stage (--e2e_tune) was re-run for the Qwen3.5-35B (inter_dim 512) and Qwen3.8-Flash-Next (inter_dim 640) FP8 PTPC shapes; a changed selection was kept only if it won all six paired timings against the previous one (six rows).New Down kernels. On the shapes where this PR selects them:
"Shapes" counts these shapes against all tuned shapes of the model and "Batch" is their token range: the new Down kernels target large batches (512 tokens and up), while smaller batches keep decode, CK or ASM 1-stage kernels. "Aux" covers compact task construction, inverse routing and sorted reduction.
¹ Main ships no Qwen3.8-Flash-Next config; for this row main was tuned on the same shapes.
² Excludes the two shapes where main selects ASM 1-stage, which has no separate Down kernel.
New Qwen3.8-Flash-Next configs. Main ships none and runs its untuned defaults (CK 2-stage for BF16, mostly ASM 1-stage for FP8). Against main as shipped, the new configs cut MoE latency by 29.35% for BF16 and 16.63% for FP8 PTPC (geometric mean over 48 shapes each).
Reproduce (MI308X, gfx942, 80 CUs)
Run the same commands on main (
42e87267a838) and on this PR. Main lacks the twoqwen38_flash_next_*_untuned_fmoe.csvfiles; copy them from this PR.Main as shipped for Qwen3.8-Flash-Next: on main, run
python3 $T $a --run_config(no CSV, untuned defaults) for both precisions.Testing (this PR):
Co-authors: [email protected]