Repository navigation
fix(ci): run the Metal test gate single threaded, like the CUDA one - #1210
Merged
Merged
Conversation
The 2026-08-16 nightly died with `signal: 11, SIGSEGV` in the mlxcel-core test binary. It published no panic and no `test result` line, so `--no-fail-fast` had nothing to collect and cargo reported a failed target with nothing to read. #1092 proposed measuring `--jobs 1` next, on the reading that cargo runs several test binaries concurrently. It does not. Measured on cargo 1.97.1 with a three-crate probe workspace, the build completes in full before the first test binary starts and each binary finishes before the next begins, so `--jobs` bounds only the build and can have no effect at the time a test is running. The concurrency is inside one binary. libtest defaults to one test thread per logical CPU, and the macOS crash report from the local repro on an 18-core M5 Max has 18 libtest workers live at the fault, every one of them in an MLX-backed cache test, two inside `iokit_user_client_trap` and two inside the allocator, faulting on an address in no mapped region. That is the CUDA abort of #1048 on the other backend, and `verify-test-cuda` already carries the flag that bounds it. Serializing is close to free, because the work serializes on the one Metal device whether or not the host threads do. On an M5 Max at 5dfcb39, warm, whole workspace, 101 binaries and 8128 tests: 69.17s parallel against 76.39s serialized. The two large members nearly cancel, mlxcel-core costing +23s while the root suite gains 12s. The nightly budgets 180 minutes for a step that spends its time in the build. `make test-fast` has passed `--test-threads=1` on macOS since #809, so the gate now agrees with the edit-test loop rather than diverging from it. No macOS counterpart to the CUDA guard test: that suite aborts every parallel run, while this one crashes rarely, and a hard guard would break `cargo test -p mlxcel-core --lib`, which is three times faster parallel and nearly always succeeds. Refs #1092
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
…ablup#1210) The 2026-08-16 nightly died with `signal: 11, SIGSEGV` in the mlxcel-core test binary. It published no panic and no `test result` line, so `--no-fail-fast` had nothing to collect and cargo reported a failed target with nothing to read. lablup#1092 proposed measuring `--jobs 1` next, on the reading that cargo runs several test binaries concurrently. It does not. Measured on cargo 1.97.1 with a three-crate probe workspace, the build completes in full before the first test binary starts and each binary finishes before the next begins, so `--jobs` bounds only the build and can have no effect at the time a test is running. The concurrency is inside one binary. libtest defaults to one test thread per logical CPU, and the macOS crash report from the local repro on an 18-core M5 Max has 18 libtest workers live at the fault, every one of them in an MLX-backed cache test, two inside `iokit_user_client_trap` and two inside the allocator, faulting on an address in no mapped region. That is the CUDA abort of lablup#1048 on the other backend, and `verify-test-cuda` already carries the flag that bounds it. Serializing is close to free, because the work serializes on the one Metal device whether or not the host threads do. On an M5 Max at 5dfcb39, warm, whole workspace, 101 binaries and 8128 tests: 69.17s parallel against 76.39s serialized. The two large members nearly cancel, mlxcel-core costing +23s while the root suite gains 12s. The nightly budgets 180 minutes for a step that spends its time in the build. `make test-fast` has passed `--test-threads=1` on macOS since lablup#809, so the gate now agrees with the edit-test loop rather than diverging from it. No macOS counterpart to the CUDA guard test: that suite aborts every parallel run, while this one crashes rarely, and a hard guard would break `cargo test -p mlxcel-core --lib`, which is three times faster parallel and nearly always succeeds. Refs lablup#1092
This was referenced Nov 10, 2026
inureyes
added a commit
that referenced
this pull request
Nov 10, 2026
Adds the bilingual (EN and KO) technical report for the mlxcel-server env test serialization and lock-poison fixes (#2937). It records why the threaded command reported failures the serial `make verify-test` gate never sees (#1092, #1210), the single poison-tolerant `cli_env_lock()` guard and its assertions, the before and after threaded run counts, and the open items: the local `CLAUDE.md` line outside the tree, the MLX-backed parallel-only failures left out of scope, and the pending full gate run.
inureyes
added a commit
that referenced
this pull request
Nov 10, 2026
…cades (#2946) The `mlxcel-server` argument tests raced whenever that binary ran threaded. clap 4 reads each `env = "..."` binding when it builds the command (`Arg::env` calls `env::var_os`), so every test that built or parsed `Cli`, or called `build_startup_input`, read `LLAMA_ARG_*` and `MLXCEL_*` values that a sibling had set under `CLI_ENV_LOCK`. The four tests named in the issue were just the ones whose assertions noticed; the audit found 40 unlocked tests that read env this way, including the help and flag-introspection tests and the parent of the CORS child-process test, whose child inherits the parent's env at spawn time. ## Changes - `src/bin/mlx_server.rs` tests: one poison-tolerant `cli_env_lock()` guard replaces the 12 hand-rolled lock sites (7 of them used `expect` and would cascade on poison), and every test that builds, parses, or spawns the child takes it. `parse_server_args`, `try_parse_cli`, `cli_command`, and the `ScopedEnv` writers assert the guard is held, so a new test that forgets fails with a message naming the fix instead of racing. A thread-local flag makes a second acquisition on one thread panic instead of deadlocking. - `src/models/popular_dense_batched_decode_tests.rs`: `test_guard()` is taken with `unwrap_or_else(PoisonError::into_inner)`, so one failing case no longer turns its siblings into `PoisonError` failures. - `CONTRIBUTING.md`: the macOS test command is now the serial `make verify-test` gate, with one sentence on why (#1092, #1210). `CLAUDE.md` is not in this PR: it is a gitignored local symlink to an untracked `AGENTS.md`, so its "Build and test" line has to be fixed outside the tree. ## Validation - Before, on the untouched tree: 5 of 6 threaded runs of `cargo test --profile test-fast --features metal,accelerate --bin mlxcel-server` failed (`image_model_without_model_*` 3 times, `legacy_server_mode_*` and `no_prompt_cache_flag_*` 1 to 2 times each). - After: 10 of 10 threaded runs of the whole binary pass (51 passed, 1 ignored), and 5 of 5 runs of the issue's four-test filter pass. - Deleting the guard from one test makes it fail with the assertion message. - `--lib popular_dense_batched_decode` passes threaded (15 passed); `cargo clippy --lib --tests --bin mlxcel-server --features metal,accelerate -- -D warnings` and `cargo fmt --check` are clean. - The race also left a stray zero-byte `legacy.log` in the checkout: a test built a logging config while a sibling held `LLAMA_LOG_FILE=legacy.log`. After the fix, 5 more threaded runs created none. - No tolerance or snapshot changed. The full `make verify-test` run is still pending. Closes #2937
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The macOS merge gate ran its whole test suite with libtest's default thread
count, one thread per logical CPU, while the CUDA gate has been serialized
since #1048. That is what took
mainred on 2026-08-16: themlxcel-corebinary died with
signal: 11, SIGSEGV, published no panic and notest resultline, and cargo reported a failed target with nothing to read.This adds
--test-threads=1toverify-testand documents the measurementbehind it.
Related issues
Closes #1092
Type of change
fix— bug fixchore— build, CI, dependencies, release infrastructuredocs— documentation onlyWhat the evidence says
--jobs 1is not the lever, and the reasoning that pointed at it waswrong. The issue thread proposed measuring
--jobs 1next, on the readingthat cargo runs several test binaries concurrently. It does not. Measured on
cargo 1.97.1 against a three-crate probe workspace whose tests sleep and print
timestamps: the build completes in full before the first test binary starts
(a 5s build script in crate
cfinishes 446ms before cratea's test begins),and each binary finishes before the next begins (
aends at t+3.010s,bstarts at t+3.339s).
--jobsbounds the build, which is over by the time anytest runs. The Makefile's existing claim that cargo "runs them one at a time"
was the correct one.
The concurrency is inside a single binary. The macOS crash report for the
local repro (
mlxcel_core-7a69ce25e4ef37da-2026-08-17-154444.ips, UUID matchedagainst the binary) has 18 named libtest worker threads live at the fault on an
18-core M5 Max, which is exactly
hw.logicalcpu. Every one of them is in anMLX-backed cache test: 10 in
cache::paged_batch_decode, 5 incache::paged_detach, 2 incache::detach, 1 inautotune. Two are insideiokit_user_client_trap, two inside the allocator. The fault isEXC_BAD_ACCESS/KERN_INVALID_ADDRESSat an address in no mapped region.That is the shape #1048 already documented on CUDA, where the fix was
--test-threads=1. The crashing tests are not new (they landed in #988 and#1004), so this is a probability, not a regression.
Cost
Measured on M5 Max at
5dfcb390,[profile.test-fast], whole workspace,101 binaries, 8128 tests, both arms warm:
--test-threads=1+7.2s, on a
cargo teststep the nightly budgets 180 minutes for and whosetime goes to the build rather than to running tests.
It is that cheap because the work already serializes on the one Metal device.
The two large members pull in opposite directions and nearly cancel:
mlxcel-corecosts +23s serialized (10.2s to 33.2s) while the root suitegains 12s (23.5s to 11.6s), thread contention across 5695 tests being worse
than running them in a row.
One trap worth recording, because it inverted the first measurement: a cold
first run pays roughly 50s of one-time Metal shader compilation. Run
parallel, serial, paralleland compare only the warm arms.make test-fasthas passed--test-threads=1on macOS since #809, so the gatenow agrees with the edit-test loop rather than diverging from it.
What this deliberately does not add
No macOS counterpart to the
the_cuda_test_suite_must_run_single_threadedguard. The CUDA suite aborts on every parallel run, so failing by name costs
nothing. The Metal suite crashes rarely, and a hard guard would break
cargo test -p mlxcel-core --lib, which is three times faster parallel andnearly always succeeds. Narrowed hand-runs are meant to stay parallel.
Test plan
make verify-teston M5 Max: 74.41s, flag applied, same verdict set asbefore the change.
agree on 17 failures; those 17 are this machine's pre-existing local reds
(13 in the root lib, 4 numeric-tolerance failures in
mlxcel-core), andthe nightly runner is green on all of them.
make helprenders the changed target line.This cannot prove the SIGSEGV will not recur, only that the concurrency it
needs is gone. The next nightly is the check.
Not fixed here
tests/granite4_vision_parity.rs::text_only_forward_produces_finite_logitsfails 6/40 parallel and 4/40 serialized against a real
granite-4.0-3b-vision-4bitcheckpoint. Independent of thread count, so itis a separate defect and gets its own issue. It does not reach the nightly,
which carries no weights.
server worker paths as well. Serializing the tests does not answer that.