Repository navigation
[PERF] gfx942 FMoE: a16 kernel dispatch for GLM-5 decode (T=16-256) - #4558
Merged
Merged
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
valarLip
approved these changes
Aug 7, 2026
Route GLM-5/DeepSeek-V3 decode token counts 16-256 to faster a16 (bf16 activation) kernels on MI300X (304 CUs, E=257, topk=9). Kernel routing: T=16 → emsort_16x128_pf3 (flat_mode=2): 123.6us vs 131.7us (6% faster) T=32 → a16_16x256: 193.0us vs 197.5us (2% faster) T=64 → a16_16x256: 253.7us vs 260.3us (3% faster) T=128 → a16_ps_16x256: 285.3us vs 284.8us (neutral) T=256 → a16_ps_16x256: 299.1us vs 299.7us (neutral) Changes: - Add int flat_mode to C++ dispatch (replaces bool is_flat_dispatch) to distinguish flat(1) from emsort(2) persistent grid modes - Fix Python cfg_flat to preserve int value instead of bool coercion - Add flat_mode parameter to fmoe_fp8_blockscale_g1u1 torch op - Register a16 kernels (16x128_pf3, 16x256, ps_16x256, emsort) in kernel config CSVs with corresponding .co files - Update GLM5 model config with benchmarked optimal kernel per token
The assert guarded flat kernels to gfx950-only, but gfx942 flat kernels are now available and tested.
alexioslyrakis-amd
force-pushed
the
alyr/gfx942-fmoe-optimal-pr
branch
from
August 7, 2026 12:28
03d4293 to
68aca62
Compare
This was referenced Aug 8, 2026
1 of 4 tasks
2 tasks
alexioslyrakis-amd
added a commit
that referenced
this pull request
Aug 11, 2026
Both Python and C++ read cfg.flat directly from the config, so passing flat_mode as a parameter was redundant. The AITER_CHECK(cfg.flat == flat_mode) added in PR #4558 caused a crash on gfx950 because fmoe_g1u1 was never wired up to pass it. Remove flat_mode from get_heuristic_kernel, fmoe_g1u1, and fmoe_fp8_blockscale_g1u1. Hardcode cfg.flat == 0 in the heuristic filter to exclude flat kernels (they are always dispatched by explicit kernel name from the tuned config CSV).
valarLip
pushed a commit
that referenced
this pull request
Aug 11, 2026
* [fix][fmoe] propagate flat_mode through fmoe_g1u1 dispatch PR #4558 added flat_mode to get_heuristic_kernel() and fmoe_fp8_blockscale_g1u1 but missed fmoe_g1u1. On gfx950, when the tuned config selects a flat kernel for the xbf16 MXFP4 path (e.g. Qwen3.5-397B), fmoe_g1u1 calls get_heuristic_kernel with the default flat_mode=0, triggering the AITER_CHECK(cfg.flat == flat_mode) assertion. Add int flat_mode to the fmoe_g1u1 C++ entrypoint and Python stub, and forward it from fused_moe_1stage. * [fix][fmoe] remove redundant flat_mode parameter from FMoE dispatch Both Python and C++ read cfg.flat directly from the config, so passing flat_mode as a parameter was redundant. The AITER_CHECK(cfg.flat == flat_mode) added in PR #4558 caused a crash on gfx950 because fmoe_g1u1 was never wired up to pass it. Remove flat_mode from get_heuristic_kernel, fmoe_g1u1, and fmoe_fp8_blockscale_g1u1. Hardcode cfg.flat == 0 in the heuristic filter to exclude flat kernels (they are always dispatched by explicit kernel name from the tuned config CSV).
5 of 6 tasks
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
int flat_modeto C++ dispatch chain, replacingbool is_flat_dispatch, to support emsort persistent grid (flat_mode=2) alongside flat one-token-per-TG (flat_mode=1)cfg_flatto preserve int value instead ofbool()coercion that collapsed flat=2 → 1Performance (E=257, topk=9, shared-expert, 304 CUs)
All accuracy within acceptable range (logits_diff ~1.4e-4).
Test plan
python op_tests/test_moe_2stage.py -e 256 -k 8 --shared-expert -t 16 32 64 128 256 -q 50on MI300X (304 CUs)