Bringing MXFP4 MoE to AMD Instinct MI300 Series GPUs with FlyDSL Replacing the software MXFP4 weight decode in AITER's `moe_2stage_a16wmix` MoE GEMM kernels with a bit-exact `v_perm_b32` byte lookup table from ROCm/aiter#5583 makes GEMM1 2.2×–2.4× and GEMM2 1.7×–2.5× faster on the AMD Instinct MI300X (gfx942) than a reference software decode with the same tiles, from 1 to 8192 tokens, AMD reports. Profiling with rocprofv3 SQ counters showed the kernels are limited by VALU issue rather than memory stalls, because CDNA 3 has no hardware MXFP4-to-bf16 convert instruction (CDNA 4's gfx950 adds `v_cvt_scalef32_pk_bf16_fp4`), so every 4-bit E2M1 weight must be decoded in software before feeding a matrix core. The nonzero decoded bf16 weights are bit-identical for every e8m0 scale up to 0xFC, per the FlyDSL-based AITER implementation measured on shapes of E=896, model_dim=3584, inter_dim=384 and topk=16. Bringing MXFP4 MoE to AMD Instinct MI300 Series GPUs with FlyDSL bringing-mxfp4-moe-to-amd-instinct-mi300-series-gpus-with-flydsl The AMD CDNA™ 3 architecture of the AMD Instinct™ MI300 Series reached the market in December 2023, two months after the Open Compute Project OCP released the Microscaling MX Formats specification v1.0 https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf \ 1\ gfx942-moe-mxfp4-ref-1 , which defines MXFP4. Hardware support for MX formats came with the next generation: AMD CDNA™ 4 in the AMD Instinct™ MI350 Series gfx950, 2025 converts MXFP4 weights to bf16 with a single instruction, v cvt scalef32 pk bf16 fp4 , and CDNA 3 GPUs such as the MI300X gfx942 have no such instruction. Serving a mixture-of-experts MoE model with MXFP4 E2M1 weights, such as gpt-oss, on gfx942 with bf16 activations therefore needs every 4-bit weight decoded in software before it can feed a matrix core. This post measures what that decode costs in moe 2stage a16wmix , the MoE GEMM kernels that AITER https://github.com/ROCm/aiter the AMD AI Tensor Engine for ROCm™ \ 2\ gfx942-moe-mxfp4-ref-2 implements in FlyDSL https://github.com/ROCm/FlyDSL \ 3\ gfx942-moe-mxfp4-ref-3 , a Python domain-specific language for GPU kernels on ROCm. SQ counters read with rocprofv3 https://rocm.docs.amd.com/projects/rocprofiler-sdk/en/latest/how-to/using-rocprofv3.html \ 4\ gfx942-moe-mxfp4-ref-4 show that the waves are limited by VALU issue rather than by waiting on memory. Advanced thread trace ATT https://rocm.docs.amd.com/projects/rocprofiler-sdk/en/latest/how-to/using-thread-trace.html \ 5\ gfx942-moe-mxfp4-ref-5 shows which instructions take those cycles. FlyDSL source-line tables tie those instructions to the Python lines that decode the weights, allowing us to follow the decoding code from FlyDSL to the compiled ISA. Replacing that decode with a bit-exact v perm b32 byte lookup table LUT from ROCm/aiter 5583 https://github.com/ROCm/aiter/pull/5583 \ 6\ gfx942-moe-mxfp4-ref-6 makes GEMM1 2.2×–2.4× and GEMM2 1.7×–2.5× faster on MI300X than a reference software decode with the same tiles, from 1 to 8192 tokens \ a\ gfx942-moe-mxfp4-endnote-a , and the nonzero decoded bf16 weights are bit-identical for every e8m0 scale up to 0xFC . The a16wmix Kernels the-a16wmix-kernels moe 2stage a16wmix is a two-stage MoE GEMM: gate/up GEMM1 then down GEMM2 , bf16 activations × MXFP4 weights, with the gated activation fused into the stage-1 epilogue. The measurements here use SwiGLU in the form gpt-oss uses: clamp gate, max = 7 · σ 1.702 · gate · clamp up, −7, 7 + 1 . MXFP4 stores each weight as a 4-bit E2M1 code and shares one e8m0 scale per group of 32 weights. An e8m0 byte e encodes 2^ e − 127 , and 0xFF is NaN OCP MX specification https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf . Both stages load packed nibbles through upconvert b , a FlyDSL helper function in AITER moe 2stage a16wmix/utils.py that GEMM1 and GEMM2 share. On gfx950 that helper uses the hardware convert; on gfx942 it must synthesize the bf16 values itself. Two terms recur below. BM is the number of sorted token rows that one workgroup tile covers 16 or 32 here . A K32 step is one 32-element slice along the reduction dimension; gfx942 has no K=32 bf16 MFMA, so each K32 step of a 16-row block takes two 16×16×16 bf16 MFMAs \ 7\ gfx942-moe-mxfp4-ref-7 . Shapes below use E=896, model dim=3584, inter dim=384, topk=16 unless noted — a per-GPU shard of a wide MoE at TP=8. Profiling the Reference Software Decode profiling-the-reference-software-decode We profiled GEMM1 and GEMM2 on one MI300X with rocprofv3 in three layers, each narrower than the last: 1. Kernel time --kernel-trace , from GPU timestamps rather than host wall clock, to see which stage dominates and how it scales with tokens. At small token counts, host overhead and run-to-run variance can swamp a host-side timer. 2. SQ hardware counters --pmc , to see what the waves spend their cycles on. 3. Advanced thread trace ATT, --att on one CU, to see which instructions those cycles belong to. A fourth step leaves the profiler: FlyDSL source-line tables tie each of those instructions to the Python line that produced it Mapping the Instructions Back to FlyDSL Lines gfx942-moe-mxfp4-s1-4 . Kernel time covers seven token counts from 1 to 8192 Kernel Time on MI300X gfx942-moe-mxfp4-s3-4 . Counters and ATT use two of them: a decode batch of 8 tokens BM=16 and a prefill batch of 2048 tokens BM=32 . All measurements use upstream AITER. Before 5583 , the FlyDSL MoE kernels in AITER did not support MXFP4 weights on gfx942. The first version we wrote while adding that support decoded the weights in software Root Cause: The Software E2M1→bf16 Decode gfx942-moe-mxfp4-s2 ; it was never merged, and 5583 shipped the LUT instead. To measure what the LUT removes, we put that software decode back at the same upconvert b call site in the 5583 merge commit baef8156a \ a\ gfx942-moe-mxfp4-endnote-a . Counters That Locate the Limiter counters-that-locate-the-limiter All of these are SQ counters that rocprofv3 exposes on gfx942, and each metric is a ratio between two counters of the same kernel. Counters that cannot be collected together go into separate passes, so each ratio uses the median of each counter over its own pass. | Metric | Counters | What it answers | |---|---|---| | VALU per MFMA | SQ INSTS VALU − SQ INSTS MFMA / SQ INSTS MFMA | How much non-matrix vector work is issued for every matrix instruction | | VALU share of issue | SQ ACTIVE INST VALU / SQ ACTIVE INST ANY | Of the cycles waves spend on instructions, how many are VALU | | VMEM / LDS share of issue | SQ ACTIVE INST VMEM , SQ ACTIVE INST LDS , each over SQ ACTIVE INST ANY | Whether memory instructions, rather than ALU work, take the issue cycles | | Wave time ratios | SQ ACTIVE INST ANY , SQ WAIT INST ANY , SQ WAIT ANY , each over SQ WAVE CYCLES | How much of its lifetime a wave spends issuing, ready but waiting to issue, or waiting on a dependency such as an outstanding load or a barrier | Table 1. The SQ counter ratios used in this post. SQ INSTS VALU includes MFMA instructions. Its ratio to SQ INSTS MFMA , 73.0 for software GEMM1 at 8 tokens, matches the ratio of all VALU instructions MFMA included to MFMA that ATT counts on the traced CU, so the first row subtracts SQ INSTS MFMA . The two ratios agree within 0.1% for every dispatch we traced, which also shows that the single CU ATT traces runs the same instruction mix as the whole GPU. rocprofv3 ships the three wave time ratios as derived metrics: WaveExec , WaveIssueWait , and WaveDepWait . What the Counters Showed what-the-counters-showed Table 2 lists the counters for the software-decode path. Each value is the median over five dispatches, collected in four counter passes. | Software decode | GEMM1, 8 tokens | GEMM2, 8 tokens | GEMM1, 2048 tokens | GEMM2, 2048 tokens | |---|---|---|---|---| | VALU per MFMA | 72.0 | 79.5 | 35.8 | 40.9 | | VALU share of issue | 97.4% | 95.7% | 98.4% | 93.4% | | VMEM / LDS share of issue | 0.3% / 1.5% | 0.4% / 0.7% | 0.4% / 0.8% | 0.6% / 2.1% | | Wave time issuing WaveExec | 45% | 38% | 30% | 50% | | Wave time ready but waiting to issue WaveIssueWait | 32% | 49% | 60% | 28% | | Wave time waiting on a dependency WaveDepWait | 22% | 13% | 10% | 21% | Table 2. SQ counters for the software-decode GEMMs on MI300X \ a\ gfx942-moe-mxfp4-endnote-a . The three wave time ratios come from separate counter passes, so they need not sum to exactly 100%. Three things stand out: - For every MFMA, the software path issues 36 to 80 other vector instructions. Decode work is per weight while MFMA work grows with the rows in a block, so BM=32 at 2048 tokens halves the ratio, but it stays high. - VALU takes 93–98% of the cycles in which waves issue anything. Memory and LDS instructions together take at most 2.7%. - Waves spend 77–90% of their time either issuing or ready to issue, and only 10–23% waiting on a dependency such as an outstanding load or a barrier. With almost every issue cycle going to VALU, the slot a ready wave waits for is almost always a VALU slot. That points at VALU issue, not at waiting on memory. After the Fix: Counters and Thread Trace gfx942-moe-mxfp4-s3-3 adds a direct check: the LUT leaves the memory work and the time spent waiting on it unchanged, yet kernel time is reduced by a factor of 2.2. The counters cannot say which VALU instructions are the problem; ATT can. What the Thread Trace Showed what-the-thread-trace-showed ATT records every instruction that the waves on one CU CU 1 of shader engine 0 execute in one dispatch, with how often each instruction ran and how many cycles it accounted for. Table 3 groups the software-decode GEMMs at 2048 tokens by instruction class. | Instruction class | GEMM1 instructions | GEMM1 cycles | GEMM2 instructions | GEMM2 cycles | |---|---|---|---|---| | MFMA v mfma f32 16x16x16 bf16 | 2.5% | 1.1% | 2.2% | 1.3% | | Compare / select v cmp , v cndmask | 22.3% | 21.2% | 27.0% | 23.0% | | Other VALU shifts, bit-field extracts, masks, integer adds, f32 multiplies | 66.0% | 62.7% | 60.3% | 50.8% | | v perm b32 | 2.5% | 2.4% | 2.3% | 2.1% | | s waitcnt | 0.5% | 5.5% | 1.3% | 14.4% | | s nop | 4.9% | 2.3% | 1.5% | 1.0% | | VMEM and LDS | 0.8% | 0.7% | 1.7% | 2.3% | | Scalar, branch, and other including s barrier | 0.4% | 4.2% | 3.8% | 5.0% | Table 3. ATT instruction mix of the software-decode GEMMs at 2048 tokens on one MI300X CU \ a\ gfx942-moe-mxfp4-endnote-a . “Cycles” is the per-instruction latency that ATT reports, summed over all executions and waves. Waves overlap in time, so these are shares of wave-cycles on that CU, not of kernel time. s barrier alone is 4.0% of GEMM1 cycles and 3.1% of GEMM2 cycles. Table 3 shows that the cycles go to VALU work: VALU instructions other than MFMA compare/select, other VALU, and v perm b32 are 91% of the instructions in software GEMM1 at 2048 tokens and 86% of its cycles, and 90% and 76% in GEMM2, while MFMA is 2–3% of the instructions and about 1% of the cycles. Within those VALU cycles, seven instructions take 60% of all GEMM1 cycles: v lshlrev b32 17% , v cmp eq u32 10% , v pk mul f32 9% , v bfe u32 7% , v and or b32 6% , v cmp u f32 5.5% , and v add3 u32 5% . v cmp u f32 alone executes 216,000 times on the traced CU in one GEMM1 dispatch, counting both of its encodings. The 8-token dispatches show the same picture: MFMA is 1.3% of software GEMM1 instructions and 0.8% of its cycles, while compare/select is 23% and 18%. The counters and ATT say what the waves issue, but not yet which code it belongs to. Shifts, masks, compares, and f32 multiplies could just as well come from address arithmetic, the scale loads, or the SwiGLU epilogue. Mapping the Instructions Back to FlyDSL Lines mapping-the-instructions-back-to-flydsl-lines ATT reports each instruction by its address in the kernel. To tie those addresses to FlyDSL source, we rebuilt the same kernels with FlyDSL source-line tables. With FLYDSL DEBUG ENABLE DEBUG INFO=1 , FlyDSL records the Python file and line of every operation it emits and passes them to the compiler as a DWARF line table. FLYDSL DUMP IR=1 dumps the compilation stages, and the ISA built from them puts a .loc directive with that file and line before each instruction. The rebuilt GEMM1 at 2048 tokens has the same 70,642 instructions, in the same order, as the kernel ATT traced for Table 3, and the same holds for every kernel in Table 4 \ a\ gfx942-moe-mxfp4-endnote-a . Each row of the ATT listing can therefore be labeled with the FlyDSL line that produced it. Table 4 groups the rows by the FlyDSL function those lines belong to. | FlyDSL source of the instruction | GEMM1, 8 tokens | GEMM2, 8 tokens | GEMM1, 2048 tokens | GEMM2, 2048 tokens | |---|---|---|---|---| | Weight decode fp4 nibble to bf16x8 sw | 93.1% / 73.4% | 90.1% / 66.8% | 92.3% / 80.5% | 84.5% / 69.3% | | MFMA and operand packing | 3.5% / 2.8% | 3.8% / 3.1% | 4.8% / 3.3% | 5.0% / 5.4% | | Weight and scale loads | 1.0% / 11.2% | 1.2% / 7.9% | 0.8% / 3.3% | 1.3% / 4.1% | | Activation tile: global memory → LDS → registers | 0.6% / 8.0% | 0.4% / 3.1% | 0.6% / 4.5% | 1.3% / 6.4% | | Epilogue: SwiGLU GEMM1 , weighted atomic store GEMM2 | 0.2% / 0.1% | 0.6% / 0.8% | 0.4% / 0.1% | 3.1% / 5.0% | | Indexing, barriers, and other | 1.6% / 4.5% | 3.8% / 18.3% | 1.1% / 8.2% | 4.8% / 9.8% | Table 4. Software decode: share of executed instructions / share of ATT cycles by FlyDSL function, on one MI300X CU \ a\ gfx942-moe-mxfp4-endnote-a . Executed instructions are ATT hit counts; cycles are as in Table 3. “Weight and scale loads” includes the e8m0→f32 scale conversion. The weight decode helper, fp4 nibble to bf16x8 sw , issues 85–93% of the executed instructions and takes 67–81% of the cycles, in both GEMMs and at both token counts. Of the 72.0 non-MFMA VALU instructions per MFMA in GEMM1 at 8 tokens Table 2 , 69.3 come from it, and across the four kernels it supplies 93–96% of that ratio. The matrix work itself, MFMA plus packing its operands, is 3.5–5.0% of the instructions, and no other group issues more than 5%. That ties the VALU-bound profile to the weight decode, and it is why we optimized the dequant first, rather than memory access or tiling. Root Cause: The Software E2M1→bf16 Decode root-cause-the-software-e2m1bf16-decode AMD CDNA 4 gfx950 and later architectures have v cvt scalef32 pk bf16 fp4 , which converts the two FP4 weights in one byte into two bf16 values and multiplies them by an f32 scale in a single instruction; four of them decode the eight weights of a K32 step. The CDNA 3 GPU we ran on gfx942 has no such instruction, so the software decode rebuilds each nibble one FP4 weight as an f32 bit pattern, multiplies it by the group scale, and converts the result to bf16. Figure 1 follows one nibble through those steps. In FlyDSL, abridged, for the eight nibbles j of one packed 32-bit word: for j in range constexpr 8 : n = raw.shrui fx.Int32 4 j & fx.Int32 0xF e = n.shrui fx.Int32 1 & fx.Int32 0x3 mant = n & fx.Int32 0x1 sign = n.shrui fx.Int32 3 & fx.Int32 0x1 normal bits = e + fx.Int32 126 << fx.Int32 23 | mant << fx.Int32 22 sub bits = mant == fx.Int32 1 .select fx.Int32 0x3F000000 , fx.Int32 0 mag bits = e == fx.Int32 0 .select sub bits, normal bits bits = mag bits | sign << fx.Int32 31 v = fx.Float32 raw bits .bitcast T.f32 fx.Float32 scale f32 bf16s.append v.to fx.BFloat16 Figure 2 maps each line of that loop to the gfx942 instructions it compiles to. What the Software Decode Compiles To what-the-software-decode-compiles-to Below is the ISA for the first two weights of software GEMM1 at 8 tokens, from the debug-info build described in Mapping the Instructions Back to FlyDSL Lines gfx942-moe-mxfp4-s1-4 . Each instruction sits under the FlyDSL line that its .loc names. v28 holds eight packed nibbles from the weight load, and v54 holds the f32 scale of the group. The compiler decodes the two nibbles side by side, so most lines produce one instruction per weight. The sign line has no instructions of its own; its shift and mask are folded into the bits = mag bits | sign << 31 line. n = raw.shrui fx.Int32 4 j & fx.Int32 0xF v lshrrev b32 e32 v32, 4, v28 ; j = 1 j = 0 needs no shift e = n.shrui fx.Int32 1 & fx.Int32 0x3 v lshrrev b32 e32 v33, 5, v28 v lshrrev b32 e32 v34, 1, v28 v and b32 e32 v33, 3, v33 v and b32 e32 v34, 3, v34 mant = n & fx.Int32 0x1 v and b32 e32 v32, 1, v32 v and b32 e32 v35, 1, v28 normal bits = e + fx.Int32 126 << fx.Int32 23 | mant << fx.Int32 22 v lshlrev b32 e32 v36, 23, v33 v lshlrev b32 e32 v37, 23, v34 v lshlrev b32 e32 v38, 22, v32 v lshlrev b32 e32 v39, 22, v35 v or b32 e32 v36, v36, v38 v or b32 e32 v37, v37, v39 v add u32 e32 v37, 0.5, v37 ; + 126 << 23 = 0x3F000000, printed as 0.5 v add u32 e32 v36, 0.5, v36 sub bits = mant == fx.Int32 1 .select fx.Int32 0x3F000000 , fx.Int32 0 v cmp eq u32 e64 s 0:1 , 0, v32 v cmp eq u32 e64 s 2:3 , 0, v35 v cndmask b32 e64 v32, 0.5, 0, s 2:3 ; 0.5 is 0x3F000000 again v cndmask b32 e64 v35, 0.5, 0, s 0:1 mag bits = e == fx.Int32 0 .select sub bits, normal bits v cmp eq u32 e64 s 0:1 , 0, v34 v cmp eq u32 e64 s 2:3 , 0, v33 v cndmask b32 e64 v32, v37, v32, s 0:1 v cndmask b32 e64 v33, v36, v35, s 2:3 bits = mag bits | sign << fx.Int32 31 v lshlrev b32 e32 v34, 24, v28 ; nibble bit 3 - bit 31 v lshlrev b32 e32 v35, 28, v28 v and or b32 v33, v34, s27, v33 ; s27 = 0x80000000 v and or b32 v32, v35, s27, v32 v = fx.Float32 raw bits .bitcast T.f32 fx.Float32 scale f32 v pk mul f32 v 32:33 , v 54:55 , v 32:33 op sel hi: 0,1 ; both weights x v54 bf16s.append v.to fx.BFloat16 v bfe u32 v34, v32, 16, 1 ; lowest bit that bf16 keeps v add3 u32 v34, v34, v32, s26 ; + 0x7FFF + that bit: round to nearest even v or b32 e32 v35, 0x400000, v32 ; quiet-NaN pattern v cmp u f32 e64 s 0:1 , v32, v32 ; is v NaN? v cndmask b32 e64 v32, v34, v35, s 0:1 ... ; the same five for the second weight fx.gemm mma atom, acc, bf16 frag4 a8, h , bf16 frag4 b8, h , acc v perm b32 v34, v33, v32, s28 ; s28 = 0x07060302: high halves of v32, v33 - two bf16 That is 38 VALU instructions for two weights, plus the last v perm b32 , which packs the two bf16 results into one register. The line table charges it to the MFMA call mma bf16 rather than to the decode helper, because the packing happens where the MFMA operand is built. Over the whole kernel, the line table puts 69.3 of the 72.0 non-MFMA VALU instructions per MFMA Table 2 in this helper: about 17 per weight, or 139 per K32 step. These are the instructions at the top of Table 3. Shifts v lshlrev b32 build the exponent and sign fields, each select becomes a v cmp eq u32 and v cndmask b32 pair, and the scale multiply becomes v pk mul f32 . The last line hides the most work. gfx942 has no v cvt pk bf16 f32 , so v.to fx.BFloat16 becomes a five-instruction round-to-nearest-even RNE with a NaN check v cmp u f32 . E2M1 has no NaN encoding, so for every e8m0 scale below 0xFF that compare can never fire. By the line table, that one line accounts for 21% of software GEMM1 cycles at 2048 tokens. The Decode Is a Bit Pattern the-decode-is-a-bit-pattern None of that arithmetic is needed. Each weight is a 4-bit FP4 E2M1 code, and the MFMA takes 16-bit bf16 operands, so every weight has to grow from 4 bits to 16. But a 4-bit code has only 16 values, and E2M1, with a 2-bit exponent and a 1-bit mantissa, fits inside bf16, so every one of them is exactly representable. The 16 output bits of every code are therefore known in advance: turning FP4 into bf16 is a table lookup, not a computation. The sign is a single bit, so the table needs only the eight magnitudes in Table 5. The e8m0 scale does not change this: it is a power of two, so for every scale up to 0xFC the scaled value is still exact in bf16 above that, the largest magnitudes overflow, and 0xFF is NaN . | nibble & 7 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | |---|---|---|---|---|---|---|---|---| | value | 0.0 | 0.5 | 1.0 | 1.5 | 2.0 | 3.0 | 4.0 | 6.0 | | bf16 bits | 0x0000 | 0x3F00 | 0x3F80 | 0x3FC0 | 0x4000 | 0x4040 | 0x4080 | 0x40C0 | Table 5. The eight E2M1 magnitudes and their bf16 bit patterns. Across the eight magnitudes, the high bytes take only three distinct values {0x00, 0x3F, 0x40} and the low bytes four {0x00, 0x40, 0x80, 0xC0} , so each half fits an 8-entry byte table indexed by the magnitude. v perm b32 treats its two 32-bit sources as an 8-byte table, and each selector byte from 0 to 7 picks one table byte; selector values 8 and above have special meanings sign replication, 0x00 , 0xFF \ 8\ gfx942-moe-mxfp4-ref-8 . The 3-bit magnitude nibble & 7 is therefore a valid selector, so one v perm b32 returns the four high bytes, and one more the four low bytes, for four nibbles with no compare chain. The sign is bit 3 of each nibble. For the high nibble of a byte it already sits at bit 7, where the bf16 high byte needs it; for the low nibble, a 4-bit shift moves it there. Fix: Bit-Exact v perm b32 LUT aiter 5583 https://github.com/ROCm/aiter/pull/5583 fix-bit-exact-v-perm-b32-lut-aiter-5583 5583 merged 2026-09-22 as baef8156a adds the gfx942 branch of upconvert b . It decodes with: 1. Two 8-entry byte tables, holding the high and low bytes of the eight unsigned bf16 magnitudes, stored as four 32-bit constants. 2. Four v perm b32 lookups that decode the high and low bytes of eight nibbles, and eight more that interleave those bytes into four 32-bit words of bf16 pairs. Masks build the selectors, and one v and or b32 per byte group folds the sign back in. 3. The e8m0 scale, applied by shifting each bf16 into an f32 low halves with a 16-bit shift, high halves with a mask , multiplying, and truncating back to bf16. The scale is a power of two, so the product is exact in bf16 and truncation gives the same bits as round-to-nearest. Figure 3 follows eight weights through these steps. The letters a to h stand for the eight FP4 weights in one 32-bit word, written from bit 31 down to bit 0, so h is element 0 of the K32 step. Each byte of sel even and sel odd is one weight widened to a byte, 0 w , with its sign bit cleared, so it is a table index from 0 to 7. The four FP4 MAG constants in the code below are the two tables. A 32-bit constant holds four table entries with its lowest byte first: FP4 MAG HI LO = 0x3F3F3F00 holds the high bytes 00, 3F, 3F, 3F of magnitudes 0–3, and FP4 MAG HI HI = 0x40404040 those of magnitudes 4–7, while FP4 MAG LO LO and FP4 MAG LO HI hold the low bytes. fp4 perm src hi, src lo, sel is one v perm b32 : src lo supplies table entries 0–3, src hi supplies entries 4–7, and each byte of sel picks one entry for the same byte of the result. With sel even as the selector, one call returns the bf16 high bytes of the four even weights, and a second call their low bytes. The interleave uses the same instruction with constant selectors: 0x05010400 takes byte 0 of src lo , byte 0 of src hi , byte 1 of src lo , and byte 1 of src hi , which puts each low byte next to its high byte. The helper, abridged from aiter/ops/flydsl/kernels/moe 2stage a16wmix/utils.py https://github.com/ROCm/aiter/blob/baef8156aa222809e7aa77801f4b7d064ca94149/aiter/ops/flydsl/kernels/moe 2stage a16wmix/utils.py at baef8156a AITER, MIT License : FP4 MAG HI LO = 0x3F3F3F00 bf16 high bytes for nibble&7 = 0,1,2,3 FP4 MAG HI HI = 0x40404040 bf16 high bytes for nibble&7 = 4,5,6,7 FP4 MAG LO LO = 0xC0800000 bf16 low bytes for nibble&7 = 0,1,2,3 FP4 MAG LO HI = 0xC0804000 bf16 low bytes for nibble&7 = 4,5,6,7 def fp4 mag dwords raw i32 : """Decode 8 FP4 nibbles to 4 dwords, each holding 2 bf16, scale not applied.""" raw = fx.Int32 raw i32 sel even = raw & fx.Int32 0x07070707 low nibble of each byte - elements 0,2,4,6 sel odd = raw.shrui fx.Int32 4 & fx.Int32 0x07070707 - elements 1,3,5,7 hb even = fp4 perm FP4 MAG HI HI, FP4 MAG HI LO, sel even lb even = fp4 perm FP4 MAG LO HI, FP4 MAG LO LO, sel even hb odd = fp4 perm FP4 MAG HI HI, FP4 MAG HI LO, sel odd lb odd = fp4 perm FP4 MAG LO HI, FP4 MAG LO LO, sel odd Sign: nibble bit 3 - bf16 bit 15, i.e. bit 7 of the high byte. hb even = hb even | raw & fx.Int32 0x08080808 << fx.Int32 4 hb odd = hb odd | raw & fx.Int32 0x80808080 dword d = lb even d , hb even d , lb odd d , hb odd d . ev01 = fp4 perm hb even, lb even, fx.Int32 0x05010400 od01 = fp4 perm hb odd, lb odd, fx.Int32 0x05010400 ev23 = fp4 perm hb even, lb even, fx.Int32 0x07030602 od23 = fp4 perm hb odd, lb odd, fx.Int32 0x07030602 return fp4 perm od01, ev01, fx.Int32 0x05040100 , fp4 perm od01, ev01, fx.Int32 0x07060302 , fp4 perm od23, ev23, fx.Int32 0x05040100 , fp4 perm od23, ev23, fx.Int32 0x07060302 , def fp4 nibble to bf16x8 raw i32, scale f32 : """FP4 E2M1 - v8bf16 for one MFMA K32 step, with the groupwise scale applied.""" scale = fx.Float32 scale f32 out = for d in fp4 mag dwords raw i32 : lo f = fx.Float32 raw d << fx.Int32 16 .bitcast T.f32 hi f = fx.Float32 raw d & fx.Int32 0xFFFF0000 .bitcast T.f32 lo b = fx.Int32 raw lo f scale .bitcast T.i32 .shrui fx.Int32 16 hi b = fx.Int32 raw hi f scale .bitcast T.i32 & fx.Int32 0xFFFF0000 out.append lo b | hi b return fx.Vector.from elements raw x for x in out , fx.Int32 .bitcast fx.BFloat16 fp4 perm src hi, src lo, sel is a thin wrapper around rocdl.perm b32 . The same helper is the gfx942 branch of upconvert b for both GEMM1 and GEMM2. Figure 4 maps each step of the helper to the gfx942 instructions it compiles to. What the LUT Decode Compiles To what-the-lut-decode-compiles-to Below are the instructions that produce the weight operand of the first MFMA, four weights, in LUT GEMM1 at 8 tokens, from the same debug-info build as the listing in What the Software Decode Compiles To gfx942-moe-mxfp4-s2-1 . They are grouped under the FlyDSL lines of fp4 mag dwords and fp4 nibble to bf16x8 above. The line table charges every v perm b32 to the one-line fp4 perm wrapper, so the table and selector operands s1 , v45 , s2 , s25 , s28 , s29 show which call each one is. v24 first holds eight packed nibbles from the weight load; once the sign step has read it, the compiler reuses it for the f32 scale of the group. sel even = raw & fx.Int32 0x07070707 v and b32 e32 v30, 0x7070707, v24 sel odd = raw.shrui fx.Int32 4 & fx.Int32 0x07070707 v lshrrev b32 e32 v31, 4, v24 v and b32 e32 v31, 0x7070707, v31 hb even = fp4 perm FP4 MAG HI HI, FP4 MAG HI LO, sel even v perm b32 v34, s1, v45, v30 ; s1 = 0x40404040, v45 = 0x3F3F3F00 lb even = fp4 perm FP4 MAG LO HI, FP4 MAG LO LO, sel even v perm b32 v30, s2, -4.0, v30 ; s2 = 0xC0804000, -4.0 = 0xC0800000 hb odd = fp4 perm FP4 MAG HI HI, FP4 MAG HI LO, sel odd v perm b32 v5, s1, v45, v31 lb odd = fp4 perm FP4 MAG LO HI, FP4 MAG LO LO, sel odd v perm b32 v6, s2, -4.0, v31 hb even = hb even | raw & fx.Int32 0x08080808 << fx.Int32 4 v lshlrev b32 e32 v32, 4, v24 v and or b32 v7, v32, s3, v34 ; s3 = 0x80808080 hb odd = hb odd | raw & fx.Int32 0x80808080 v and or b32 v5, v24, s3, v5 ev01 = fp4 perm hb even, lb even, fx.Int32 0x05010400 v perm b32 v15, v7, v30, s25 ; s25 = 0x05010400 od01 = fp4 perm hb odd, lb odd, fx.Int32 0x05010400 v perm b32 v13, v5, v6, s25 fp4 perm od01, ev01, fx.Int32 0x05040100 , fp4 perm od01, ev01, fx.Int32 0x07060302 v perm b32 v14, v13, v15, s28 ; dword 0 v perm b32 v15, v13, v15, s29 ; dword 1 scale loader, shared with the software decode: e8m0 byte - f32 v lshlrev b32 e32 v16, s33, v21 ; byte into the exponent field v and b32 e32 v24, 0x7f800000, v16 ; v24 = 2^ e8m0 - 127 lo f = fx.Float32 raw d << fx.Int32 16 .bitcast T.f32 v lshlrev b32 e32 v4, 16, v14 v lshlrev b32 e32 v5, 16, v15 hi f = fx.Float32 raw d & fx.Int32 0xFFFF0000 .bitcast T.f32 v and b32 e32 v14, 0xffff0000, v14 v and b32 e32 v15, 0xffff0000, v15 lo f scale, hi f scale v pk mul f32 v 4:5 , v 24:25 , v 4:5 op sel hi: 0,1 ; both lanes x v24 v pk mul f32 v 14:15 , v 24:25 , v 14:15 op sel hi: 0,1 lo b = fx.Int32 raw lo f scale .bitcast T.i32 .shrui fx.Int32 16 v lshrrev b32 e32 v4, 16, v4 v lshrrev b32 e32 v5, 16, v5 hi b = ... & fx.Int32 0xFFFF0000 ; out.append lo b | hi b v and or b32 v96, v14, s27, v4 ; s27 = 0xFFFF0000 v and or b32 v97, v15, s27, v5 ; v 96:97 : weight operand of the MFMA Apart from the scale loader, that is 24 VALU instructions for four weights. The other four weights of the K32 step reuse the selectors, lookups, and sign, and need only the remaining four v perm b32 and their scale steps: 14 more. Over the whole kernel, the line table puts 19.4 of the 20.5 non-MFMA VALU instructions per MFMA Table 6 in the decode helpers: about 5 per weight, against about 17 for the software decode. The scale loader builds the f32 scale by shifting the e8m0 byte into the exponent field and masking it. That maps e8m0 0x00 to 0.0 rather than 2^-127, and 0xFF to +inf rather than NaN. Both decodes use the same loader, so this does not differ between them. Checking Bit-Exactness on MI300X checking-bit-exactness-on-mi300x To check that the two decodes produce the same bits on hardware, we read decoded weights back through GEMM2. With topk=1 , a routing weight of 1.0, and a one-hot intermediate row, each output element is exactly one decoded weight: one nonzero product per dot product, exact in fp32, written onto a zeroed bf16 output. GEMM1 calls the same helper; the test reads back through GEMM2 because GEMM2 has no activation epilogue. - The test reads back 22,020,096 weights 16 experts × 3584 × 384 with random packed bytes and e8m0 scales from 0x00 to 0xFC . That covers all 64,768 pairs of packed byte value and scale. - Every nonzero weight is bit-identical between the software and LUT outputs. Zeros match by value; the test cannot see their sign, because adding −0 to a +0 accumulator gives +0. - Against the exact E2M1 × 2^ e8m0 − 127 values, the only differences are the 76,208 nonzero weights with scale 0x00 . Both decodes return 0 for them, because of the scale loader described in What the LUT Decode Compiles To gfx942-moe-mxfp4-s3-1 . - Scales 0xFD – 0xFF are left out: they overflow bf16 for the largest magnitudes or are NaN, and a single non-finite weight would turn its whole dot product into NaN. After the Fix: Counters and Thread Trace after-the-fix-counters-and-thread-trace Table 6 repeats the counters from What the Counters Showed gfx942-moe-mxfp4-s1-2 with the LUT in place. | Software → LUT | GEMM1, 8 tokens | GEMM2, 8 tokens | GEMM1, 2048 tokens | GEMM2, 2048 tokens | |---|---|---|---|---| | VALU per MFMA | 72.0 → 20.5 | 79.5 → 20.9 | 35.8 → 10.1 | 40.9 → 11.6 | | Non-MFMA VALU instructions, LUT / software | 0.28 | 0.26 | 0.28 | 0.28 | | MFMA and LDS instructions, waves | unchanged | unchanged | unchanged | unchanged | | VMEM instructions | unchanged | unchanged | −3% | unchanged | | VALU share of issue | 97.4% → 92.9% | 95.7% → 85.7% | 98.4% → 94.4% | 93.4% → 80.7% | | Wave time waiting on a dependency | 22% → 24% | 13% → 29% | 10% → 20% | 21% → 49% | Table 6. SQ counters before and after the LUT on MI300X \ a\ gfx942-moe-mxfp4-endnote-a . The LUT issues 3.5×–3.8× fewer non-MFMA VALU instructions for exactly the same MFMA instructions, in both GEMMs and at both token counts. VALU is still most of what the waves issue, but there is far less of it between consecutive MFMAs. This is also the direct check promised in What the Counters Showed gfx942-moe-mxfp4-s1-2 . The LUT leaves the LDS instruction count and the number of waves unchanged, and the VMEM instruction count unchanged or 3% lower. On the traced CU at 2048 tokens, the cycles spent in s waitcnt do not grow in GEMM1 2.93M → 2.11M and grow 10% in GEMM2 2.76M → 3.04M \ a\ gfx942-moe-mxfp4-endnote-a . Yet GEMM1 and GEMM2 kernel times drop 2.2× and 1.8× Kernel Time on MI300X gfx942-moe-mxfp4-s3-4 . If waiting on memory had been the limit, removing VALU work could not have moved the kernel time this much. ATT shows where the remaining cycles go. In LUT GEMM1 at 2048 tokens, compare/select drops from 21% to 0.6% of the cycles, and v cmp u f32 falls from 216,000 executions on the traced CU to 1,024, none of them in the decode. v perm b32 becomes 25% of the instructions but only 16% of the cycles. The MFMA share of the cycles rises from 1.1% to 4.9% in GEMM1 and from 1.3% to 5.3% in GEMM2. The line table shows that the decode, although cheaper, is still most of GEMM1. Its three helpers issue 85% of the instructions in LUT GEMM1 at 8 tokens and 81% at 2048 tokens, and take 62% and 75% of the cycles, against 93% and 92% of the instructions and 73% and 81% of the cycles for the software decode Table 4 \ a\ gfx942-moe-mxfp4-endnote-a . In LUT GEMM2 the decode share falls further, to 75% and 62% of the instructions and 53% and 43% of the cycles. That is why VALU still dominates issue after the fix. The next limits are visible in the same data: - Waits are now exposed. With the decode cheaper, s waitcnt is 11% of GEMM1 cycles and 36% of GEMM2 cycles up from 5.5% and 14% . s barrier grows from 4.0% to 4.8% of GEMM1 cycles and from 3.1% to 5.5% of GEMM2 cycles, and GEMM2 waves wait on a dependency 49% of the time. - Stalls at the scale multiply. ATT charges 33% of LUT GEMM1 cycles at 2048 tokens to v pk mul f32 , the lo f scale and hi f scale multiplies of fp4 nibble to bf16x8 , and 94% of those cycles are waiting before issue. The software decode shows the same pattern at that instruction 97% , so the stall belongs to this instruction rather than to the lookup. Neither is the bit-pattern lookup itself, so they are separate optimizations. Kernel Time on MI300X kernel-time-on-mi300x Table 7 compares kernel time on one AMD Instinct MI300X GPU, taken from the GEMM1 and GEMM2 kernels of full fused moe calls. The only source difference between the two arms is the decode helper called at that one site in upconvert b . Each arm has its own FlyDSL kernel cache, so neither reuses a kernel compiled for the other decode. Tiles come from the tuned table that 5583 ships, and both arms pick the same kernels at every token count: BM=16 up to 512 tokens, and BM=32 at 2048 and 8192. Routing follows the op test in that commit: the top 16 of random scores per token. | Tokens | Distinct experts | Software GEMM1 µs | LUT GEMM1 µs | GEMM1 × | Software GEMM2 µs | LUT GEMM2 µs | GEMM2 × | Total × | |---|---|---|---|---|---|---|---|---| | 1 | 16 | 49.0 | 20.8 | 2.36 | 20.0 | 8.6 | 2.32 | 2.35 | | 2 | 32 | 75.8 | 31.4 | 2.41 | 34.3 | 14.8 | 2.31 | 2.38 | | 4 | 64 | 109.7 | 49.5 | 2.22 | 51.1 | 23.5 | 2.17 | 2.20 | | 8 | 128 | 231.7 | 95.5 | 2.43 | 107.8 | 49.1 | 2.19 | 2.35 | | 512 | 896 | 1306.1 | 591.9 | 2.21 | 774.3 | 313.2 | 2.47 | 2.30 | | 2048 | 896 | 2336.1 | 1040.7 | 2.24 | 1587.3 | 884.7 | 1.79 | 2.04 | | 8192 | 896 | 6661.1 | 2846.0 | 2.34 | 4217.1 | 2534.0 | 1.66 | 2.02 | Table 7. Software vs LUT decode, rocprofv3 kernel time on MI300X \ a\ gfx942-moe-mxfp4-endnote-a . Mean of three repetitions of 100 fused moe calls after 10 warm-up calls. Total × is software GEMM1 + GEMM2 / LUT GEMM1 + GEMM2 ; MoE sorting is not included. Per repetition, the whole MoE call agrees within 2.2%, except the LUT arm at 2048 tokens 6.5% . Both GEMMs speed up, because both were spending their issue cycles on the decode. Kernel time drops less than the VALU instruction count does for GEMM1 at 2048 tokens, 2.2× against 3.5× : the LUT kernel still spends most of its issue cycles on VALU, and the waits described in After the Fix: Counters and Thread Trace gfx942-moe-mxfp4-s3-3 are now exposed. Prefill GEMM2 gains the least 1.8× at 2048 tokens and 1.7× at 8192 , which matches Table 6: after the fix, its waves spend 49% of their time waiting on a dependency rather than issuing. Try It try-it 5583 made the LUT the gfx942 decode for MXFP4 weights with bf16 activations, and AITER used it without a flag from baef8156a until 6144 replaced it at f2cb249 Follow-Up Decode Optimizations in AITER gfx942-moe-mxfp4-followup . Check out baef8156a to reproduce the numbers of this post. We ran the steps below with FlyDSL 0.3.4.1, ROCm 10.0.0, and PyTorch 2.12.0 \ a\ gfx942-moe-mxfp4-endnote-a . Save this script as moe.py . It sends the shape of this post through fused moe with SwiGLU, with inputs and weights set up as in the AITER op test for these kernels: python import torch import aiter from aiter import ActivationType, QuantType, dtypes from aiter.fused moe import fused moe, fused topk from aiter.ops.flydsl.moe common import GateMode from aiter.ops.shuffle import shuffle scale a16w4, shuffle weight a16w4 E, topk, H, I, tokens = 896, 16, 3584, 384, 2048 x = torch.randn tokens, H , dtype=dtypes.bf16, device="cuda" w1 = torch.randn E, 2 I, H , dtype=dtypes.bf16, device="cuda" w2 = torch.randn E, H, I , dtype=dtypes.bf16, device="cuda" scores = torch.randn tokens, E , dtype=dtypes.bf16, device="cuda" topk weights, topk ids = fused topk x, scores, topk, True quant = aiter.get torch quant QuantType.per 1x32 w1 q, w1 s = quant w1, quant dtype=dtypes.fp4x2 w2 q, w2 s = quant w2, quant dtype=dtypes.fp4x2 out = fused moe x, shuffle weight a16w4 w1 q.view E, 2 I, H // 2 , 16, False , shuffle weight a16w4 w2 q.view E, H, I // 2 , 16, False , topk weights, topk ids, w1 scale=shuffle scale a16w4 w1 s, E, False , w2 scale=shuffle scale a16w4 w2 s, E, False , quant type=QuantType.per 1x32, activation=ActivationType.Swiglu, quant dtype a=dtypes.bf16, doweight stage1=False, gate mode=GateMode.SEPARATED.value, torch.cuda.synchronize print "out", tuple out.shape , out.dtype, "nan" if out.isnan .any .item else "finite" To profile the two GEMMs the way Profiling the Reference Software Decode gfx942-moe-mxfp4-s1 does, run the script under rocprofv3: kernel time, the four counter passes behind Table 2, and ATT on one CU. rocprofv3 --kernel-trace --output-format csv -d trace -o trace -- python3 moe.py rocprofv3 --kernel-include-regex gemm --output-format csv -d pmc -o pmc \ --pmc 'GRBM GUI ACTIVE SQ WAVES SQ WAVE CYCLES SQ BUSY CYCLES' \ --pmc 'GRBM GUI ACTIVE SQ INSTS VALU SQ INSTS MFMA SQ INSTS SALU SQ INSTS VMEM' \ --pmc 'GRBM GUI ACTIVE SQ ACTIVE INST VALU SQ VALU MFMA BUSY CYCLES SQ ACTIVE INST ANY SQ INSTS LDS' \ --pmc 'GRBM GUI ACTIVE SQ WAIT ANY SQ WAIT INST ANY SQ ACTIVE INST VMEM SQ ACTIVE INST LDS' \ -- python3 moe.py rocprofv3 --att --kernel-include-regex gemm --att-target-cu 1 -d att -o att -- python3 moe.py For the source lines of Mapping the Instructions Back to FlyDSL Lines gfx942-moe-mxfp4-s1-4 , build the kernels again with line tables, starting from an empty FlyDSL cache ~/.flydsl/cache by default : FLYDSL DEBUG ENABLE DEBUG INFO=1 FLYDSL DUMP IR=1 FLYDSL DUMP DIR=dump python3 moe.py Each kernel gets a directory under dump/ , named after the kernel. Its final isa.s file puts a .loc directive file number and line before each instruction, and the .file lines at the top of the file map those numbers to Python files. Before joining that file with the instruction list in an ATT stats .csv , check that both list the same instructions in the same order. If a FlyDSL compile fails with lld invocation failed , set ROCM PATH to the ROCm install, for example /opt/rocm ; in our container, the FlyDSL link step found ld.lld only with it set. Limitations limitations These bound what the measurements above support: - One GPU and one shape. Every number comes from one MI300X running GEMM1 and GEMM2 at E=896, model dim=3584, inter dim=384, topk=16 with SwiGLU and bf16 activations. Other shapes, activations, and gfx942 products are not measured. - Synthetic weights and routing. Inputs and weights are N 0,1 before MXFP4 quantization, and routing takes the top 16 of random scores, as in the AITER op test for these kernels. Weights and routing from a real checkpoint are not measured. - A reference baseline. The speedups compare the LUT with the first, straightforward software decode written during development, placed at the same call site; it was never merged into AITER. - GEMM time only. Table 7 covers the two GEMM kernels. MoE sorting and the rest of the model are not included, so it is not an end-to-end speedup. - One process per point. Each kernel time comes from one process. Across its three repetitions the whole MoE call agrees within 2.2% 6.5% for the LUT at 2048 tokens , but variation between processes was not measured. - One CU in the thread trace. ATT covers CU 1 of shader engine 0 for one dispatch per GEMM, and its cycles are wave-cycles on that CU, not kernel time. Its VALU-per-MFMA ratio matches the whole-GPU counters within 0.1% Counters That Locate the Limiter gfx942-moe-mxfp4-s1-1 . - Bit-exactness range. The check covers e8m0 scales 0x00 – 0xFC . Scale 0x00 decodes to 0 rather than 2^-127 in both decodes, and 0xFD – 0xFF are left out Checking Bit-Exactness on MI300X gfx942-moe-mxfp4-s3-2 . - Innermost source lines. The line table names the innermost FlyDSL line of each instruction. The v perm b32 lookups land on the one-line fp4 perm wrapper and the LUT scale arithmetic on the final return of fp4 nibble to bf16x8 , so the listing in What the LUT Decode Compiles To gfx942-moe-mxfp4-s3-1 places them under their calling lines by their operands. The categories in Table 4 are our grouping of FlyDSL functions. Follow-Up Decode Optimizations in AITER follow-up-decode-optimizations-in-aiter Two later AITER pull requests cut the VALU instructions of the gfx942 decode further and keep every nonzero decoded weight bit-identical to the 5583 LUT. ROCm/aiter 6144 https://github.com/ROCm/aiter/pull/6144 \ 9\ gfx942-moe-mxfp4-ref-9 , merged as f2cb249 , looks up E4M3FNUZ fp8 codes instead of bf16 bytes and converts them with the hardware v cvt pk f32 fp8 , which takes the lookups from 12 v perm b32 to 2 for every 8 weights. ROCm/aiter 8184 https://github.com/ROCm/aiter/pull/8184 \ 10\ gfx942-moe-mxfp4-ref-10 , open as of November 19, 2026, takes that decode from 28 to 21 VALU instructions for every 8 weights. Summary summary In this blog you explored why MXFP4 MoE weights need a software decode on AMD Instinct MI300X GPUs, and what that decode costs. You profiled the moe 2stage a16wmix GEMMs in AITER with GPU kernel time, SQ counter ratios, ATT, and FlyDSL source-line tables, and traced their VALU-bound profile to a single helper: the E2M1→bf16 weight decode. You then saw that this decode is a fixed bit pattern rather than arithmetic, and how the v perm b32 byte LUT from 5583 turns it into byte lookups. On MI300X, the LUT makes GEMM1 2.2×–2.4× and GEMM2 1.7×–2.5× faster than the reference software decode, and every nonzero decoded weight stays bit-identical to the software decode for every e8m0 scale up to 0xFC \ a\ gfx942-moe-mxfp4-endnote-a . | Step | What you learn / change | Accuracy | Status | |---|---|---|---| | Kernel time + SQ counters + ATT + FlyDSL line tables | VALU takes 93–98% of issue cycles, and the weight-decode helper issues 92–93% of the GEMM1 instructions on the software path | — | Method | | Software E2M1→bf16 | f32 rebuild + RNE including NaN checks that cannot fire | Reference without the hardware convert | Reference baseline not shipped | | v perm b32 bf16 LUT | Bit-pattern lookup in both GEMMs; VALU per MFMA 72→20 GEMM1, 8 tokens | Nonzero decoded weights bit-identical for e8m0 ≤ 0xFC | aiter 5583 https://github.com/ROCm/aiter/pull/5583 merged | If you run MXFP4 MoE models with bf16 activations on MI300X through AITER, you already use the result: since 5583 , AITER decodes these weights on gfx942 with a table lookup, and the follow-up pull requests keep every nonzero decoded weight bit-identical to it. Beyond this one kernel, you can take away a profiling loop: time kernels on the GPU, use counter ratios such as VALU per MFMA and the wave time ratios to see what the waves are busy with, use ATT to tie those cycles to specific instructions, use the line tables from the compiler to tie the instructions to source lines, and fix the code those lines point at. The commands in Try It gfx942-moe-mxfp4-try-it are a starting point for running the same loop on your own FlyDSL kernels. There is more to come. The counters and thread trace in this post already point at the next limits: the exposed waits and the stalls at the scale multiply. Meanwhile, the follow-up pull requests keep cutting the decode itself Follow-Up Decode Optimizations in AITER gfx942-moe-mxfp4-followup . Follow AITER https://github.com/ROCm/aiter and FlyDSL https://github.com/ROCm/FlyDSL on GitHub, and check back on ROCm Blogs for more kernel work on AMD Instinct GPUs from our team. Endnotes endnotes a Test Environment Tables 2–4, 6, and 7, Checking Bit-Exactness on MI300X gfx942-moe-mxfp4-s3-2 , and After the Fix: Counters and Thread Trace gfx942-moe-mxfp4-s3-3 : testing conducted by AMD on October 30, 2026. GEMM1 and GEMM2 of moe 2stage a16wmix at E=896, model dim=3584, inter dim=384, topk=16 , with bf16 activations, MXFP4 weights, and SwiGLU gpt-oss form . Every fused moe call passes quant dtype a=dtypes.bf16 : for SwiGLU, fused moe otherwise quantizes the activations to fp4 from about 512 tokens up, which leaves the bf16-activation kernels this post measures. LUT arm: AITER baef8156a the 5583 merge commit with FlyDSL 0.3.4.1. Software arm: the same commit with the reference software decode from Root Cause: The Software E2M1→bf16 Decode gfx942-moe-mxfp4-s2 called from upconvert b instead of fp4 nibble to bf16x8 . Inputs and weights follow the op tests/test flydsl moe a16wfp4.py setup of that commit, and tiles come from its tuned table. The bit-exactness check in Checking Bit-Exactness on MI300X gfx942-moe-mxfp4-s3-2 calls GEMM2 directly and does not involve the activation. Kernel time from rocprofv3 --kernel-trace : mean of three repetitions of 100 fused moe calls after 10 warm-up calls. Counters from rocprofv3 --pmc in four passes: median of five dispatches after 2 warm-up dispatches. ATT from rocprofv3 --att on CU 1 of shader engine 0, one dispatch per GEMM. Source lines Table 4, What the Software Decode Compiles To gfx942-moe-mxfp4-s2-1 , What the LUT Decode Compiles To gfx942-moe-mxfp4-s3-1 , and After the Fix: Counters and Thread Trace gfx942-moe-mxfp4-s3-3 : the same kernels rebuilt on November 4, 2026 from the same commits with FLYDSL DEBUG ENABLE DEBUG INFO=1 ; the ISA of each rebuilt kernel has the same instructions, in the same order, as the kernel ATT traced, and the line of each instruction is joined to the ATT row of that instruction. Server manufacturers may vary configurations, which can yield different results. Performance may also vary based on the use of the latest drivers and optimizations. AMD system configuration: - 1x AMD Instinct™ MI300X, 192 GB HBM3 per GPU - Host OS: Ubuntu 24.04.4 LTS - Host GPU driver: amdgpu 7.1.3 - Container: ROCm™ 10.0.0, PyTorch 2.12.0, AITER baef8156a , FlyDSL 0.3.4.1 References references 1 OCP Microscaling Formats MX v1.0 Specification https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf : defines MXFP4 and the e8m0 scale. 2 AITER https://github.com/ROCm/aiter : AMD AI Tensor Engine for ROCm, with the moe 2stage a16wmix kernels. 3 FlyDSL https://github.com/ROCm/FlyDSL : Python domain-specific language for GPU kernels on ROCm. 4 Using rocprofv3 https://rocm.docs.amd.com/projects/rocprofiler-sdk/en/latest/how-to/using-rocprofv3.html : kernel tracing and counter collection. 5 Using thread trace https://rocm.docs.amd.com/projects/rocprofiler-sdk/en/latest/how-to/using-thread-trace.html : advanced thread trace ATT with rocprofv3. 6 ROCm/aiter 5583: gfx942 v perm b32 E2M1 decode https://github.com/ROCm/aiter/pull/5583 : the LUT decode measured in this post. 7 Matrix Core Programming on AMD CDNA™3 and CDNA™4 architecture https://rocm.blogs.amd.com/software-tools-optimization/matrix-cores-cdna/README.html : MFMA instructions and their operands. 8 AMD Instinct MI300 CDNA 3 Instruction Set Architecture https://www.amd.com/content/dam/amd/en/documents/instinct-tech-docs/instruction-set-architectures/amd-instinct-mi300-cdna3-instruction-set-architecture.pdf : including v perm b32 . 9 ROCm/aiter 6144: gfx942 a16w4 MXFP4 decode through an fp8 LUT and the hardware fp8 convert https://github.com/ROCm/aiter/pull/6144 : the first follow-up decode. 10 ROCm/aiter 8184: gfx942 a16w4 MXFP4 decode with a negative LUT, v pk mul f32 scale, and v perm b32 pack https://github.com/ROCm/aiter/pull/8184 : the second follow-up decode. Disclaimers disclaimers The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions, and typographical errors. The information contained herein is subject to change and may be rendered inaccurate for many reasons, including but not limited to product and roadmap changes, component and motherboard version changes, new model and/or product releases, product differences between differing manufacturers, software changes, BIOS flashes, firmware upgrades, or the like. Any computer system has risks of security vulnerabilities that cannot be completely prevented or mitigated. AMD assumes no obligation to update or otherwise correct or revise this information. However, AMD reserves the right to revise this information and to make changes from time to time to the content hereof without obligation of AMD to notify any person of such revisions or changes. THIS INFORMATION IS PROVIDED ‘AS IS.” AMD MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE CONTENTS HEREOF AND ASSUMES NO RESPONSIBILITY FOR ANY INACCURACIES, ERRORS, OR OMISSIONS THAT MAY APPEAR IN THIS INFORMATION. AMD SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT WILL AMD BE LIABLE TO ANY PERSON FOR ANY RELIANCE, DIRECT, INDIRECT, SPECIAL, OR OTHER CONSEQUENTIAL DAMAGES ARISING FROM THE USE OF ANY INFORMATION CONTAINED HEREIN, EVEN IF AMD IS EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. AMD, the AMD Arrow logo, AMD Instinct, AMD CDNA, AMD ROCm, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies. PyTorch, the PyTorch logo and any related marks are trademarks of The Linux Foundation. © 2026 Advanced Micro Devices, Inc. All rights reserved