[RFC] Define accelerator-agnostic backend boundaries for core MoE operations
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
調査の方向性
MoE層で使用されている既存のmegablocks.opsインターフェースから始め、そのrouting、permutation、grouped expert operationsを追跡します。実装前に、提案されているpure-PyTorchの参照動作とconformance-testの範囲を確認します。operation contractとreference testが定義され、dispatchおよびaccelerator固有の実装が独立したフォローアップ作業として残されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
MegaBlocks already exposes megablocks.ops as the interface used by its MoE layers, but it does not currently have a consistent internal boundary between operation semantics and accelerator-specific implementations. Routing metadata operations depend on the megablocks_ops CUDA extension, token permutation uses Triton kernels, and grouped expert computation depends on the CUDA-specific grouped_gemm package.
This RFC proposes explicit internal contracts for core operations and grouped GEMM. A pure-PyTorch reference implementation would define device-independent correctness behavior, while optimized accelerator implementations could be developed and reviewed independently.
Motivation
- #97 requests AMD and ROCm support. A maintainer noted that the remaining CUDA kernels could be replaced with Torch operations or Triton kernels and welcomed contributions.
- #182 explores pure-PyTorch routing and permutation implementations for NPU tensors while preserving the CUDA paths.
- #187 explores ROCm support through HIPification and build-system changes.
These efforts require common decisions about operation semantics, dispatch, optional dependencies, and conformance testing. Defining those boundaries once would reduce duplication and make accelerator support easier to review and maintain.
Proposed direction
The existing megablocks.ops functions would remain the interface used by MoE layers. Their input, output, dtype, autograd, and edge-case behavior would be defined explicitly. An internal dispatch mechanism would select implementations from tensor device and runtime capabilities.
A pure-PyTorch backend would serve as the conformance reference. It would not replace optimized implementations by default. Existing CUDA kernels would remain the optimized CUDA path. Grouped GEMM would use a separate provider contract because its implementation and dependency requirements differ from routing and permutation operations. The existing grouped and sparse choices would continue to describe algorithms rather than accelerator platforms.
Contribution approach
I will drive the implementation. If this direction is acceptable, I would begin with a change defining operation contracts and pure-PyTorch reference tests. Dispatch, dependency separation, and accelerator-specific implementations would follow as independent pull requests.
Feedback requested
Before implementation, I would appreciate the maintainers' feedback on whether these backend boundaries fit the intended direction of MegaBlocks and whether the proposed incremental contribution approach is suitable
AI tool use
- Grammarly was used to improve grammar and phrasing.
- Cursor was used to inspect this repository, trace accelerator-specific dependencies, and review the claims of this issue.
I reviewed the final content and take responsibility for the proposal and any subsequent contributions.
- 主要言語
- Python
- スター
- 1.6k
- フォーク
- 228
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
elviskahoro/sdk-python-attio#144 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
RenyiELBO raises TypeError when model has no sample sites対応中かも @alibb007 が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Four evaluation scripts unpack init_memmachine_params's five return values into three namesオープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
MemMachine/MemMachine#1911 ·
メンテナーはふだん 3 日以内に返信