Repository navigation
Add fused-MoE routed experts and rowwise FP8 - #735
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c43f01061
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Routed-expert MLP (grouped-GEMM up/gate + down with SwiGLU) and the rowwise-FP8 config + machinery it builds on. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Guard the optional nvtx import (olmo_core._nvtx fallback) in both files. - routed_experts: except Exception -> except ImportError on the grouped_gemm guard; document build(); drop a stale :param d_model: on num_params(); add the v2-config dimension-field divergence note. - fp8: mark MoERowwiseFP8Config @beta_feature, Tuple -> tuple. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Config validation/normalization, RoutedExperts construction + fp8-only weight-store grad handling, the FP8 weight store, and the block-level rowwise-FP8 cache-refresh logic (via lightweight fakes). GPU/compute-only paths are gated with @requires_gpu. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
0c43f01 to
a02e86f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a02e86f7fc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Port the routed-experts forward correctness tests: the grouped-GEMM expert MLP matches a naive per-expert reference, and the output is invariant to pad-token positions within each expert's token block. Gated with @requires_gpu / @requires_grouped_gemm / @requires_te (the grouped-mm forward and the TE permute used to set up routing are GPU-only). The pad-position perf benchmark is omitted. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8f20e349a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Document the rowwise-FP8 scale-mode enum and its rceil member, matching the documented StrEnum enums elsewhere in the codebase. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…document EP/fp8 caveats - P1: initialize expert weights in __init__ via reset_parameters (trunc_normal_, std=0.02) — they were left as raw torch.empty, so a from-scratch build fed uninitialized w_up_gate/w_down into forward. Add a build-initializes-weights regression test. - P2: raise a clear error in gmm() when neither torch>=2.10 grouped_mm nor the grouped_gemm package is available, instead of an AttributeError. - Document (in-code NOTEs) the by-design / dormant items: apply_ep allocates fresh sharded storage filled later by init_moe_v2/checkpoint load (parallelize-then-init), and its ep_dp/ep_mp mesh dim names need reconciling with the repo EP mesh builder when the EP train-module lands; and the fp8_only_params bf16-fallback guard needs a grad-context-aware extension (deferred to the GPU FP8 pass). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replace the use_torch_grouped_mm machinery (manual torch.__version__ parse, the OLMO_USE_TORCH_GROUPED_MM env override, and the cached module globals) with plain hasattr(F, "grouped_mm") feature detection — grouped_mm is a torch-2.10 addition, so the attribute check is the gate, matching olmo_core.testing.has_torch_grouped_mm. The env override was unused anywhere in the repo or the dev branch. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Rewrite the rambling "BIG NOTE"/WARNING about grouped_mm's uninitialized padding rows into a concise NOTE, and collapse the three module-level _debug_* nan/inf helpers (only ever referenced from a commented-out assertion) into a single commented debug snippet inline. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Convert the field-explanation # comments to attribute docstrings (placed below each field), matching the codebase convention (e.g. MoERouterConfig, MoERouterConfigV2) so Sphinx documents them. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
fp8.py now keeps only the config surface routed_experts needs
(MoERowwiseFP8ScaleMode, MoERowwiseFP8Config, normalize_rowwise_fp8_config).
The functions that operate on a MoEFusedV2TransformerBlock — the
reset_/invalidate_/refresh_*_rowwise_fp8_cache helpers and the
shared_experts_forward{,1,2}_rowwise_fp8 forwards — are removed and will
land with block.py, where they're actually used and testable. Trim the now
unused imports (nvtx, scaled-grouped-mm kernels, the TYPE_CHECKING block
ref) and drop the 3 test_block_refresh_* tests that exercised the removed
machinery via fakes.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa717a5817
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The third-party grouped_gemm op requires bf16, so the torch<2.10 fallback would fail for a float32-built RoutedExperts. Flag with a TODO (cast like the v1 DroplessMoEMLP path) rather than fixing now, since v2 targets torch 2.10 (the grouped_mm path). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
It was only needed for the TYPE_CHECKING block annotation, which was removed with the block-coupled functions. The remaining X | Y union annotation evaluates natively on Python 3.10+ (our minimum), and the sibling v2 files don't use it. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adds the routed-expert MLP and the rowwise-FP8 config + machinery it builds on.
routed_experts.py—RoutedExperts/RoutedExpertsConfig: grouped-GEMM up/gate + per-expert down projection with SwiGLU, plus optional rowwise-FP8 expert weights (prequantized RHS caching, fp8-only-param weight stores).fp8.py—MoERowwiseFP8Config(validation + runtime-support checks) and the cache-refresh/invalidation helpers used to keep prequantized FP8 weights in sync.MoERowwiseFP8Configis marked@beta_feature.Tests cover config validation/normalization,
RoutedExpertsconstruction and fp8-only weight-store gradient handling, the FP8 weight store, and the cache-refresh logic (via lightweight fakes). FP8/compute-capability paths are gated with@requires_gpu.🤖 Generated with Claude Code