Skip to content

[FlyDSL] feat(mega_moe): optimize fused stage1 and AOT bundles - #5001

Merged
GwilliamHu merged 33 commits into
mainfrom
megamoe_aot_pr_20260826
Sep 8, 2026
Merged

GwilliamHu merged 33 commits into
mainfrom
megamoe_aot_pr_20260826

Conversation

@GwilliamHu

@GwilliamHu GwilliamHu commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Motivation

Improve DeepSeek-V4-Pro MegaMoE A8W4 end-to-end performance while reducing communication-buffer memory usage and preserving 8-GPU correctness across dynamic MTPR configurations.

Technical Details

  • Fuse activation quantization with dispatch preparation.

  • Overlap Stage1 communication and GEMM through finite producer dispatch, producer auto-retirement, and consumer tile scheduling.

  • Deduplicate common dispatch payloads.

  • Improve Stage2 scheduling and common-row processing.

  • Add DeepSeek-V4-Pro AOT bundles for EPR 48/52/56 and MTPR 8192/16384/32768.

  • Harden synchronization, cache/preload handling, and remove obsolete experimental paths.

Test Plan

  • Run 8-GPU correctness and CUDA Graph replay tests for:

    • MTPR=MAX: 15 shapes
    • MTPR=tokens: 15 shapes
    • Mixed-rank token distributions
    • 512-round stress test at tokens-per-rank 4096
  • Validate JIT and cross-process AOT execution.

  • Run DeepSeek-V4-Pro full-network benchmarks at concurrency 512/4096 and request rates 0.8/1.0.

  • Run Python compile, Black, Ruff, and diff checks.

• ## Test Result

Environment

Component Version
Image rocm/atom-dev@sha256:a5cfa1ab503af6e0f55e0ed83cd7e999edbea6940a38dba44aaeee9a22758976
ATOM 1e7659fde32eeaa0d9aa868c3e90847e5e46a51c
FlyDSL 065280213fb28f1b574b08333a1a05c05df2a195
Runtime PyTorch 2.10.0+rocm7.2.4.git3d3aa833, HIP 7.2.53211

Full-network throughput

Concurrency Request rate Standard baseline (tok/s) PR #5001 (tok/s) Improvement
512 1.0 44,703.15 45,872.94 +2.62%
512 0.8 39,824.01 42,197.57 +5.96%
4096 1.0 59,208.26 60,379.51 +1.98%
4096 0.8 57,381.45 59,733.85 +4.10%

Correctness and stability

  • MTPR=MAX: 15/15 8-GPU CUDA Graph cases passed.
  • MTPR=tokens: 15/15 cases passed.
  • Mixed-rank and 512-round stress tests passed.
  • AOT compilation and cross-process run-only validation passed.
  • All full-network requests completed without traceback, OOM, watchdog timeout, illegal memory access, or assertion failure.
  • Compile, formatting, Ruff, and diff checks passed.

SGLang end-to-end performance

AgentX variable-length trace replay, concurrency 64

Workload: inferencex-agentx-mvp, Weka/Claude-Code trajectories, 900-second profiling window, random seed 42.

Metric AITER main PR #5001 Improvement
Input throughput (tok/s) 191,410.96 217,611.16 +13.69%
Output throughput (tok/s) 1,018.91 1,165.63 +14.40%
Total throughput (tok/s) 192,429.87 218,776.78 +13.69%
Mean TTFT (ms) 10,962.79 6,734.85 -38.57%
Mean ITL (ms) 79.69 59.12 -25.81%
Mean request latency (ms) 57,086.37 48,766.04 -14.57%

SGLang environment

Component Version
SGLang 1ce08ce230011be15ad52080d12ff96ce01a5306
InferenceX / AgentX driver 884cc79c8291b599b067b5edd0003d35b4069112
AITER main 5853cf35377eb4e1433a075ce7a9d6fa0beed15d
AITER PR #5001 31cfb4a0286fc9f0cf25498d07f937640cd1295d
FlyDSL 0.3.2
PyTorch / HIP 2.10.0+rocm7.2.4.git3d3aa833 / 7.2.53211

Submission Checklist

