AMD Engineers Profile a VALU-Bound MoE Kernel on MI300X and Replace Its Arithmetic Decode with a Bit Lookup
AMD's FlyDSL team documents how they traced a 2.2×–2.4× MoE GEMM slowdown on MI300X to software E2M1→bf16 weight decoding, then replaced it with a v_perm_b32 byte lookup table. The article walks through a four-step profiling pipeline—GPU kernel time, SQ hardware counters, advanced thread trace, and FlyDSL source-line tables—and shows that the decode is a fixed bit pattern, not arithmetic, because all 16 E2M1 values are exactly representable in bf16.
The AMD Instinct MI300X (gfx942, CDNA 3) has no hardware instruction to convert MXFP4 weights to bf16. That conversion arrives with CDNA 4 in the MI350 series. Serving a mixture-of-experts model like gpt-oss with MXFP4 (E2M1) weights on MI300X therefore requires every 4-bit weight to be decoded in software before it can feed a matrix core. Four AMD engineers—Menghsuan Yang, Felix Li, Clement Lin, and Chunhung Wang—documented what that software decode costs and how to eliminate it.
Their profiling pipeline proceeds in four narrowing layers. First, GPU kernel time from rocprofv3 --kernel-trace identifies which stage dominates and how it scales with token count, avoiding host-side timer noise at small batches. Second, SQ hardware counters collected in separate passes reveal what the waves spend their cycles on: the ratio of non-MFMA VALU instructions per MFMA, the VALU share of issue cycles, and three wave-time ratios (executing, ready-but-waiting-to-issue, waiting-on-a-dependency). Third, advanced thread trace (ATT) on a single CU records every instruction executed, its hit count, and its cycle contribution. Fourth, rebuilding the kernels with FLYDSL_DEBUG_ENABLE_DEBUG_INFO=1 produces a DWARF line table that maps each instruction address back to the Python source line that emitted it.
The counters showed the bottleneck clearly. In the software-decode path, every MFMA is accompanied by 36 to 80 other vector instructions. VALU takes 93–98% of the cycles in which waves issue anything; memory and LDS instructions together account for at most 2.7%. Waves spend 77–90% of their lifetime either issuing or ready to issue, and only 10–23% waiting on a dependency. The profile is VALU-issue-bound, not memory-bound. The ATT instruction mix confirmed it: at 2048 tokens, VALU instructions other than MFMA constitute 91% of GEMM1 instructions and 86% of its cycles, while MFMA itself is 2–3% of instructions and about 1% of cycles. Seven instructions—shifts, compares, packed multiplies, bit-field extracts, and/or, NaN checks, and three-way adds—account for 60% of all GEMM1 cycles.