Repository navigation
[ASM] [HIP] Qwe38 flash mxfp4 asm - #5757
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
5d6a1b4 to
70996e2
Compare
|
I added a follow up #7012 and the vLLM consumer on top of this vllm-project/vllm#64025 . Here are some impact numbers, in case they help to expedite the PR MI355X,
|
70996e2 to
a9f55fa
Compare
6b2e9ba to
f429787
Compare
…diate widths vLLM stores the MoE intermediate width padded (Qwen3.8-Flash-Next: 320 stored as 384 at TP2, 160 as 256 at TP4) and passes the zero-filled delta as intermediate_pad. The FLAT 16x32/16x160/16x320 tiles and the EMSORT 16x160 persistent tile from ROCm#5757 need the logical width, so a padded call never reached them. - fmoe_g1u1 takes intermediate_pad. The FLAT and EMSORT branches keep the stored inter_dim in KernelArgs (gate/up row offset, w1 scale offset, w2 scale pitch) and size the grid, and the EMSORT ps_deno and total_tgs, from inter_dim - intermediate_pad. - get_heuristic_kernel matches FLAT and EMSORT tiles on the logical width. - get_2stage_cfgs falls back to the FLAT or EMSORT MXFP4 1-stage row tuned at inter_dim - intermediate_pad when the stored width has no row. - The pertokenMXfp4 manifests gain a dim_align column. Kernels without the 512-column tail drain declare 1024, and fmoe_g1u1 passes model_dim to the kernel picker, so the alignment applies per kernel. - test_moe_2stage passes -hip through for a4w4. Co-authored-by: Cursor <[email protected]> Signed-off-by: Mikko Tukiainen <[email protected]>
ROCm#7012's manifest predates ROCm#5757's "Extend TP4/TP2 kernels to conc512", so taking it reset emsort_silu_16x160 and 16x320 to max_tokens 256 and max_assignments 2816 while their .co files and the tuned rows are the conc512 ones. A 512-token MoE call then failed in launch_kernel with "EMSORT ... supports token_cnt <= 256; got 512". Signed-off-by: Mikko Tukiainen <[email protected]> Co-authored-by: Cursor <[email protected]>
…diate widths vLLM stores the MoE intermediate width padded (Qwen3.8-Flash-Next: 320 stored as 384 at TP2, 160 as 256 at TP4) and passes the zero-filled delta as intermediate_pad. The FLAT 16x32/16x160/16x320 tiles and the EMSORT 16x160 persistent tile from ROCm#5757 need the logical width, so a padded call never reached them. - fmoe_g1u1 takes intermediate_pad. The FLAT and EMSORT branches keep the stored inter_dim in KernelArgs (gate/up row offset, w1 scale offset, w2 scale pitch) and size the grid, and the EMSORT ps_deno and total_tgs, from inter_dim - intermediate_pad. - get_heuristic_kernel matches FLAT and EMSORT tiles on the logical width. - get_2stage_cfgs falls back to the FLAT or EMSORT MXFP4 1-stage row tuned at inter_dim - intermediate_pad when the stored width has no row. - The pertokenMXfp4 manifests gain a dim_align column. Kernels without the 512-column tail drain declare 1024, and fmoe_g1u1 passes model_dim to the kernel picker, so the alignment applies per kernel. - test_moe_2stage passes -hip through for a4w4. Co-authored-by: Cursor <[email protected]> Signed-off-by: Mikko Tukiainen <[email protected]>
49f42f6 to
b209886
Compare
|
@mjkvaak-amd if you have compute could you check again TP4/TP2 up to con512 ? |
WAITING ON AUTHORPR Self-ReviewRevision Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision. Questions to answer in the PR description
Edit the Missing or invalid answers
Shadow mode reports what would block but keeps the status successful. Set |
Relax the small-tile dim check to a 512 multiple so 2560 hidden works, dispatch FLAT tiles for irregular inter_dim, and trim e8m0 shuffle padding in the 2-stage test so E=513 fused-expert can view scales. Co-authored-by: Cursor <[email protected]>
b209886 to
70ed590
Compare
* Add --fused-expert option to 2stage moe tests * Add gfx950 FLAT MXFP4 fused-MoE 16x32/160/320 kernels. Relax the small-tile dim check to a 512 multiple so 2560 hidden works, dispatch FLAT tiles for irregular inter_dim, and trim e8m0 shuffle padding in the 2-stage test so E=513 fused-expert can view scales. Co-authored-by: Cursor <[email protected]> * Add new kernels and tuned config * Fix 16x320 kernel when h_dim/sub_gu > 1 * Remove redundant second loop scan * Revert temp test changes * Add test option to disable biases * Extend asm 16x160 up to con 256 for TP4 * Add 16x320 kernel for TP2 * Extend TP4/TP2 kernels to conc512 * Upmerge to top of main * Pass num_valid_tokens correctly for flat and emsort --------- Co-authored-by: Sergey SOlo <[email protected]> Co-authored-by: Cursor <[email protected]>
Motivation
New asm kernels to support qwen 3.8-flash in PT2 and TP4 splt
Technical Details
Since moe_intermediatedimention for qwen3.8-flash is 640 it cannot use existing asm kernels with split by 128 or 256, we need new kernels besides 1x32 - 16x160 and 16x320. Also hidden_dim is 512 which means aiter requirements for these kernels should relax from dim % 1024 == 0 to dim % 512 == 0.
Test Plan
python3 -u op_tests/test_moe_2stage.py -t 1 2 4 8 16 -d bf16 -dim 2560,320 -q 4 -a silu -e 512 -k 10 -s f --no-flydsl-csv --ref-dtype fp32
Results:
PR Self-Review
Reviewed revision
a10f4be0bd32dd6959c56027f3c4705083db08d9Behavior and intent
Qwen3.8-flash MXFP4 MoE intermediate widths are 640 at TP1, 320 at TP2 and 160 at TP4. The existing gfx950 MXFP4 SiLU assembly tiles are 128, 256 wide, so
inter_dim160 and 320 failinter_dim % subGU_n == 0and never launch. The default 2-stage path is also the wrong producer for these decode shapes, and two host bugs blocked the new tiles even after they were added: packed FP4 shuffling rejected K=160 because it grouped two 16-byte tiles, and the ASM heuristic hid FLAT rows by applying sorted-kernelsubGU_mandvskipchecks to them. This revision adds gfx950 FLAT novs tiles16x32,16x160and16x320and EMSORT tiles16x160and16x320, records them inhsa/gfx950/fmoe/silu/fmoe_bf16_pertokenMXfp4_g1u1_silu.csv, and adds tuned rows inaiter/configs/model_configs/qwen3_8_flash_fp4_tuned_fmoe.csvfor hidden 2560, experts 512/topk 10 and fused-expert 513/topk 11, tokens 1 through 512. Tokens 1-16 use FLAT; tokens 32-512 use EMSORT.shuffle_weightnow uses a 16-byte K tile for packed FP4, andkernel_fitsacceptsflat == NO_SORT. A sorted row with the samesubGU_nstill wins a tie.Validation and unverified scope
On a gfx950 host reporting 256 CUs,
op_tests/test_moe_2stage.pywas run for bf16 SiLU, MXFP4, E=512, topk=10, model_dim=2560, inter_dim=160 and 320, tokens 1, 2, 4, 8 and 16, with--stage1-bias f --stage2-bias f --no-flydsl-csv --ref-dtype fp32. Dispatch logged the new symbols (flat_novs_silu_16x32at token 1, and the wider FLAT tiles at larger tokens). Cosine difference versus the fp32 reference was 1.5e-5 to 4.2e-5 for inter_dim=160 and 1.5e-5 to 8.1e-5 for inter_dim=320. A host-side check ofshuffle_weighton packed FP4 showed a 128-byte K width matches the previous 32-byte grouping and an 80-byte width (logical K=160) is accepted. Unverified on revisionb2098866: the token 32-512 EMSORT rows were not in that sweep,token_cnt=512was not launched against the manifest caps, and no vLLM or SGLang run was repeated on this head. The MI355X throughput numbers already in the thread include follow-up #7012 and are not a measurement of this SHA. gfx942, Gelu, andmodel_dimthat is not a multiple of 512 were not run.PR-specific question
The new path is gfx950 only: the code objects and manifest rows live under
hsa/gfx950/fmoe/silu/, andget_heuristic_kernelprefixes the lookup with the runtime arch id, so a gfx942 process cannot select them. The dtype gate is bf16 output, per-token MXFP4 (torch.float4_e2m1fn_x2weights,QuantType.per_1x32), SiLU, and gated G1U1.fmoe_g1u1loadscfg_fmoe_bf16_pertokenMXfp4_g1u1_siluonly for that combination; Gelu, fp16 output and other quant types use other manifests that do not contain these symbols. Tuned keys are model_dim=2560, inter_dim 160 or 320, experts 512 with topk 10 or 513 with topk 11, and the power-of-two token buckets from 1 to 512. An untuned call reaches a FLAT tile only wheninter_dim % subGU_n == 0after the sharedsmf,dim_alignand persistent-grid checks. The invariant that keeps unsupported inputs out is enforced in the launcher, not only in the CSV. Every MXFP4fmoe_g1u1launch requiresmodel_dim >= 512andmodel_dim % 512 == 0, so a 256-wide remainder never reaches these tiles. EMSORT additionally requiresinter_dim % sub_GU == 0, a resident persistent grid,token_cnt <= 512,token_cnt * topk <= 5632andexperts <= 1024, andlaunch_kernelrejects anything outside those manifest limits. Sorted rows still have to matchvskipandsubGU_m == block_size_M, so a 16-wide FLAT row does not replace a 32-wide sorted row of equal cost.Changed op tests
op_tests/test_moe_2stage.pyis the only changed op test. The net change versus main is--stage1-bias(default[True], same shape as the existing--stage2-biasswitch). Default CLI cases still inject a random per-expert stage-1 bias, so existing sweeps keep their previous inputs. The flag is necessary because the new FLAT and EMSORT MXFP4 kernels do not apply a per-expert stage-1 bias, while the test reference does. Leaving the default bias on makes the Qwen 2560x160 and 2560x320 comparison report a cosine near 1 even when the GEMM matches.--stage1-bias ftogether with--stage2-bias fis what lets this file compare those kernels to a bias-free reference. No other op test builds this gfx950 MXFP4 SiLU shape and can turn stage-1 bias off, so the coverage is not redundant.