Repository navigation
test: cheaper test suite — opt-level test profile, trimmed sweeps, parallel pure-TS lane - #221
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
f305c14 to
c5ffd1b
Compare
There was a problem hiding this comment.
💡 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".
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>
c5ffd1b to
0fe4edf
Compare
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>
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
Root cause:
cargo testran at opt-level 0, and the slow tests are f64 CPU reference loops / host-side data generation (the test files themselves saycargo test --releasein their headers). The MLX C++ side is always Release.Commits
[profile.test] opt-level = 2— measured:int8_verify_routes255 s → 34 s,kquant_m8_nax253 s → 30 s; mlx-core compile 3m03s → 4m46s (18 cores). Full--libsuite 921 s (CI) → 317 s locally with no test touched. Debug assertions / overflow checks stay on.#[ignore], now run in the qwen3 model-test leg on main), determinism sweeps 20–24 repeats × full grid → 3 × representative, bulk FFI readback inkquant_mode_guards.retention_simreports behind#[ignore], asserted cells kept.pure-tsparallel,addonserial; 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 flakystdReward > 0test made deterministic (greedy); two never-run paged TS gates wired into the qwen3 model leg.Measured locally (M5 Max), after all four
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).main— untouched.Test plan
cargo test -p mlx-core --lib4053 passed / 0 failed--ignoredpipeline tests passvp test: only environmental failures locally (gsm8k file, local addon older thanindex.cjs)Generated with Devin