Nemo Mbridge Perf Moe Long Context

nvidia/skills/skills/nemo-mbridge-perf-moe-long-context

作者 nvidiacf5224d14250Apache-2.03.5K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Long-context MoE training guidance for Megatron Bridge. Covers CP sizing, selective recompute, dispatcher choices, and practical patterns from DSV3, Qwen3, and Qwen3-Next long-context experiments.

僅含說明AI & Agents
AI 產生的概覽

為 Megatron Bridge 的長上下文 MoE 訓練提供設定指引,涵蓋上下文平行、重計算、調度器與常見陷阱。

功能
此技能為在 Megatron Bridge 中以長序列長度訓練混合專家(MoE)模型提供書面指引。它說明注意力記憶體與活化值駐留如何成為主要瓶頸,並給出上下文平行規模估算、選擇性重計算與完全重計算的取捨、調度器與管線配置選擇,以及 CUDA Graph 使用的經驗法則。它也列出 DSV3 與 Qwen3 模型在 128K 與 256K 下的代表性設定組合,以及常見陷阱。其產出是建議與設定模式,而非程式碼或檔案。
適用情境
適用於以長序列長度訓練 MoE 模型,或排查導致長上下文 MoE 記憶體不足、吞吐量下降的變更時。在為 128K 等級訓練選擇上下文平行規模、重計算設定或調度器時也適用。
執行需求
不需要指令碼或工具,僅為說明與參考資料。它依路徑引用配套文件與另一個技能,並假定使用者熟悉 Megatron Bridge 的訓練設定。

MoE Long-Context Training

Stable docs: @docs/training/moe-optimization.md Card: @skills/nemo-mbridge-perf-moe-long-context/card.yaml

What Changes At Long Context

Once sequence length moves well past the 4K-class regime, attention memory and activation residency become the dominant constraints. For MoE models, that usually means you need some combination of:

  • context parallelism
  • selective recompute
  • lower precision
  • CPU offload for optimizer state
  • a dispatcher and PP layout that do not waste the smaller remaining DP budget

Rounded Scaling Patterns

DSV3 on H100

The DSV3 long-context runs show a stable pattern:

  • selective recompute works better than full recompute once you move past the shortest contexts
  • throughput stays in a fairly narrow band from mid-length through very long contexts if CP is increased appropriately
  • the trade shifts from "memory fit" to "GPU-count feasibility" as CP grows

In other words, long context does not immediately collapse utilization if the layout is chosen well, but it does consume the DP budget very quickly.

Qwen3-Next on GB200

Qwen3-Next behaves more like a memory-sensitive medium-scale model:

  • 8K and 32K remain practical with moderate CP
  • 64K is possible, but the throughput drop is noticeable and memory becomes much tighter
  • pipeline layout and grouped-GEMM improvements matter almost as much as CP

Qwen3 235B on GB200

Qwen3 235B shows that long context can still be efficient on NVL72 systems when TP, CP, and HybridEP are coordinated. The best 128K-class configurations are not just "fit-only" recipes; they can remain highly efficient if routing, parallelism, and recompute are balanced.

CP Sizing Rules Of Thumb

  1. Start from a 4K shard target: a good first guess is CP ~= seq_len / 4096, then round to a practical power-of-two layout.

  2. Keep DP alive if possible: long-context scaling becomes brittle once CP, EP, TP, and PP together squeeze DP down to the floor.

  3. Prefer selective recompute: recompute modules such as up_proj, norm, moe, moe_act, or mlp before reaching for full recompute.

  4. Avoid SDPA-heavy recompute at very long context: recomputing attention internals can add a lot of work for less memory benefit than recomputing smaller MoE and MLP-side modules.

  5. Use TP as another lever on NVL72 systems: GB200 and GB300 runs can sometimes trade some CP for TP while still staying efficient.

  6. Assume GBS will need to shrink: as CP rises and DP falls, you may need to reduce global batch size or accept higher GA.

Representative Config Families

DSV3 at 128K on H100

text
TP=1  CP=32  EP=32  PP=8  VPP=4Precision: FP8-classDispatcher: DeepEPRecompute: up_proj, norm, moe, mlpExtra memory help: optimizer CPU offload

DSV3 at 256K on H100

text
TP=1  CP=64  EP=32  PP=8  EDP=2  VPP=4Precision: FP8-classDispatcher: DeepEPRecompute: up_proj, norm, moe, mlpExtra memory help: optimizer CPU offload

Qwen3 235B at 128K on GB200

text
TP=4  CP=4  EP=32  PP=4  VPP=12Precision: BF16 or MXFP8Dispatcher: HybridEPRecompute: moe_act, normCUDA Graph: attn + moe_router + moe_preprocess

Recompute And CUDA Graph Guidance

For long-context MoE training:

  • start with selective recompute
  • add CUDA graphs only after the shapes and routing path are stable
  • keep sequence length and MBS fixed when using CUDA graphs
  • if the run depends on highly dynamic batches, prefer eager execution

Useful references:

  • @docs/training/activation-recomputation.md
  • @skills/nemo-mbridge-perf-cuda-graphs/SKILL.md

Pitfalls

  1. CP does not replace EP or PP: it adds another dimension; it does not make the others disappear.

  2. A good 4K baseline can still be a bad long-context baseline: routing mode, recompute choice, and offload strategy often need to change.

  3. GPU-count feasibility becomes the real constraint: very long context can look fine in a single recipe, then become impossible once EP and PP are added honestly across the full model.

  4. CUDA graphs need static shapes: variable-length batches and opportunistic padding strategies can silently break the path.

  5. Container and kernel support matters more at 128K+: long-context paths tend to rely on newer kernels and bug fixes than short-context bring-up does.

來源與署名

來源:nvidia/skills位於skills/nemo-mbridge-perf-moe-long-context提交cf5224d

授權條款: Apache-2.0

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架