Repository navigation
[FlyDSL] Add full-expert DeepSeek V4.1 Flash MegaMoE tuning for gfx950 - #6154
Fangzhou-Ai wants to merge 4 commits into
Conversation
Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
Preserve measured compact workspace classes and extend per-M configuration coverage for both EP sizes. Co-authored-by: Codex <noreply@openai.com> Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
Summary
Enable DeepSeek V4.1 Flash MegaMoEV2 on gfx950 for full expert parallelism: H=5120, I=2304, E=384, top-k=6, with 192 complete experts/rank at EP2 or 96 at EP4. Fuse peer dispatch with W13, clamp-10 SwiGLU and FP8 intermediate quantization, followed by MXFP4 W2 and weighted peer combine. Shared experts remain separate.
This extends the now-merged #6127 and remains a draft for implementation and tuning review. AI assistance (Codex) was used for implementation, benchmarking and this description.
Duplicate checks: searched open ROCm/aiter PRs for MegaMoE/Flash and related EP work. #6127 supplies the underlying MegaMoEV2 improvements. #5937 targets TP A4W4; #5562 supplies standalone EP A8W4 GEMM tuning with a different top-k; #5967 supplies CK TP2 tuning. This PR adds full-expert Flash dispatch/W13/W2/combine integration and a distinct per-M configuration policy.
Changes and tuning
AITER_MEGA_FIXED_SLOT_MAX_MTPRand the standalone tuning file from the submitted diff.config_tokenssupplies one source count on all peers, including empty ranks.Complete performance and occupancy data
644 source-M/workspace performance cases · All kernel/rank occupancy and resource records · Measurement methodology
The attached CSVs include every selected table entry, deduplicated config IDs, full configurations, independent timings, actual launch sizes, per-rank VGPR/AGPR/SGPR/LDS and spill counts, theoretical residency and achieved rank-0 occupancy.
Performance measurements: 8×MI355X/gfx950, isolated EP groups, BF16 inputs, MXFP4 weights, top-6 routing across 384 experts. HIP graph replay with a 512 MiB cache flush and five warmups before sampling. For each sample take the maximum time across ranks, then its median. MegaMoE uses two reversed/shuffled passes of 30 samples; the MoRI+AITER baseline uses 60. The table reports the mean of the two pass medians. Source/received token counts are recorded rather than assumed equal.
Decode comparisons use MoRI's 64-block/4-wave geometry and static uniform-DP receive trim; prefill powers M≥2048 use its 128-block/16-wave geometry and full receive capacity. The CSV explicitly records the baseline phase. These kernel comparisons exclude the caller's final output copy and shared-expert computation. Hardware-counter timings are excluded from performance results.
Occupancy and spills
Resource occupancy comes from
hipModuleOccupancyMaxActiveBlocksPerMultiprocessorqueried on exported HSACO using each kernel's actual workgroup size and zero dynamic LDS. MI355X has 256 CUs and 32 wave slots/CU. The launch ceiling additionally limits residency by the launched workgroup count. These are ceilings, not useful MFMA activity. AMD occupancy guide.Achieved occupancy uses ROCprofiler SDK's gfx950
OccupancyPercentcounter on rank 0 of each EP job. Report the median of ten cold-cache replays: five measured replays following five warmups in each of two passes. Capture-time executions and warmups are excluded. Counter collection serializes dispatches and can alter overlap; its occupancy is diagnostic rather than an uninstrumented serving measurement. Every rank has separate static metadata/residency checks; achieved runtime percentages are measured only on rank 0 and labeled as such in the attachment.All 842 distinct selected kernel/rank combinations have 0 VGPR spills. 30 compact W2 kernel/rank combinations report 2 SGPR spills; these were retained based on measured performance across ranks, rather than assuming that a spill-free variant is always faster. Maximum selected VGPR count: 394. The attachment reports the actual register, LDS and spill counts for every rank/configuration; no blanket zero-spill claim is made.
Rejected layouts include W13 M32/N512/4 waves (11 spilled VGPRs), M64/N512/4 waves (100), and M128/N512/8 waves (66, with 151,600 B LDS). Raising waves-per-EU to 4 also introduced spills and was excluded from selection. Higher occupancy alone was not used as the selection criterion.
Representative speculative-decode source bounds are below. For the compact cases this view uses capacity 8192; capacity 16384 and every intermediate M are included in the attachments. W13 and W2 occupancy columns show resource ceiling / launch ceiling / achieved rank-0 median (%).
Large-M prefill comparisons and occupancy at both serving capacities
Correctness and model evaluation
Reproduction and checks
The exhaustive tuning/resource-export harness was run locally and is excluded from this PR. The submitted benchmark and correctness suite reproduce the selected configurations. In an environment with ROCm PyTorch, FlyDSL, MoRI and AITER native dependencies:
All submitted Python changes pass Black and Ruff;
git diff --checkpasses. Final validation covers every measured table entry, and exported HSACO/resource and launch metadata is cross-checked as described in the attachments.EP2 serving sweep versus published TP2
AIPerf AgentX MVP, 393 trace entries, 3600-second profiling duration plus the reference warmup, four simultaneous two-GPU servers at concurrency 1/4/16/64. Same attempt-3 workload and serving recipe, with TP2 replaced by TP1+DP2+EP2 and MegaMoE. Synthetic DSpark acceptance is 3.51 in performance runs; GSM8K above uses real rejection. Benchmark and aggregation code use the exact reference revisions. Modified local vLLM/AITER sources are used rather than claiming the unchanged reference container image.
All rates are tokens/s for a complete two-GPU server. p90 interactivity = 1/p90 TPOT. Total throughput counts input plus output tokens; output throughput is provided separately. Changes are EP2/TP2−1.
The reference aggregation excludes warmup and error records. Error accounting is retained below, including the published TP2 error counts.
Serving outcome and additional accounting
All four EP2 runs trail the published TP2 result on p90 interactivity, output throughput and total throughput. The isolated MoE speedups do not establish an end-to-end serving win. The vLLM/AITER build differs from the published reference image; a same-build local TP2 run and serving instrumentation would help isolate the cause. Prefill/decode interference, DP synchronization and graph-replay fallback are hypotheses, not measured explanations.
The benchmark's final drain cancelled 1/0/0/10 unfinished profiling requests at concurrency 1/4/16/64 respectively. These cancellations do not have successful profiling records and are excluded from aggregation. All four runs report zero profiling request errors. C64 additionally has two warmup InvalidInferenceResultError records, as does the published TP2 C64 warmup.
DSpark settings were checked against the exported TP2 reference configuration and actual startup logs for all four EP2 servers: five draft tokens, probabilistic drafting, synthetic rejection with acceptance length 3.51, and adaptive verification disabled. Exported counters show exactly five draft tokens per draft. Mean acceptance including the bonus token is TP2 C1 3.510170; EP2 C1/C4/C16/C64 3.510312/3.509701/3.510071/3.509569. Thus neither a DSpark configuration mismatch nor a measured acceptance-rate mismatch explains the gap. These synthetic performance counters are separate from the real-rejection GSM8K evaluation.
No KV-cache preemptions occurred in any EP2 sweep; peak observed usage is below 20% per engine at C16 and approximately 20.7% at C64. These observations exclude KV capacity exhaustion for these runs; they do not establish the remaining bottleneck.
Complete serving comparison CSV · Phase completion/cancellation accounting · DSpark configuration check · Runtime acceptance counters