@GwilliamHu
GwilliamHu requested a review from a team August 26, 2026 02:05
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5001 --add-label <label>

PR title tags:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf] and op tags like [MLA] are left untouched. Add the no-auto-title label to opt this PR out of title tagging.

@github-actions github-actions Bot changed the title feat(mega_moe): optimize fused stage1 and AOT bundles [FlyDSL] feat(mega_moe): optimize fused stage1 and AOT bundles Aug 26, 2026
@zufayu
zufayu requested a review from coderfeli August 27, 2026 01:24
@GwilliamHu
GwilliamHu force-pushed the megamoe_aot_pr_20260826 branch from 4147bfb to b2807e8 Compare August 31, 2026 21:01
Add profile-bundled Stage1/Stage2 compilation, deterministic cache identity, and latest-FlyDSL-compatible AOT loading. Optimize compact dispatch publication and consumer scheduling while preserving fixed-slot behavior. Remove superseded dispatch paths, dead compile-time switches, unused helper arguments, and invariant config fields; add CPU protocol and bundle coverage.
@GwilliamHu
GwilliamHu force-pushed the megamoe_aot_pr_20260826 branch from 727885e to 324a0ee Compare September 1, 2026 09:18
@GwilliamHu
GwilliamHu merged commit 2bd2056 into main Sep 8, 2026
56 checks passed
@GwilliamHu
GwilliamHu deleted the megamoe_aot_pr_20260826 branch September 8, 2026 13:38
coderfeli added a commit that referenced this pull request Sep 8, 2026
coderfeli pushed a commit that referenced this pull request Sep 9, 2026
* Reapply "[FlyDSL] feat(mega_moe): optimize fused stage1 and AOT bundles (#5001)" (#5345)

This reverts commit 66beac2.

* fix(aot): load MegaMoE combine tuning from CSV

* fix(ci): sort MegaMoE AOT imports
RolaoDenthu added a commit to RolaoDenthu/sglang that referenced this pull request Nov 16, 2026
With SGLANG_AITER_MEGA_RANK_SYNC, an idle DP rank in a prefill step ran a
fabricated one-token extend through the whole forward, and fed MegaMoE a
fabricated row. Only the idle rank accounted for that row: it rewrote its
global_num_tokens to [1] * N, while the busy ranks kept [N, 0, ...]. When
those counts are DP-global, collectives outside the MoE that size their
buffers from them disagree across ranks, so the DeepSeek-V4.1 Engram
per-rank lookup hung in RCCL during warmup.

aiter MegaMoEv2 already handles a rank with zero tokens (ROCm/aiter#5001):
it quantizes zero rows and gives that rank the smallest bundle
configuration, so the rank still joins the collective dispatch. CUDA
MegaMoE likewise lets idle ranks enter with zero rows.

So remove the fabrication. Idle ranks stay IDLE, every rank sees the real
token counts, and an idle rank enters MegaMoEv2 with zero rows, with or
without SGLANG_AITER_MEGA_RANK_SYNC.
RolaoDenthu added a commit to RolaoDenthu/sglang that referenced this pull request Nov 30, 2026
With SGLANG_AITER_MEGA_RANK_SYNC, an idle DP rank in a prefill step ran a
fabricated one-token extend through the whole forward, and fed MegaMoE a
fabricated row. Only the idle rank accounted for that row: it rewrote its
global_num_tokens to [1] * N, while the busy ranks kept [N, 0, ...]. When
those counts are DP-global, collectives outside the MoE that size their
buffers from them disagree across ranks, so the DeepSeek-V4.1 Engram
per-rank lookup hung in RCCL during warmup.

aiter MegaMoEv2 already handles a rank with zero tokens (ROCm/aiter#5001):
it quantizes zero rows and gives that rank the smallest bundle
configuration, so the rank still joins the collective dispatch. CUDA
MegaMoE likewise lets idle ranks enter with zero rows.

So remove the fabrication. Idle ranks stay IDLE, every rank sees the real
token counts, and an idle rank enters MegaMoEv2 with zero rows, with or
without SGLANG_AITER_MEGA_RANK_SYNC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants