Skip to content

test: cheaper test suite — opt-level test profile, trimmed sweeps, parallel pure-TS lane - #221

Merged
Brooooooklyn merged 5 commits into
chore/mlx-bump-2026-10-14from
perf/test-suite-trim
Oct 15, 2026
Merged

Brooooooklyn merged 5 commits into
chore/mlx-bump-2026-10-14from
perf/test-suite-trim

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Contributor

Summary

Stacked on #219. Makes the test suite cheaper without dropping the regressions it guards. Research first (per-test timings from CI logs, then code reading), then four scoped commits.

Where the time went

rust-lib   4198 tests  921 s          rust-int   96 binaries  1160 s
├─ 1 test  int8_verify_routes   336 s  ├─ kquant_m8_nax              372 s   3 tests
├─ 4 tests qwen4_exp prefill    147 s  ├─ kquant_mode_guards         296 s  12 tests
├─ 2 tests int8 (others)         74 s  ├─ kquant_tiled               201 s  11 tests
├─ 5 tests retention_sim         56 s  ├─ kquant_affine_tiled         97 s   4 tests
└─ 4186 tests                   ~300 s ├─ kquant_metallib_names       93 s   2 tests
                                       ├─ bridge_metallib_names       51 s   4 tests
TS (vitest) 3775 tests          220 s  └─ 90 binaries                ~50 s

Root cause: cargo test ran at opt-level 0, and the slow tests are f64 CPU reference loops / host-side data generation (the test files themselves say cargo test --release in their headers). The MLX C++ side is always Release.

