Skip to content

[Perf] [NPU] moe: Add DeepGEMM-Ascend MegaMoE for Prefill - #1548

Draft
AkiYangDev wants to merge 2 commits into
Ascend:release/20261215from
AkiYangDev:draft/ascend-deepgemm-prefill
Draft

AkiYangDev wants to merge 2 commits into
Ascend:release/20261215from
AkiYangDev:draft/ascend-deepgemm-prefill

Conversation

@AkiYangDev

@AkiYangDev AkiYangDev commented Dec 3, 2026 •

Copy link
Copy Markdown

Motivation

On Ascend 950, DeepSeek-V4.1-Flash Prefill can send routed tokens through AllGather, grouped expert matmuls and ReduceScatter. DeepGEMM-Ascend fuses the dispatch, expert FFN and combine in one device path. An eight-card offline prototype raised new-input throughput from 13,035.87 to 15,872.72 tokens/s/NPU (+21.8%) on a 128K prompt with a 124K cached prefix.

Modifications

  • Add the opt-in fused_op_provider: "deepgemm" to AscendOps. It requires a fixed Prefill worker on one Ascend 950 node with TP8, attention DP8, EP8, static expert placement and eager synchronous execution. The existing fused-op provider is cann.
  • Pack MXFP4 expert weights and E8M0 scales from checkpoint bytes at load time. The worker retains one weight layout. Online weight replacement requires a restart. FP8 experts and FP4-to-FP8 dequantization are rejected during argument resolution.
  • Reuse the initialized TP device communicator after checking its ordered membership against the EP group. The group shares one symmetric workspace, sized from the resolved Prefill chunk budget. Idle ranks participate with an ignored route.

Install a DeepGEMM-Ascend build for the worker's CANN runtime. Add these options to the regular Prefill launch. The 32,768-token launch budget resolves to 4,096 tokens per rank with attention DP8.

--disaggregation-mode prefill \
--tp-size 8 --attn-dp-size 8 --ep-size 8 \
--chunked-prefill-size 32768 --random-seed 42 \
--disable-overlap-schedule --disable-prefill-cuda-graph \
--ep-dispatch-algorithm static \
--moe-a2a-backend ascend_ops \
--moe-ascend-ops-config '{"prefill":"fused_op","fused_op_provider":"deepgemm"}'

Accuracy Tests

Offline comparison First-token agreement Held-out logit argmax agreement
AllGather vs DeepGEMM prototype 64/80 30/32
AllGather repeat 69/80 30/32

The prototype and baseline used identical token inputs but different engine seeds. In a separate diagnostic against AllToAllV, matching its MXFP8 scale convention (scale_alg=1) gave bitwise-identical outputs on the first matched-input call at 40 layers across 8 ranks. That diagnostic used a different quantization route from the AllGather comparison above. The full-model results leave output differences to resolve on the final branch with a fixed engine seed, including an AllGather repeat.

Six CPU tests cover opt-in, fixed-worker startup, packed expert requirements, weight packing, live rows and the ignored route on an idle rank.

python -m pytest -q test/registered/unit/moe/test_ascend_deepgemm_prefill.py

Speed Tests and Profiling

Eight Ascend 950DT cards, CANN 9.3.0-beta.1, torch-npu 2.13.0, DeepSeek-V4.1-Flash, real model routing, 384 routed experts plus 32 static replicas. Each arm timed 10 steps and 327,680 new input tokens. Throughput is new input tokens divided by the common elapsed time across all eight ranks and by eight cards.

Metric AscendOps AllGather DeepGEMM prototype Change
New input tokens/s/NPU 13,035.87 15,872.72 +21.8%
Mean common step time 314.230 ms 258.091 ms −17.9%
Offline first-token P50 313.958 ms 257.830 ms −17.9%
Requests completed 80/80 80/80

The offline prototype recorded 3,200 provider calls over 40 routed layers. It used a DeepGEMM-Ascend build with BF16 rounding at the SwiGLU boundary and router weights applied after the down projection. These are prototype measurements. The exact integration and a pinned vendor build still need a device run. DeepGEMM-Ascend base revision

Reproduce on one eight-card host

Run AllGather, the DeepGEMM provider and an AllGather repeat in separate Prefill processes. Keep the runtime, model, ranks, routing, cache settings and engine seed fixed across runs. For AllGather, use {"prefill":"allgather"} as the AscendOps configuration.

Prime a distinct 124K prefix on each attention-DP rank. Send eight simultaneous /generate requests with max_new_tokens=1, routed_dp_rank and a fresh 4K suffix. Omit bootstrap_host. Check each response for 131,072 input tokens, 126,976 cached tokens and one output token. Use the same input sequence and warmup in each run. Measure client latency and common burst wall time separately from the offline engine metrics above. One-token Prefill endpoint

Checklist

  • Provider CPU tests and local lint.
  • Documented opt-in and supported launch settings.
  • Eight-card run of this branch with the pinned vendor build.
  • Fixed-seed AllGather repeat and DeepGEMM accuracy and throughput comparison.

CI States

Latest PR Test (Base): ❔ Run #47058759173
Latest PR Test (Extra): ❔ Run #47058763177
Latest PR Test (AMD ROCm 10): ⊘ Skipped -- the PR is a draft; marking it ready starts a new run (AMD: then /rerun-failed-ci).

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant