Repository navigation
[CK] Add dsv41 some MoE tuning configs - #5967
Conversation
…che, MoE tuner GPU datagen, torch.Stream, tuned FMoE CSV) - flydsl mixed MoE stage1: full vmcnt drain + sched_barrier before the LDS-DMA barrier (partial waits let LDS-DMA loads cross it; ROCm#5561) - fp4 prefill mqa logits: unbounded kernel cache (lru_cache(32) evicted and recompiled per shape) - MoE tuner: generate the E x 2I x H test weights on the GPU (CPU fp4 packing took tens of minutes per shape at E=385) - cpp_itfs torch_utils: accept any torch.Stream (derive the HIP handle when cuda_stream is missing) - add DSV4.1 TP2 shared-experts-fusion fp8/fp4 tuned FMoE config
…moe.csv - move the 23 shared-experts-fusion rows (E385 topk7, E129 topk4, fp8 activation x fp4 weight) into dsv41_fp4_tuned_fmoe.csv and their shapes into dsv41_fp4_untuned_fmoe.csv instead of a separate file - drop the torch_utils, fp4 prefill cache and flydsl stage1 wait changes
🏷️ 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
The new rows measure a different stage-1 path from serving, and input preparation can mix CUDA devices.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
This PR adds DeepSeek V4.1 FP4 MoE tuning configurations and moves stage-1 tuning input generation to the GPU to reduce preparation time.
Changes:
- Adds untuned and tuned configurations for 385- and 129-expert shapes.
- Generates v2 stage-1 inputs on the GPU.
| File | Description |
|---|---|
csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py |
Moves stage-1 input generation to the GPU. |
aiter/configs/model_configs/dsv41_fp4_untuned_fmoe.csv |
Adds shapes to the tuning inputs. |
aiter/configs/model_configs/dsv41_fp4_tuned_fmoe.csv |
Adds measured kernel selections. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| with torch.device(device): | ||
| d = _v2_gen( | ||
| token, | ||
| model_dim, | ||
| inter_dim, | ||
| expert, | ||
| topk, | ||
| blockM, | ||
| adtype=adtype, | ||
| b_dtype=b_dtype, | ||
| activation=act_type, | ||
| situ_beta=DEFAULT_SITUV2_BETA, | ||
| situ_linear_beta=DEFAULT_SITUV2_LINEAR_BETA, | ||
| ) | ||
| v = _v2_build_inputs(d, token, model_dim, inter_dim, expert, topk, blockM) |
| gfx950,256,8192,5120,1152,384,6,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,64,0,1178.4115,flydsl_mxmoe_g1_a4w4_64x256x256_xcd2,1.2%,0,flydsl_moe2_layout_afp4_wfp4_bf16_t64x256x128_atomic_sbm64,1.2%,1178.4115,0,0,0,1476.11,5872.82 | ||
| gfx950,256,16384,5120,1152,384,6,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,128,0,1847.0189,flydsl_mxmoe_g1_a4w4_128x256x256_xcd4,1.2%,0,flydsl_moe2_layout_afp4_wfp4_bf16_t128x128x128_atomic_sbm128,1.2%,1847.0189,0,0,0,1883.53,3815.03 | ||
| gfx950,256,32768,5120,1152,384,6,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,128,0,3253.4182,flydsl_mxmoe_g1_a4w4_128x256x256_xcd2,1.2%,0,flydsl_moe2_layout_afp4_wfp4_bf16_t128x128x128_atomic_sbm128,1.2%,3253.4182,0,0,0,2138.63,2243.21 | ||
| gfx950,256,1,5120,1152,385,7,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,32,0,12.5991,flydsl_moe1_afp8_wfp4_bf16_t32x64x256_w2_gui_kw4_fp8,0.0%,9.4207,flydsl_moe2_layout_afp8_wfp4_bf16_t32x256x128_atomic_nt_sbm32,0.0%,22.0198,0,0,0,11.25,309379.86 |
| ) | ||
| # Generate on the GPU: the CPU fp4 packing of E x 2I x H weights takes | ||
| # tens of minutes per shape at E=385. | ||
| with torch.device(device): |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Two recorded kernel selections differ from their runtime launches, and the new FP8 dispatch path lacks a focused correctness check.
Review effort: Balanced
Findings: 1
Open (5)
Avoid cross-device buffers when tuning on non-default CUDA device Add FP8 interleaved dispatch and correctness coverage · New Exclude invalid stage-1 tiles and retune E=385 rows · New Generate stage-2 FP4 inputs on GPU to avoid CPU packing delays Retune expert groups with serving-compatible scaled FP8 inputs
| gfx950,256,8192,5120,1152,384,6,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,64,0,1178.4115,flydsl_mxmoe_g1_a4w4_64x256x256_xcd2,1.2%,0,flydsl_moe2_layout_afp4_wfp4_bf16_t64x256x128_atomic_sbm64,1.2%,1178.4115,0,0,0,1476.11,5872.82 | ||
| gfx950,256,16384,5120,1152,384,6,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,128,0,1847.0189,flydsl_mxmoe_g1_a4w4_128x256x256_xcd4,1.2%,0,flydsl_moe2_layout_afp4_wfp4_bf16_t128x128x128_atomic_sbm128,1.2%,1847.0189,0,0,0,1883.53,3815.03 | ||
| gfx950,256,32768,5120,1152,384,6,ActivationType.Silu,torch.bfloat16,torch.float4_e2m1fn_x2,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,128,0,3253.4182,flydsl_mxmoe_g1_a4w4_128x256x256_xcd2,1.2%,0,flydsl_moe2_layout_afp4_wfp4_bf16_t128x128x128_atomic_sbm128,1.2%,3253.4182,0,0,0,2138.63,2243.21 | ||
| gfx950,256,1,5120,1152,385,7,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,32,0,12.5991,flydsl_moe1_afp8_wfp4_bf16_t32x64x256_w2_gui_kw4_fp8,0.0%,9.4207,flydsl_moe2_layout_afp8_wfp4_bf16_t32x256x128_atomic_nt_sbm32,0.0%,22.0198,0,0,0,11.25,309379.86 |
| gfx950,256,256,5120,1152,385,7,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,32,0,363.7643,flydsl_moe1_afp8_wfp4_bf16_t32x128x256_w3_gui_fp8,0.0%,201.7408,flydsl_moe2_layout_afp8_wfp4_bf16_t32x256x128_atomic_nt_sbm32,0.0%,565.5051,0,0,0,112.14,12053.65 | ||
| gfx950,256,512,5120,1152,385,7,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,32,0,367.7689,flydsl_moe1_afp8_wfp4_bf16_t32x128x256_w3_gui_fp8,0.0%,191.9912,flydsl_moe2_layout_afp8_wfp4_bf16_t32x256x128_atomic_nt_sbm32,0.0%,559.7601,0,0,0,226.59,12184.38 | ||
| gfx950,256,1024,5120,1152,385,7,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,32,0,378.2528,flydsl_moe1_afp8_wfp4_bf16_t32x128x256_w4_gui_fp8,0.0%,225.2484,flydsl_moe2_layout_afp8_wfp4_bf16_t32x256x128_atomic_nt_sbm32,0.0%,603.5012,0,0,0,420.33,11314.3 | ||
| gfx950,256,2048,5120,1152,385,7,ActivationType.Silu,torch.bfloat16,torch.float8_e4m3fn,torch.float4_e2m1fn_x2,QuantType.per_1x32,1,0,64,0,433.2996,flydsl_moe1_afp8_wfp4_bf16_t64x256x256_w3_gui_fp8,0.0%,238.7783,flydsl_moe2_layout_afp8_wfp4_bf16_t64x256x128_atomic_nt_sbm64,0.0%,672.0779,0,0,0,754.89,10183.23 |


Motivation
DeepSeek-V4.1-Flash on gfx950 (TP2, SGLang with
--enforce-shared-experts-fusion) runs FlyDSL a8w4 MoE shapes (fp8 activation x fp4 weight, E=385 topk=7 and E=129 topk=4) that have no tuned entries, so they fall back to the untuned heuristic.Technical Details
aiter/configs/model_configs/dsv41_fp4_tuned_fmoe.csv: add 23 tuned rows (gfx950, cu_num 256, model_dim 5120, inter_dim 1152; E385/topk7 for 13 token sizes, E129/topk4 for 10 token sizes). No key overlaps the existing fp4/fp4 rows.aiter/configs/model_configs/dsv41_fp4_untuned_fmoe.csv: add the same 23 shapes so they can be re-tuned.csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py: generate the v2 stage1 test data on the target GPU (with torch.device(device)). Packing the E x 2I x H fp4 weights on the CPU took tens of minutes per shape at E=385.Test Plan
gemm_moe_tune.pyon MI355X (gfx950).Test Result
Submission Checklist