Skip to content

Consolidate benchmark scripts under src/scripts/benchmarks#786

Merged
AkshitaB merged 7 commits into
akshitab/moe-v2-corefrom
akshitab/test-hygiene-rename-benches
Jul 21, 2026
Merged

Consolidate benchmark scripts under src/scripts/benchmarks#786
AkshitaB merged 7 commits into
akshitab/moe-v2-corefrom
akshitab/test-hygiene-rename-benches

Conversation

@AkshitaB

@AkshitaB AkshitaB commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Collect all benchmark/profiling scripts into a single src/scripts/benchmarks/
directory so they're easy to find and clearly separated from the test suite.

Changes

  • Relocate existing benches into src/scripts/benchmarks/:
    • benchmark_odc.pyodc_bench.py
    • all_reduce_bench.py (from src/scripts/train/)
    • routed_experts_fp8_bench.py, shared_experts_dense_bench.py,
      rowwise_alltoall_bench.py, rowwise_combine_fused_bench.py
      (from src/test/nn/moe/**)
  • Add MoE-v2 kernel microbenches: grouped-mm backend comparison, MXFP8
    quantize (plain / swizzle / weighted / scale-mode), scaled_grouped_mm_q,
    rowwise-FP8 dispatch/combine comm, fused restore+unpermute, and valid-prefix
    SwiGLU.

All are standalone CLI / torchrun scripts with no pytest test functions, so
they are no longer collected during test runs. In-file usage-example paths were
updated to match the new locations.

AkshitaB and others added 2 commits July 20, 2026 15:13
rowwise_alltoall_test.py and rowwise_combine_fused_test.py are standalone
torchrun benchmark scripts (argparse + main()), not pytest tests — they define
no test functions, so pytest collected them and found nothing. Rename them to
*_bench.py to match the existing benchmark-script convention (routed_experts_fp8_bench.py,
shared_experts_dense_bench.py) so they are no longer collected while remaining
runnable via torchrun.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move all benchmark scripts into a single src/scripts/benchmarks/ directory and
add the MoE-v2 kernel microbenchmarks that were still missing.

- Relocate the existing benches: odc (renamed benchmark_odc.py -> odc_bench.py),
  all_reduce_bench, routed_experts_fp8_bench, shared_experts_dense_bench,
  rowwise_alltoall_bench, rowwise_combine_fused_bench.
- Add microbenches for grouped-mm backends, MXFP8 quantize (plain / swizzle /
  weighted / scale-mode), scaled_grouped_mm_q, rowwise FP8 dispatch/combine,
  fused restore+unpermute, and valid-prefix SwiGLU.

These are standalone CLI / torchrun scripts (no pytest test functions), so this
also removes them from test collection. Update in-file usage-example paths.

Co-Authored-By: Tianhua Tao <tianhuatao@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@AkshitaB AkshitaB changed the title Rename rowwise torchrun bench scripts out of the test suite Consolidate benchmark scripts under src/scripts/benchmarks Jul 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

src_root = Path(__file__).resolve().parents[4]

P2 Badge Point the sys.path shim at src after the move

When this renamed benchmark is run from a source checkout via the torchrun path shown above, it now lives under src/scripts/benchmarks, so Path(__file__).resolve().parents[4] resolves to /workspace instead of the repo's src directory (the old src/test/nn/moe/v2 location made this depth work). In environments without an editable install, _load_combine_callables() inserts the wrong directory and the following from olmo_core.kernels.symm_mem_vdev2d ... import fails, so the benchmark is no longer runnable after the move.


src_root = Path(__file__).resolve().parents[4]

P2 Badge Point the sys.path shim at src after the move

After moving this script to src/scripts/benchmarks, Path(__file__).resolve().parents[4] no longer points at /workspace/OLMo-core/src; it points at /workspace. For the source-tree torchrun use case that this helper supports, _load_rowwise_callables() therefore adds the wrong path and from olmo_core.kernels.symm_mem_vdev2d ... fails unless the package happens to be installed separately. Recompute this as the actual src directory for the new location.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

AkshitaB and others added 5 commits July 21, 2026 15:53
The torch baseline sliced both `x[:num_elements]` and `out[:num_elements]` with
the device-tensor count, so under torch.compile (fullgraph) each slice derived
an independent unbacked size and dynamo could not prove they matched for the
copy_ (Eq(u2, u1)). Reuse the sliced row count for the output slice instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the bespoke SubCmd / BeakerLaunchConfig launch machinery so the all-reduce
bench runs like the other benches: a plain argparse entrypoint under torchrun
(or the generic Beaker launcher), with no required RUN_NAME/CLUSTER args. Payload
size, trials, and warmup are now CLI flags; the byte size is derived from the
tensor instead of module globals.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The rowwise all-to-all and combine benches inserted `parents[4]` onto sys.path,
which was `src` at their old src/test/nn/moe/v2/ location. After the move to
src/scripts/benchmarks/, `src` is `parents[2]`; `parents[4]` pointed above the
repo, breaking the `from olmo_core.kernels.symm_mem_vdev2d ...` import in a
non-editable-install (torchrun-from-source) run.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Optionally torch.compile both the FeedForward and SharedExperts forwards before
timing, so the comparison can measure whether inductor fuses away the
SharedExperts permute + strided SwiGLU + batch-1 bmm overhead that makes the
eager E=1 path slower. Adds --compile and --compile-mode
(default/reduce-overhead/max-autotune); the header notes the mode.

Co-Authored-By: Tianhua Tao <tianhuatao@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The single-expert (shared) forward pays for a no-op permute and a batch-1 bmm
that a plain mm would avoid; eager it runs ~13% slower than FeedForward (parity
under torch.compile max-autotune). Leave a TODO to add an E==1 fast path later.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@AkshitaB
AkshitaB merged commit f5376c1 into akshitab/moe-v2-core Jul 21, 2026
16 of 23 checks passed
@AkshitaB
AkshitaB deleted the akshitab/test-hygiene-rename-benches branch July 21, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant