Conversation
ShilohYu
force-pushed
the
feat/ultraep
branch
5 times, most recently
from
September 17, 2026 05:40
ae7d6f5 to
f73980c
Compare
Add compile-compatible random-logits routing for balanced benchmark runs.
Integrate UltraEP as an opt-in MoE execution path for DeepEP-based expert parallel training, and move autograd hooks to the decoder so replica weights are not snapshotted. Supported in this initial integration: - dispatcher="deepep" with ep_size > 1 - BF16 grouped experts without expert bias - intra_layer_micro_batch == 1 - DP=1, where the EP group covers the whole world - runtime-owned redundant expert weight/grad buffers outside model parameters, optimizer state, and checkpoints - UltraEP placement/reroute, replica weight sync, fused master+replica grouped GEMM, and replica grad reduce for the single-microbatch training path Not supported yet: - intra_layer_micro_batch > 1 - activation recompute with UltraEP - MTP expert layers with UltraEP - dispatcher="all2all" or dispatcher="agrs" - FP8 grouped experts - expert bias - DP>1/FSDP gradient-reduction ordering
Use the externally packaged TEGroupedGEMM backend through a dedicated XTuner adapter. Convert host-side token counts to m_splits, preserve master and UltraEP replica weight and gradient handling, and select the TE backend through get_group_gemm. Co-authored-by: Cursor <cursoragent@cursor.com>
Give each in-flight micro-batch its own virtual-layer id and replica slot so weight-sync, restore, and grad-reduce stay correct when intra_layer_micro_batch > 1. Co-authored-by: Cursor <cursoragent@cursor.com>
Bind local FSDP expert shards into UltraEP and skip unchanged weight pointer refresh after reshard. Co-authored-by: Cursor <cursoragent@cursor.com>
Add lightweight phase markers so disabled NVTX ranges stay cheap.
… dispatcher Create UltraEPModelRuntime in the dispatcher factory and move placement, sync, restore, and grad-reduce onto a composite dispatcher so the decoder no longer names UltraEP. prepare_layer_inputs validates the constructor-time slot width instead of growing it. Co-authored-by: Cursor <cursoragent@cursor.com>
Publish the MoonEP-shaped layout envelope for TE grouped GEMM, but leave UltraEP replica slots out of compiled MoEBlock so later-layer slot reuse does not trip torch.compile. Co-authored-by: Cursor <cursoragent@cursor.com>
Preserve ordinary MoE list-forward behavior while keeping UltraEP capacity validation in its runtime. Fix grouped-GEMM test inputs, optional TE coverage, backend environment isolation, and lint/type issues. Add opt-in eight-GPU EP8 and EP4/DP2 regression tests covering multiple microbatches, gradient accumulation, optimizer updates, and coordinated native teardown. Document the setup and numerical comparison limits. Validation: 78 targeted tests and 2 eight-GPU integration tests passed; 61 tests passed and 17 skipped without TE. Ruff, formatting, and Pydantic checks passed. Mypy adds no errors versus the same-environment baseline.
ShilohYu
force-pushed
the
feat/ultraep
branch
from
September 17, 2026 09:35
ca22c05 to
a836ea6
Compare
ShilohYu
force-pushed
the
feat/ultraep
branch
from
September 17, 2026 09:45
a836ea6 to
ad7c2a4
Compare
ShilohYu
commented
Sep 18, 2026
| else: | ||
| process_group = ep_group | ||
| # TODO: remove type ignore here | ||
| # TODO: remove ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
在 MoE Expert Parallel(EP)训练中,router post-gating 后的专家负载不均衡会使端到端吞吐受最慢 rank 限制。UltraEP 根据当前 layer / microbatch 的实际负载创建热点专家副本,并将部分 token 重路由到 replica slot。
本 PR 将 UltraEP 作为 Xtuner 的可选运行时接入,同时保持职责边界:
主要改动
UltraEP runtime
MoEConfig.ultraep_cfg和UltraEPManager;TE grouped GEMM
XTUNER_GROUP_GEMM=te启用 TEGroupedGEMM adapter;XTUNER_TE_GEMM_BACKEND=auto|cublas|cutlass|torch进一步选择 TE 内部 backend。支持范围
当前已验证单机八卡下EP8×DP1 单microbatch/多microbatch、FSDP EP4×DP2设置,底层dispatcher为deepep。暂不支持 activation recompute、MTP expert layers、
all2all/agrsdispatcher、FP8 grouped experts 和 expert bias。实验结果
实验使用单机 8×H200、DeepEP、BF16、torch.compile 和缩小 Qwen3-235B-A22B 结构。正式 timing 使用 25 steps,step 1–5 warmup,step 6–25 统计。
EP8×DP1,single-microbatch
UltraEP on 相比 UltraEP off:
baseline、UltraEP off 和 UltraEP on 的 loss 曲线稳定下降,未观察到 NaN、Inf 或异常发散。force-balanced 用于均衡性能上限参考,不作为正常路由正确性基线。
FSDP EP4×DP2
该实验验证 FSDP local expert shard、
reshard_after_forward=True、TE grouped GEMM 以及 UltraEP/FSDP gradient reduce 顺序。UltraEP on 相比 UltraEP off:
EP8×DP1,multi-microbatch(MB=2)
UltraEP on 相比 UltraEP off:
该配置下 UltraEP on/off 的 loss trajectory acceptance threshold 已通过