Moonshot AI、MoE 学習向け Expert Parallelism ライブラリ「MoonEP」を公開
Moonshot AI は大規模 MoE モデルの学習効率を向上させる Expert Parallelism ライブラリ「MoonEP」を MIT ライセンスで公開し、通信の不均衡を解消する動的冗長専門家機構を採用した。
AI深層分析を開く2026年7月30日 15:16
AI深層分析
キーポイント
Expert Parallelism の不均衡問題への対応
従来の Expert Parallelism ではルーターの偏りにより一部の専門家が過負荷になるが、MoonEP はこの「最大違反度(maxvio)」を定量化し、構造的な遅延の原因となる不均衡を解消する。
動的冗長専門家による完全バランスの実現
各ランクが常に S × K トークンを処理するという不変条件を達成するため、ルーター出力に基づいてオンラインで少数の冗長専門家を計画し、事前フェッチと勾配還流を行う。
メモリ効率と計算性能の最適化
ゼロコピー転送と静的形状(static shapes)を採用することで GPU メモリの断片化を防ぎ、レイヤーごとのホスト同期を不要にするため、Kimi K3 モデルのスケーリング効率が 2.5 倍向上した。
対称メモリと連続性による効率的なGEMM
各専門投影には1つの連続した対称メモリ重みテンソルが必要であり、これによりグループGEMMは行インデックスのみで専門をアドレスできる。
事前フェッチスロットの共有と設定
事前フェッチスロットは全層にわたるプロセスグローバルプールから共有され、トレーニングではB=E/R、推論では推奨値3-4が用いられる。
重要な引用
MoonEP is one of the innovations behind a claimed 2.5× improvement in scaling efficiency for Kimi K3
Every rank receives exactly S × K tokens, no matter how skewed the routing is
Imbalance costs are structural, not incidental
MoonEP claims every EP rank receives exactly S × K tokens, regardless of router skew.
編集コメントを表示
編集コメント
Kimi K3 の技術報告と併せて公開された MoonEP は、MoE モデルのトレーニング効率化における重要な実装例を示している。特に通信不均衡を動的に解決する手法は、大規模モデル開発において即座に参照価値を持つ技術的知見である。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
Moonshot AI は、分散型の Mixture-of-Experts (MoE) ワークロード向けに設計された Expert Parallelism (EP) 通信ライブラリ「MoonEP」をオープンソース化しました。このリリースは、大規模な環境におけるエキスパート並列通信の効率化を目指して構築されたものです。ライセンスは MIT です。
MoonEP は Kimi K3 Open Day の一環として発表されました。K3 モデルの重みと技術レポートに加え、Moonshot 社は 3 つのインフラストラクチャコードベースを公開しました。それが MoonEP、FlashKDA、そして AgentEnv です。FlashKDA はすでにオープンソース化されていましたが、MoonEP と AgentEnv は今回のリリースで新たに公開されました。MoonEP は、ネイティブな視覚機能と 100 万トークンのコンテキストウィンドウを備えた 2.8 兆パラメータの MoE モデル「Kimi K3」において、スケーリング効率を 2.5 倍向上させたという成果の背景にある技術革新の一つです。
MoonEP が解決する課題
エキスパート並列化では、ルーターが各トークンをトップ K のエキスパートに振り分けます。これらのエキスパートは異なる計算ノード(ランク)上に配置されています。しかし、実際の運用ではルーターのバランスが取れていないケースがほとんどです。特定のエキスパートに集中して多くのトークンが割り当てられ、他のエキスパートにはあまり回らないという偏りが生じます。
このリポジトリでは、最大値偏差 (maxvio) を用いてこの偏りを定量化しています。maxvio は「max_e (T_e / T̄) − 1」と定義されます。ここで T_e はエキスパート e に割り当てられたトークン数、T̄は完全なバランスが保たれている場合に期待されるトークン数を表します。maxvio が 0 の場合、それは完璧にバランスが取れていることを意味します。
この不均衡によるコストは、偶発的なものではなく構造的な問題です。並列処理のレイテンシは最も遅い参加者によって決定されるため、最も負荷の高いランクが全体の反復時間を支配してしまいます。さらに深刻なのは、各ステップでランクあたりのトークン数が変動することです。この動的に変わる活性化形状が GPU メモリを断片化させ、層ごとのホスト同期を余儀なくさせています。
核心となるアイデア:動的な冗長エキスパート
MoonEP の中核となるのは、厳格な不変条件です。ルーティングがどれだけ偏っていても、すべてのランクは必ず S × K トークンを受け取ります。ここで S は各ランクあたりの入力トークン数、K は各トークンに対してルーティングされる上位 k 個のエキスパート数を表します。
これを実現するために、MoonEP は現在のルーター出力から直接、少数の冗長なエキスパートをオンラインで計画します。重複したエキスパートは計算前に事前フェッチされます。逆伝播では、これらのエキスパートに対する勾配が元のホームランクに集約されます。
この設計は以下の 3 つの特徴に基づいています。
完璧なバランス:上記の S × K の保証を実現するために、オンラインで計画された冗長エキスパートを活用します。
オンライン計画:オーバーヘッドを無視できるほど小さい、ほぼ最適化された GPU プランニングカーネルです。CUTLASS CuTe DSL で実装されており、setup.py によって nvidia-cutlass-dsl==4.4.2 が固定されています。
ゼロコピーと静的形状:結合された並べ替え/元に戻す処理が行われます。トークンはリモートランク上のエキスパートグループ化された位置に直接書き込まれ、計算用バッファビューが返されます。必要なのは固定サイズの S × K バッファのみで、層ごとの MoE におけるホスト同期を不要にするために形状は静的に知られています。
以下の対話型エクスプローラーでは、ユーザーが設定した構成から、結果として得られるバッファサイズと事前フェッチプールサイズをリアルタイムで計算します。
window.addEventListener("message",function(e){
if(e.data&&e.data.mepFrame==="mep1"){
var f=document.getElementById("mep1-frame");
if(f) f.style.height=e.data.height+"px";
}
});
メモリ契約
MoonEP とトレーニングまたは推論フレームワークの契約は、特定の形式に厳格に従います。各エキスパート投影に対して、対称メモリ上の連続した 1 つの重みテンソルと、プランナーが生成する cu_seqlens を用意します。VM グループ GEMM は、[E+B, H, H'] の形状を持つ単一の重みテンソルを消費します。ここで E はルーティングされるエキスパートの総数、B はランクあたりのプリフェッチスロット数、H は隠れ層サイズ、H' はエキスパート FFN の中間サイズを表します。dispatch によって返される cu_seqlens[E+B] が、どのエキスパート行がアクティブかを指定します。
連続性は必須条件です。グループ GEMM は、エキスパートを純粋に行インデックスで参照するからです。このレイアウトは明確に分割されます。
行 [0, E) には全ランクのローカルエキスパートが格納され、各ランクは E/R 行ずつを担当します。各チャンクは物理的にはホームランクのパラメータメモリであり、対称メモリを通じてどこからでもマッピング可能です。
行 [E, E+B) はローカルのプリフェッチスロットで、buffer.prefetch_weight によって埋められます。
これらのプリフェッチスロットは、全レイヤーで共有されるプロセスグローバルなプールから供給されます。この仕組みが重要なのは、追加のメモリコストがレイヤーごとに発生するのではなく、投影全体で B 個分のエキスパート重みだけになる点です。
B の値はワークロードに応じて設定します。トレーニングでは B = E/R を使用します。プランナーは各ランクあたり最大 1 つの遠隔ホームグループからのみエキスパートを複製するため、この上限を設定することで、グループ GEMM がアクセスするすべてのエキスパートがローカルに存在することが保証されます。
推論では B < E/R も可能です。README では B = 3〜4 を推奨しています。もしあるランクで必要な遠隔エキスパートの数が B を超える場合、グループ GEMM は対称マッピングを通じてホームランクからオーバーフローした重みを直接読み込みます。わずかに速度は低下しますが、正しさには影響しません。
fp32 でのトレーニングでは、各投影に対して [E+B, H, H'] の勾配バッファが重みレイアウトと同期されます。重要なのは、行 [E, E+B) がパラメータ勾配ではなく、独立したリダクションバッファによってバックアップされている点です。重複する専門家の勾配は一時的なものであり、フレームワーク自身の勾配集約からは隠蔽される必要があります。各ランクはすべての R 個のリダクションバッファを [R, B, H, H'] のビューとしてマッピングし、reduce_grad は NVLink を介して全ランクから自らの専門家のスロットを読み取り、ローカルなパラメータ勾配に累積した上で、消費されたスロットをゼロクリアします。
DeepEP v2 に対するベンチマーク結果
公開されている両方のベンチマークは H20 で EP=8 の条件下で実行され、ルーターの不均衡を変化させながら評価されています。比較用スクリプト benchmarks/bench_vs_deepep.py は、デフォルトで S=8192、E=384、H=7168、K=8、H'=2048、SM 数 32 を設定し、最大不均衡(maxvio)のターゲットとして 0.2、1、10、20 を指定します。両ライブラリとも、共通のシードから生成された同一のルーティング行列を受け取ります。
GitHub ページで報告された主な知見は以下の通りです。ゼロコピー機能により、エピローグを支配する「通信バッファからユーザーバッファへの転送」が不要になるため、MoonEP の通信時間は不均衡レベルに関わらず常に DeepEP v2 を下回ります。また、完全なバランス設計により MoonEP はスキューの影響を受けにくく、maxvio が大きくなっても通信時間がほぼ一定に保たれるのに対し、最も遅いランクのレイテンシによって決定される DeepEP v2 は性能が徐々に低下します。
キーポイント
MoonEP では、ルーターの不均衡に関わらず、すべての EP ランクが正確に S × K トークンを処理すると主張しています。
このバランスは、オン GPU でオンライン計画された冗長な専門家によって実現され、専門家の計算前に事前フェッチされます。
静的形状(Static shapes)を採用することで、MoE における層ごとのホスト同期が不要になり、DeepEP が引き起こすメモリの断片化による OOM(Out Of Memory)エラーを防ぐことができます。
トレーニング時には B = E/R のプリフェッチスロットが必要ですが、推論では正解性に影響を与えることなく、B を 3〜4 に減らすことが可能です。
Kim K3 Open Day で MIT ライセンスの下に公開され、FlashKDA や AgentEnv と同時にリリースされました。
出典:GitHub の MoonshotAI/MoonEP および @Kimi_Moonshot の発表
この記事は MarkTechPost に掲載された「Moonshot AI が MoE 学習用の完璧なバランスの取れたエキスパート並列化ライブラリ MoonEP をオープンソース化した」という記事の翻訳です。
原文を表示
Moonshot AI has open-sourced MoonEP, an Expert Parallelism (EP) communication library for distributed Mixture-of-Experts (MoE) workloads. The team announced the release as a library built to make expert-parallel communication more efficient at scale. It ships under an MIT license.
MoonEP arrived as part of Kimi K3 Open Day. Alongside the K3 model weights and technical report, Moonshot released three infrastructure codebases: MoonEP, FlashKDA, and AgentEnv. FlashKDA had already been open-sourced; MoonEP and AgentEnv were published with this release. MoonEP is one of the innovations behind a claimed 2.5× improvement in scaling efficiency for Kimi K3, a 2.8-trillion-parameter MoE model with native vision and a 1M-token context window.
The problem MoonEP targets
In expert parallelism, a router sends each token to its top-K experts, which live on different ranks. Routers are rarely balanced. Some experts get far more tokens than others.
The repository quantifies skew with maxvio, defined as max_e (T_e / T̄) − 1, where T_e is tokens routed to expert e and T̄ is the expected count under perfect balance. A maxvio of 0 means perfectly balanced.
Imbalance costs are structural, not incidental. A collective’s latency is set by its slowest participant, so the hottest rank determines iteration time. Worse, token counts per rank change every step. Those dynamic activation shapes fragment GPU memory and force per-layer host synchronization.
The core idea: dynamic redundant experts
MoonEP’s main mention is a hard invariant. Every rank receives exactly S × K tokens, no matter how skewed the routing is — where S is input tokens per rank and K is routed top-k per token.
It achieves this by planning a small number of redundant experts online, directly from the current router outputs. Those duplicated experts are prefetched before expert computation. In the backward pass, their gradients are reduced back to their home ranks.
The design is set up into three properties:
Perfect balance: the S × K guarantee above, via online-planned redundant experts.
Online planning: a near-optimal GPU planning kernel with negligible overhead. It is implemented in the CUTLASS CuTe DSL; setup.py pins nvidia-cutlass-dsl==4.4.2.
Zero copy and static shapes: fused permute/unpermute. Tokens are written directly into their expert-grouped positions on remote ranks, and buffer views are returned to the computation. Only a fixed S × K buffer is needed, and statically known shapes eliminate per-layer MoE host synchronization.
The interactive explainer below computes the resulting buffer and prefetch-pool sizes live from a config you control.
window.addEventListener("message",function(e){
if(e.data&&e.data.mepFrame==="mep1"){
var f=document.getElementById("mep1-frame");
if(f) f.style.height=e.data.height+"px";
}
});
The memory contract
MoonEP’s contract with a training or inference framework is specific: one contiguous symmetric-memory weight tensor per expert projection, plus a planner-produced cu_seqlens. The VM group GEMM consumes a single [E+B, H, H'] weight tensor, where E is total routed experts, B is prefetch slots per rank, H is hidden size, and H' is the expert FFN intermediate size. The cu_seqlens[E+B] returned by dispatch selects which expert rows are active.
Contiguity is a hard requirement, because the group GEMM addresses experts purely by row index. The layout splits cleanly:
Rows [0, E) hold all ranks’ local experts, E/R rows per rank. Each chunk physically is the home rank’s parameter memory, mapped everywhere via symmetric memory.
Rows [E, E+B) are local prefetch slots, filled by buffer.prefetch_weight.
The prefetch slots draw from a process-global pool shared by all layers. That detail matters: the extra memory cost is B expert weights per projection in total, not per layer.
How you set B depends on the workload. Training must use B = E/R, because the planner duplicates experts from at most one remote home group per rank. That bound guarantees every expert the group GEMM touches is local. Inference allows B < E/R, and the README recommends B = 3–4. If a rank needs more distinct remote experts than B, the group GEMM reads overflow weights straight from the home rank through the symmetric mapping — slightly slower, with no impact on correctness.
Training mirrors the weight layout in fp32 with a [E+B, H, H'] grad buffer per projection. Critically, rows [E, E+B) are backed by a separate reduce buffer, not by the parameter grads. Duplicated experts’ gradients are temporary and must stay invisible to the framework’s own grad reduce. Each rank maps all R reduce buffers as one [R, B, H, H'] view, then reduce_grad reads its own experts’ slots from every rank over NVLink, accumulates into the local parameter grad, and zeroes consumed slots.
Benchmarks against DeepEP v2
Both published benchmarks run on H20 with EP=8, sweeping router imbalance. The comparison script benchmarks/bench_vs_deepep.py defaults to S=8192, E=384, H=7168, K=8, H'=2048, and 32 SMs, with maxvio targets of 0.2, 1, 10, and 20. Both libraries receive an identical routing matrix from a shared seed.
Three findings were reported on their github page. Zero copy makes raw communication faster by eliminating the comm-buffer → user-buffer copy that dominates the epilogue, so MoonEP’s comm time sits consistently below DeepEP v2 at every imbalance level. Perfect balance makes MoonEP nearly immune to skew: its comm time stays almost flat as maxvio grows, while DeepEP v2 — whose latency is set by the hottest rank — degrades steadily.
Key Takeaways
MoonEP claims every EP rank receives exactly S × K tokens, regardless of router skew.
Balance comes from redundant experts planned online on-GPU, then prefetched before expert compute.
Static shapes remove per-layer MoE host sync and stop the memory fragmentation that OOMs DeepEP.
Training requires B = E/R prefetch slots; inference can drop to B = 3–4 with no correctness cost.
Released MIT under Kimi K3 Open Day, alongside FlashKDA and AgentEnv.
Sources: MoonshotAI/MoonEP on GitHub and @Kimi_Moonshot announcement
The post Moonshot AI Open-Sources MoonEP: A Perfectly Balanced Expert Parallelism Library for MoE Training appeared first on MarkTechPost.
AI算出
主要ニュースainew評価標準
MoE モデルの並列処理における不均衡問題を解決する独自技術(動的冗長エキスパート)と、Kimi K3 モデルでの実証結果(スケーリング効率 2.5 倍向上)を報じており、新規性の高い技術発表である。
6つの評価軸を見る
- AI関連度
- 100
- 情報源の信頼性
- 25
- 新規性
- 75
- 調べる価値
- 75
- 重複の少なさ
- 100
- 日本での有用性
- 25
関連記事
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み