Repository navigation
fix(test): serialize mlxcel-server env tests and stop lock-poison cascades - #2946
Merged
Merged
Conversation
…cades The mlxcel-server argument tests raced whenever the binary ran threaded: clap reads every `env = "..."` binding when it builds the command, so any test that built or parsed `Cli` (or called `build_startup_input`) saw `LLAMA_ARG_*` and `MLXCEL_*` values that a sibling had set under `CLI_ENV_LOCK`. On an untouched tree 5 of 6 threaded runs of `--bin mlxcel-server` failed one to three of the four tests named in the issue. Every test in that module that builds, parses, or spawns the CORS child now holds the lock through a poison-tolerant `cli_env_lock()` guard, and `parse_server_args`, `try_parse_cli`, and `cli_command` assert it is held, so a future test that forgets fails with a message instead of racing. The dense batched decode test lock now recovers from poison, so one failing case no longer turns every later case into a `PoisonError`. CONTRIBUTING.md documents the serial `make verify-test` gate and why it is serial (#1092, #1210). Validated: 10 threaded runs of the whole `--bin mlxcel-server` set and 5 of the four-test filter all pass; removing one guard makes that test fail with the assertion; `popular_dense_batched_decode` passes threaded; clippy and fmt are clean. No tolerance or snapshot changed. Closes #2937
Member
Author
Implementation Review SummaryIntent
Findings Addressed
Remaining Items
Verification
Guard review: poison is tolerated through |
Review follow-up for #2937. `ScopedEnv::set` and `ScopedEnv::unset` now assert the env lock is held, so the writer half of the race is checked as well as the readers. The CONTRIBUTING.md note no longer calls the serial command "the gate" next to step 4's "NOT gated at PR time"; it says the command is what `make verify-test` and the nightly workflow run. Validated with 5 threaded runs of `--bin mlxcel-server` (51 passed each), clippy on the bin's tests, and fmt.
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.
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.
The
mlxcel-serverargument tests raced whenever that binary ran threaded. clap 4 reads eachenv = "..."binding when it builds the command (Arg::envcallsenv::var_os), so every test that built or parsedCli, or calledbuild_startup_input, readLLAMA_ARG_*andMLXCEL_*values that a sibling had set underCLI_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.rstests: one poison-tolerantcli_env_lock()guard replaces the 12 hand-rolled lock sites (7 of them usedexpectand 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 theScopedEnvwriters 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 withunwrap_or_else(PoisonError::into_inner), so one failing case no longer turns its siblings intoPoisonErrorfailures.CONTRIBUTING.md: the macOS test command is now the serialmake verify-testgate, with one sentence on why ([nightly-verify] main is red #1092, fix(ci): run the Metal test gate single threaded, like the CUDA one #1210).CLAUDE.mdis not in this PR: it is a gitignored local symlink to an untrackedAGENTS.md, so its "Build and test" line has to be fixed outside the tree.Validation
cargo test --profile test-fast --features metal,accelerate --bin mlxcel-serverfailed (image_model_without_model_*3 times,legacy_server_mode_*andno_prompt_cache_flag_*1 to 2 times each).--lib popular_dense_batched_decodepasses threaded (15 passed);cargo clippy --lib --tests --bin mlxcel-server --features metal,accelerate -- -D warningsandcargo fmt --checkare clean.legacy.login the checkout: a test built a logging config while a sibling heldLLAMA_LOG_FILE=legacy.log. After the fix, 5 more threaded runs created none.make verify-testrun is still pending.Closes #2937