Skip to content

[FlyDSL] Megamoe restore 5001 aot fix - #5346

Merged
coderfeli merged 3 commits into
mainfrom
megamoe_restore_5001_aot_fix
Sep 9, 2026
Merged

coderfeli merged 3 commits into
mainfrom
megamoe_restore_5001_aot_fix

Conversation

@GwilliamHu

@GwilliamHu GwilliamHu commented Sep 8, 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 September 8, 2026 14:53
@github-actions

github-actions Bot commented Sep 8, 2026

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
multigpu Aiter multi-GPU tests on the 8-GPU runner
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 5346 --add-label <label>

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

@github-actions github-actions Bot changed the title Megamoe restore 5001 aot fix [FlyDSL] Megamoe restore 5001 aot fix Sep 8, 2026
@github-actions github-actions Bot added the FlyDSL label Sep 8, 2026
@coderfeli
coderfeli merged commit 354e278 into main Sep 9, 2026
56 checks passed
@coderfeli
coderfeli deleted the megamoe_restore_5001_aot_fix branch September 9, 2026 05:06
jhinpan added a commit to sgl-project/sgl-amd-mono that referenced this pull request Oct 27, 2026
## Motivation

Without CUDA graphs, every launch of the DeepSeek-V4.1, GLM-5.3,
GLM-5.3-Flash and MiniMax-M3 runners goes through FlyDSL's JIT dispatch
(`JitFunction.__call__`): it binds the signature, checks the globals and
builds the full cache key at each launch. For GLM-5.3-Flash's launchers
(50 integer arguments), that costs 182 µs of host time a launch, so an
eager decode step is host-bound. This PR reuses AITER's
compiled-dispatch helper: it keeps the first real launch's
`CompiledFunction` and calls it after that.

A replayed CUDA graph does not call the launchers, so decode with CUDA
graphs (the default) does not change.

## Modifications

- These launches use `_run_compiled` from
`aiter.ops.flydsl.kernels.tensor_shim`, with the runtime addresses,
scalars and stream passed positionally:
  - DeepSeek-V4.1: K1, K2, FFN and K2i.
  - GLM-5.3: the layer.
  - GLM-5.3-Flash: the layer and the head.
  - MiniMax-M3: the launch.

  MiniMax-M3.1 already caches its compiled FFN callable.
- `compile_only` in the four runners uses AITER's `_preload_compiled`.
AITER handles the no-dispatch preload and restores the environment.
- The GLM runners import both helpers where they use them. AITER probes
the GPU when it is imported, and `test/unit` imports these modules on
CPU.
- `test/kernels/test_compiled_dispatch.py` checks the dispatch that the
runners rely on:
  - a preload never runs the kernel;
  - the first real call runs it once;
  - later calls skip JIT dispatch, also inside a graph.
- AITER requirement: `_preload_compiled`, from ROCm/aiter#5346
(`354e278e5`) onwards. ROCm/aiter#6946 is not needed, because this
repository never calls `_run_compiled` while `COMPILE_ONLY` is set.

## Accuracy Tests

The kernels and their arguments do not change, and the outputs are
bitwise equal to main's:

- GLM-5.3-Flash: the eager step of layers 3-43 at TP4, 4 and 8 rows, on
every rank.
- DeepSeek-V4.1 K1 through `DSV41MonoRunner.k1`: at TP2; widths 1, 6, 24
and 48; fold, settled and index. The outputs match after the first and
third eager call and after a graph replay, in 24/24 cases.

E2E on MI355X:

- `test_glm53_flash_server.py` (TP4): 5/5. GSM8K past the largest width
scores 0.995.
- `test_glm53_server.py` (FP8, TP8): 8/8. GSM8K scores 0.99 for decode
and 0.99 with MTP, with an accept length of 3.3-3.4.
- `test_minimax_m3_server.py` (TP4, with sgl-project/sglang#41998): 7/9.
GSM8K scores 0.925 with EAGLE3 and 0.885 for decode. The 2 failing cases
also fail on main: the test expects the spec name `minimax_m3_hip`, but
the spec has been named `minimax_m3_family_hip` since #56.

After the GLM import change, CPU-only `test/unit` gives the same result
as on main, and GLM-5.3-Flash stays bitwise equal to main at TP4.

## Speed Tests and Profiling

MI355X at TP4, with a fresh server for each arm and two rounds. The load
is random 2048 tokens in and 256 out. The table gives median TPOT in ms,
main -> this PR:

| Model | CUDA graphs, c1 / c4 | `--disable-cuda-graph`, c1 / c4 |
| --- | --- | --- |
| GLM-5.3-Flash | 2.520 -> 2.523 / 3.032 -> 3.029 | 11.28 -> 2.72 /
11.75 -> 3.19 |
| GLM-5.3 (FP8) | 6.812 -> 6.812 / 9.351 -> 9.342 | 20.06 -> 7.05 /
20.43 -> 9.39 |
| MiniMax-M3 + EAGLE3 | 1.430 -> 1.426 / 4.118 -> 4.174 | 6.29 -> 3.31 /
9.58 -> 6.38 |

- **With CUDA graphs**, TPOT does not change (within ±1.4% at every
covered width). The gain applies only to steps that run without a graph.
- **Host time** of a GLM-5.3-Flash launch goes from 182 µs to 14.7 µs.
An eager step of layers 3-43 goes from 7.50 ms to 2.54 ms, which equals
the step's graph replay time.

Setup: image `rocm/sgl-dev:v0.5.22-rocm10-mi35x-20261026`, with SGLang
`5ef99013ac`, AITER `285579b62` and FlyDSL 0.4.0.

## Checklist

- [x] `pre-commit run --all-files` passes.
- [x] Tests under `test/` cover the change.
  - The dispatch: `test_compiled_dispatch.py`.
- DeepSeek-V4.1 FFN and K2: `test_deepseek_v41_kernels.py`. K2i:
`test_deepseek_v41_k2i.py`.
  - GLM-5.3-Flash: `test_glm53_flash_kernels.py`.
  - MiniMax-M3 `compile_only`: `test_minimax_m3_compile.py`.
  - Only the e2e tests reach the GLM-5.3 and MiniMax-M3 launches.
- No committed test reaches `DSV41MonoRunner.k1`, because `check_k1.py`
calls the K1 launcher directly. K1 was checked bitwise against main, as
described above.
- [x] The SGLang commit or PR this was tested against is named above.
- [x] Accuracy and speed results are attached.
- [ ] A new model adds one line to `.github/CODEOWNERS` that names its
owner. (No new model.)

---------

Co-authored-by: Jin Pan <[email protected]>
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