Commits

  1. [profile.test] opt-level = 2 — measured: int8_verify_routes 255 s → 34 s, kquant_m8_nax 253 s → 30 s; mlx-core compile 3m03s → 4m46s (18 cores). Full --lib suite 921 s (CI) → 317 s locally with no test touched. Debug assertions / overflow checks stay on.
  2. K-quant integration trims — build-every-pipeline tests (#[ignore], now run in the qwen3 model-test leg on main), determinism sweeps 20–24 repeats × full grid → 3 × representative, bulk FFI readback in kquant_mode_guards.
  3. Unit-test sweeps — int8 prefixes chosen from the segmented-SDPA plan boundaries (150 → 50 cases, every route still hit per layout), qwen4_exp prefill parity on a table of distinct mechanisms (70 → 16 combos), retention_sim reports behind #[ignore], asserted cells kept.
  4. vitest two lanes — pure-ts parallel, addon serial; membership traced from the import graph at config load (scripts/test-lanes.ts). TS tests pinned exactly by Rust unit tests removed; expect(true) train() tests now assert the batch contract; the flaky stdReward > 0 test made deterministic (greedy); two never-run paged TS gates wired into the qwen3 model leg.

Measured locally (M5 Max), after all four

                         before (CI, debug)   after (local, opt 2)
mlx-core --lib           921 s                 90 s   (4053 passed, 153 ignored)
6 hot kquant binaries   1109 s                202 s   (142 s of it is one CPU-reference test, see below)
vp test                  220 s                127 s

Left alone on purpose (product calls)

  • kquant_tiled::kquant_modes_take_no_row_tier_past_m8 — 115 s, 45 single-thread CPU reference matmuls at M=40 on Qwen3.8 shapes. Now the single biggest Rust test; shrinking it is a coverage decision.
  • kquant_m8_nax::m8_nax_matches_cpu_on_every_mode_and_shape (31 s) — not a subset of the tiled test (outlier channels, signed sub-scales, production dispatch), kept.
  • RUST_TEST_THREADS=1 — load-bearing (global RNG, default device, route counters).
  • 15 pre-existing K-quant golden failures on main — untouched.

Test plan

  • cargo test -p mlx-core --lib 4053 passed / 0 failed
  • the 6 touched integration binaries + their --ignored pipeline tests pass
  • vp test: only environmental failures locally (gsm8k file, local addon older than index.cjs)
  • fmt / clippy / typecheck / lint / actionlint clean
  • CI on this PR (runs once ci: prebuilt MLX from GitHub releases, split test legs, commit Cargo.lock #218 merges and the stack is retargeted)

Generated with Devin

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0746032f-13ad-4a80-9f11-8b08765925f6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T10:37:42.119533Z e4e177d New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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

Here are some automated review suggestions for this pull request.

Reviewed commit: c5ffd1b351

ℹ️ 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".

Comment thread vite.config.ts Resolved
Brooooooklyn and others added 4 commits October 15, 2026 18:28
The test suite's cost is host-side work, not GPU work: f64 reference loops
(K-quant parity gates, int8 SDPA references), synthetic weight generation,
and retention simulations, while the MLX C++ side is always built Release.
At opt-level 0 those loops dominated CI: one unit test took 336 s and six
K-quant integration binaries were 92% of their 19 min job.

Measured on the two hottest tests: 255 s -> 34 s and 253 s -> 30 s, for
about 1.5x the mlx-core compile time (3m03s -> 4m46s, 18 cores). The full
mlx-core --lib suite drops from 921 s (CI, debug) to 317 s locally before
any test is touched. Debug assertions and overflow checks stay on.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- The build-every-pipeline tests in kquant_metallib_names (~2800 kernels)
  and bridge_metallib_names (segmented SDPA specializations) are #[ignore]d
  and run in the model-test qwen3 leg on main; a present-but-unloadable
  function is a pin-bump defect class. The cheap name-set tests still run on
  every PR. (126 s + 25 s -> 0.3 s each)
- Determinism sweeps in kquant_m8_nax, kquant_tiled, kquant_affine_tiled
  re-evaluated the same kernel 20-24 times over full mode x shape grids;
  the only scheduling-dependent code is the shared split-K epilogue, so 3
  repeats over one representative per decode class / kernel family keep the
  gate (affine: 10.7k dispatches -> 48).
- kquant_mode_guards::expect_f32 read results back one FFI call per element;
  the "add(arr, zeros)" reason in its comment is stale (mlx_array_to_float32
  is flatten + memcpy, no kernel), so it uses the bulk readback.

kquant_m8_nax::m8_nax_matches_cpu_on_every_mode_and_shape is left alone: it
is not a subset of the tiled test (heavy outlier channels, signed sub-scales,
production dispatch on the default device, runs on non-NAX hosts).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- kv_int8_tests: the route sweep ran 5 layouts x 10 prefixes x 3 q_std =
  150 cases, each with two O(heads*rows*prefix*256) f64 references. The
  kept prefixes {1, 87, 1019, 1024, 6219} are read off the segmented SDPA
  plan: one-pass empty partitions, one-pass masked tile, chunk == tile just
  under the 1024 two-pass switch (the int8 split route), two-pass + masked
  tail, several full tiles + tail on both simdgroup and NAX tile widths.
  Every route is still hit per layout (counters assert it). 150 -> 50.
- qwen4_exp: the three prefill-parity tests asserted one contract (chunked /
  batched / window prefill == step-by-step) over 70 fixture x layout x width
  combos, two decoders each. A table-driven PrefillCase keeps each distinct
  mechanism (singleton tail chunk, indexer budget crossing, first chunk below
  the compress ratio, demand-loaded / auto / resident expert tiers, window
  carry + async frontier) on both layouts and both dtypes: 70 -> 16.
- retention_sim: decision_tables had no assertions and multi_owner_sweep
  asserted 8 of ~300 simulations; the reports move behind #[ignore], the
  asserted cells stay. The publisher-arm invariant runs the caps that decide
  when the blinding arm is reached (binding, per-owner-tight, wide global
  over tight per-owner, never-fires) instead of all nine.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…by Rust

- vite.config.ts now has two projects. `pure-ts` runs with default workers;
  `addon` keeps maxWorkers 1 (one Metal device). Membership is computed at
  config load by scripts/test-lanes.ts, which traces each test file's import
  graph for @mlx-node/core (plus a hand list for files that spawn a child
  that loads the addon, or pick-a-free-port-then-bind). Vitest schedules the
  maxWorkers:1 project after the parallel one, so the lanes never overlap.
  218 s -> 127 s locally.
- Deleted __test__/core/{grpo-autograd,autograd-training}.test.ts (MxArray
  arithmetic placeholders; crates/mlx-core/src/array/tests.rs pins them) and
  the grpo-trainer / grpo-integration tests whose property is asserted
  exactly by grpo/{engine,loss,advantages}.rs. The `expect(true)` train()
  tests now assert the reward-call batch sizes instead.
- "varying reward values" asserted stdReward > 0, but the engine computes
  std over the completions that survive the length-cap filter; with random
  weights at temperature 0.8 one survivor made it 0 (seen in CI). Greedy
  sampling makes the four identical prompts survive or fall together.
- qwen3.test.ts gets the siblings' .cache fallback instead of never running;
  the two QWEN3_PAGED_PARITY_MODEL_PATH gates run in the qwen3 model-test
  leg (nothing set that variable before). Chunked-prefill sizes 6 -> 3.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Vitest 5.0.4 already runs the maxWorkers:1 project in its own last group,
but that is an implementation detail; distinct groupOrder values are the
documented way to say "pure-ts, then addon". Measured: the first addon file
starts ~100 ms after the last pure-TS file ends, before and after.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Brooooooklyn
Brooooooklyn merged commit fdab1cd into main Oct 15, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the perf/test-suite-trim branch October 15, 2026 11:42
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