Skip to content

[ROCm][Perf][DSv4.1] Support dynamic EPLB with AITER MegaMoE - #70258

Draft
shen-shanshan wants to merge 1 commit into
vllm-project:mainfrom
shen-shanshan:rocm-dsv41-mega-moe-eplb
Draft

shen-shanshan wants to merge 1 commit into
vllm-project:mainfrom
shen-shanshan:rocm-dsv41-mega-moe-eplb

Conversation

@shen-shanshan

@shen-shanshan shen-shanshan commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Overview

Enable --enable-eplb (with or without redundant experts) for DeepSeek-V4.1 on ROCm with --moe-backend aiter_mega_moe, which previously refused EPLB. Target deployment: DEP8 on MI355X (SemiAnalysisAI/InferenceX#5056).

Claims

  • DeepSeek-V4.1 with AITER MegaMoE serves with --enable-eplb and any num_redundant_experts; load is recorded and live rearrangements keep outputs correct.
  • GSM8K accuracy with EPLB on matches EPLB off within run-to-run noise.
  • With EPLB off, the MegaMoE forward path is unchanged.
  • Only ROCm DeepSeek-V4 / V4.1 model code changes.

Validation

Unit tests (MI355X): pytest tests/models/test_deepseek_v4_aiter_mega_moe.py -q — 25 passed. New cases cover redundant-slot weight loading, get_expert_weights views (3-D weights and 2-D shuffled scales), and the placement kernel vs a torch reference (replica choice, load recording, fused-shared dispatch).

E2E (8×MI355X, DeepSeek-V4.1-Flash, DEP8). Server = override_dep8_c256 of InferenceX#5056 (TP1 × DP8 + EP, --all2all-backend mori --moe-backend aiter_mega_moe, DSpark 5 tokens, fp8 KV), EPLB config {"window_size":100,"step_interval":200,"use_async":false,"communicator":"torch_nccl"}. GSM8K: lm-eval gsm8k 8-shot, 1319 questions, 64 concurrent (settings of DeepSeek-V4-Flash-MXFP4.yaml); the first live rearrangement lands ~40% into the eval.

Config Smoke (temp 0 arithmetic) GSM8K strict / flexible
EPLB off 384 / 384 0.9280 / 0.9295
EPLB on, num_redundant_experts=0 1152 / 1152 0.9363 / 0.9371
EPLB on, num_redundant_experts=8 768 / 768 0.9257 / 0.9257
EPLB on, num_redundant_experts=16 768 / 768 —

GSM8K stderr is ±0.007; all runs are within noise. Each live rearrangement takes ~1 s.

Overhead of idle EPLB (step_interval=1e9, nothing ever moves), vllm bench serve random 2048/1024, 2048 prompts at concurrency 512, runs 2–3 after warmup:

Metric EPLB off EPLB idle
Output throughput (tok/s) 21232 / 22105 21383 / 23227
Median TPOT (ms) 18.31 / 17.70 18.23 / 16.80
Median ITL (ms) 32.66 / 32.79 33.22 / 33.05

Throughput/TPOT differences are within run-to-run spread; median ITL is ~0.4 ms (+1.2%) higher, about 10 µs per MoE layer for the extra map-and-record launch. KV cache capacity drops 8% per rank (38.6M → 35.5M tokens) for the EPLB buffers.

AgentX DEP8 throughput, EPLB off vs on: <TODO: add AgentX benchmark>

Commands
VLLM_ROCM_USE_AITER=1 VLLM_ROCM_USE_AITER_MOE=1 VLLM_ROCM_QUICK_REDUCE_QUANTIZATION=NONE \
VLLM_ROCM_USE_AITER_TRITON_SPARSE_MLA=True VLLM_USE_BREAKABLE_CUDAGRAPH=1 OMP_NUM_THREADS=1 \
MORI_SHMEM_HEAP_SIZE=64G VLLM_RANDOMIZE_DP_DUMMY_INPUTS=1 \
vllm serve deepseek-ai/DeepSeek-V4.1-Flash \
  --language-model-only --tokenizer-mode deepseek_v41 \
  --attention-config '{"indexer_kv_dtype":"mxfp4","indexer_sparse_logits":true}' --block-size 128 \
  --speculative-config '{"method":"dspark","num_speculative_tokens":5,"draft_sample_method":"probabilistic","rejection_sample_method":"block","enable_adaptive_verification":false}' \
  --max-model-len 1048576 --gpu-memory-utilization 0.9 \
  --tensor-parallel-size 1 --data-parallel-size 8 --enable-expert-parallel \
  --all2all-backend mori --moe-backend aiter_mega_moe \
  --engram-config '{"cpu_offload":false,"embedding_across_dp":true}' \
  --max-num-seqs 128 --max-num-batched-tokens 32768 \
  --prefill-schedule-interval 96 --long-prefill-token-threshold 8192 \
  --max-cudagraph-capture-size 1024 --kv-cache-dtype fp8_e4m3 \
  --enable-eplb --eplb-config '{"window_size":100,"step_interval":200,"num_redundant_experts":8,"use_async":false,"communicator":"torch_nccl"}'

lm_eval --model local-completions \
  --model_args "model=deepseek-ai/DeepSeek-V4.1-Flash,base_url=http://localhost:8333/v1/completions,tokenizer_backend=None,num_concurrent=64,max_retries=3,tokenized_requests=False" \
  --tasks gsm8k --num_fewshot 8 --limit 1319 --batch_size 1

vllm bench serve --backend vllm --model deepseek-ai/DeepSeek-V4.1-Flash --port 8333 \
  --dataset-name random --random-input-len 2048 --random-output-len 1024 --ignore-eos \
  --max-concurrency 512 --num-prompts 2048 --seed 0 \
  --percentile-metrics ttft,tpot,itl --metric-percentiles 50,90,99

Details

In DEP8 every MegaMoE launch waits at combine for the most-loaded EP rank; EPLB evens this out by moving/replicating hot experts. DeepseekV4AiterMegaMoEExperts (vllm/models/deepseek_v4/amd/mega_moe.py) now plugs into the shared EPLB framework the same way DeepGemmMegaMoEExperts does on NVIDIA:

  • num_experts counts physical slots; weight_loader fills every local slot from EPLB's initial linear placement (physical p holds logical p % num_logical).
  • Adds set_eplb_state, get_expert_weights, update_expert_map, layer_id. get_expert_weights returns expert-major views (AITER's a16w4 shuffle keeps each expert contiguous); migration copies in place, so the shared MegaMoEV2 weight pointers and captured graphs stay valid.
  • New Triton kernel _eplb_place_experts_kernel (reusing eplb_map_and_record) maps logical routes to physical replicas, records load, and handles the fused-shared-expert dispatch in one launch. It is used only once EPLB registers the layer; otherwise the old _append_shared_expert_kernel path runs.
  • deepseek_v4/amd/model.py: computes logical/physical/redundant counts from eplb_config; EPLB requires expert_placement_strategy="linear"; V4 still refuses EPLB (no MixtureOfExperts). deepseek_v41/amd/model.py: sets supports_eplb = True, drops the hard-coded zero redundant experts, and errors clearly if EPLB is requested on the non-MegaMoE path.

Limitations:

  • DSpark draft MoE layers are not rebalanced (draft EPLB is already disabled on ROCm).
  • Without NIXL the default communicator is torch_gloo (CPU staging); validation used torch_nccl. A ROCm default is left to follow-up.
  • Padding inside the V4.1 bounded-replay sub-batch can still be counted as load, same as the NVIDIA MegaMoE path; a fix belongs in shared code.

Not a duplicate: #68385 tunes MegaMoE kernels without EPLB; #64835 / #68355 are NVIDIA-only.


Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

Let DeepSeek-V4.1 on ROCm run --enable-eplb with --moe-backend
aiter_mega_moe, following DeepGemmMegaMoEExperts:

- DeepseekV4AiterMegaMoEExperts counts physical slots (redundant ones
  included), loads each checkpoint expert into every local replica slot,
  and exposes set_eplb_state / get_expert_weights / update_expert_map.
- A Triton kernel maps logical routes to EPLB replicas, records load and,
  with a fused shared expert, appends the shared route in one launch; the
  old path runs unchanged until EPLB registers the layer.
- V4 keeps refusing EPLB on MegaMoE; V4.1's non-MegaMoE ROCm path raises
  a clear error.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: shen-shanshan <467638484@qq.com>
@shen-shanshan shen-shanshan changed the title [ROCm][Perf][DSv4.1] Support EPLB with AITER MegaMoE [ROCm][Perf][DSv4.1] Support dynamic EPLB with AITER MegaMoE Nov 27, 2026
@mergify mergify Bot added deepseek Related to DeepSeek models rocm Related to AMD ROCm labels Nov 27, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Nov 27, 2026

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

deepseek Related to DeepSeek models rocm Related to AMD ROCm

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant