Repository navigation
test: skip pinned muse_glimmer checkpoint tests and fix MLXCEL_BACKEND race - #1157
Conversation
…D race Two Muse Glimmer tests introduced with #1116 panicked on a machine without the pinned models/mlx/muse-glimmer-30b checkpoint instead of skipping: loading::vlm::muse_glimmer::tests::pinned_weight_index_classifies_each_source_weight_once panicked reading the missing safetensors index, and vision::encoders::muse_glimmer_fusion::tests::pinned_post_tower_weight_roots_and_shapes_match_published_contract asserted on the same missing file. Both now check for the index file first and skip with an eprintln reason, matching the pattern already used in tests/prompt_cache_e2e.rs, while still running the full contract check when the checkpoint is present. server::startup::muse_glimmer_startup_guard_tests::muse_glimmer_startup_allows_baseline_and_keeps_video_disabled also failed intermittently under the default parallel test runner. The sibling test in the same module, muse_glimmer_startup_rejects_xla_backend_selection, mutates the process-wide MLXCEL_BACKEND env var under the crate-wide env_lock guard, but the baseline test called into the same env-reading validate_muse_glimmer_unsupported_startup without acquiring that lock, so it could observe the transient MLXCEL_BACKEND=xla value. The baseline test now acquires crate::test_support::env_lock::env_lock() for the duration of its call. A grep of MLXCEL_BACKEND across src/ confirmed no other test module mutates this variable, so no other lock sharing is needed. Verified on a machine without models/mlx/muse-glimmer-30b: cargo test --release --features metal,accelerate --lib muse_glimmer (80 passed), and cargo test --release --features metal,accelerate --lib muse_glimmer_startup_guard repeated 5 times under default parallelism (5 passed each run). cargo clippy --release --lib --tests --features metal,accelerate -- -D warnings and cargo fmt --check both pass. The checkpoint-present arm of the two skip fixes could not be exercised on this box and is verified by code inspection only. Refs #1155
Implementation Review SummaryIntent
Findings AddressedNone. No CRITICAL or HIGH findings; no fixes were required. Verification performed by this reviewSkip guards (deliverable a). Both guards test exactly Env lock (deliverable b). The sibling Differential proof that the lock is load-bearing. Removing only the added Criterion 4 (no other test can observe the transient value), verified independently rather than taking the PR body's mutator-only argument. Under No production code touched. All three changed files are Remaining Items
Verification
|
Security and performance reviewNo CRITICAL or HIGH findings. Test-only change, no production code touched, nothing auto-fixed. Re-verified on this box: Deadlock analysis: clear
MEDIUM: acceptance criterion 4 is not fully met under
|
PR Finalization CompleteSummary
No changes were needed; the branch is unchanged from commit 79bc61a. Ready for merge. |
…ds (#1169) ## Summary Closes a pre-existing test-only race in `src/backend/tests.rs`: under the opt-in `xla-backend` / `experimental-backend` features, `select_backend()` reads `MLXCEL_BACKEND`, and a parallel full-suite run could interleave with `muse_glimmer_startup_rejects_xla_backend_selection` (which transiently sets that variable while holding the crate-wide env lock added in #1157) and make a backend test observe the transient `xla` value instead of the default MLX selection. ## What changed - `src/backend/tests.rs`: all four `select_backend()` call sites now acquire `crate::test_support::env_lock::env_lock()`, bound to a named `_env_guard` variable (never a bare `_`, since dropping it immediately would reinstate the exact race this fix closes), before calling `select_backend()`. - `mlx_session_threads_the_token_bias_through` (the test named in the issue) is guarded: without the lock it would hit the `unreachable!("select_backend defaults to MLX without MLXCEL_BACKEND=xla")` arm under the race. - `select_backend_resolves_to_mlx_under_default_features` is guarded: without the lock its `matches!(backend, Backend::Mlx(_))` and `backend.name() == "mlx"` assertions would fail under the race. - `mlx_backend_creates_a_session_and_advertises_batched_serving` is guarded: without the lock, `backend.supports_batched_serving()` and the session's `caps.multimodal` assertion would fail under the race (the XLA scaffold session reports `multimodal: false`, the opposite of what this test asserts for MLX). - `seam_delegates_to_real_mlx_loader_on_missing_dir` is guarded too, even though it would not fail outright under the race (both the MLX loader and the XLA scaffold's `load_unsupported()` return `Err` for a missing path): its docstring claims to prove the seam reaches the real MLX loader specifically, and without the lock a race could silently validate the XLA scaffold instead, defeating that claim without a visible test failure. All three of these sites were evaluated per the issue's discussion, and none were left unguarded. - Each guarded test carries a short comment explaining why the lock is needed, since under default features `select_backend()` reads no environment variable and the lock can otherwise look superfluous to a future reader. - Test-only change. `src/backend/mod.rs` (the feature-gated `select_backend` arm that reads `MLXCEL_BACKEND`) and `src/server/muse_glimmer_startup_guard_tests.rs` (already fixed by #1157) are untouched, and no production code path changed. ## Test plan - [x] `cargo check --lib --tests` (default features) - [x] `cargo test --lib backend::tests` (default features): 5 passed, 0 failed - [x] `cargo clippy --lib --tests -- -D warnings` (default features): clean - [ ] Full-suite parallel run with `--features metal,accelerate,xla-backend`: not run. This machine is a CUDA/GB10 Linux box where `metal` is not applicable, no CI workflow builds `xla-backend`, and a cold `mlxcel-xla` build exceeds local verification time budgets. Per the issue's accepted evidence, this PR relies on code inspection (the guard follows the exact `let _env_guard = crate::test_support::env_lock::env_lock();` pattern established by #1157 in `muse_glimmer_startup_guard_tests.rs`) plus the targeted default-feature run above. Closes #1159
The paragraph claimed there was no availability pre-check before PR #1173. There was one, just a narrower one: PR #1157 (`92d6d4c8`) replaced the vision-side test's `assert!(index_path.exists(), ...)` with a silent skip and added the same index-absent skip to `pinned_weight_index_classifies_each_source_weight_once`. Issue #1161 records this as well, both in its third acceptance criterion and in its note that #1157 "added the index-absent guard". As written the paragraph implied every partially materialized state was loud before #1173, which overstates what that PR gave up and therefore what the gate buys back. An absent index already skipped quietly under #1157. Restates the sequence accurately: #1157 made the index-absent case quiet, #1173 made the index-present-but-incomplete case quiet by replacing the unwraps past that guard, and `MLXCEL_REQUIRE_PINNED_CHECKPOINTS=1` restores the loudness for both. Documentation only; no code, test, or gate behavior changes.
Bilingual report covering the shared pinned-checkpoint gate: why the gate had to move into test_support rather than be copied, why the loading-side panic on a classification error stays a panic, and why documenting when to enable the variable was half the deliverable given it was set nowhere in the tree. Records the two-step correction the pre-#1173 paragraph needed, since the #1157 and #1173 sequence is easy to state wrongly.
…D race (lablup#1157) ## Summary Fixes three pre-existing muse_glimmer test defects (introduced with lablup#1116, unrelated to epic lablup#1148) that prevented `cargo test --release --features metal,accelerate --lib` from being green on a machine without the pinned `models/mlx/muse-glimmer-30b` checkpoint. ## What changed - `src/loading/vlm_muse_glimmer_tests.rs`: `pinned_weight_index_classifies_each_source_weight_once` now checks whether `model.safetensors.index.json` exists before calling `read_muse_weight_inventory_from_index`, and skips with an `eprintln` reason instead of panicking when the pinned checkpoint is absent, matching the pattern already used in `tests/prompt_cache_e2e.rs`. - `src/vision/encoders/muse_glimmer_fusion_tests.rs`: `pinned_post_tower_weight_roots_and_shapes_match_published_contract` skips the same way instead of asserting on the missing index file. - `src/server/muse_glimmer_startup_guard_tests.rs`: `muse_glimmer_startup_allows_baseline_and_keeps_video_disabled` now acquires the crate-wide `crate::test_support::env_lock::env_lock()` guard before calling `validate_muse_glimmer_unsupported_startup`, which reads `MLXCEL_BACKEND`. The sibling test `muse_glimmer_startup_rejects_xla_backend_selection` in the same module already sets `MLXCEL_BACKEND=xla` under that lock; without the baseline test also taking it, the baseline test could intermittently observe the transient value under default parallel test execution and fail. A grep of `MLXCEL_BACKEND` across `src/` confirmed no other test module mutates it, so no other module needs to share this lock. Both pinned-checkpoint tests still run their full contract check when the index file is present; that arm could not be exercised on this machine (no `models/mlx/` directory) and is verified by code inspection only, as noted in the commit body. ## Test plan - [x] `cargo test --release --features metal,accelerate --lib muse_glimmer` (80 passed, 0 failed, on a machine without `models/mlx/muse-glimmer-30b`) - [x] `cargo test --release --features metal,accelerate --lib muse_glimmer_startup_guard`, repeated 5 times under default parallelism (5 passed each run, no flakes observed) - [x] `cargo check --lib --tests --features metal,accelerate` - [x] `cargo clippy --release --lib --tests --features metal,accelerate -- -D warnings` (clean) - [x] `cargo fmt --check` (clean) Closes lablup#1155
…ds (lablup#1169) ## Summary Closes a pre-existing test-only race in `src/backend/tests.rs`: under the opt-in `xla-backend` / `experimental-backend` features, `select_backend()` reads `MLXCEL_BACKEND`, and a parallel full-suite run could interleave with `muse_glimmer_startup_rejects_xla_backend_selection` (which transiently sets that variable while holding the crate-wide env lock added in lablup#1157) and make a backend test observe the transient `xla` value instead of the default MLX selection. ## What changed - `src/backend/tests.rs`: all four `select_backend()` call sites now acquire `crate::test_support::env_lock::env_lock()`, bound to a named `_env_guard` variable (never a bare `_`, since dropping it immediately would reinstate the exact race this fix closes), before calling `select_backend()`. - `mlx_session_threads_the_token_bias_through` (the test named in the issue) is guarded: without the lock it would hit the `unreachable!("select_backend defaults to MLX without MLXCEL_BACKEND=xla")` arm under the race. - `select_backend_resolves_to_mlx_under_default_features` is guarded: without the lock its `matches!(backend, Backend::Mlx(_))` and `backend.name() == "mlx"` assertions would fail under the race. - `mlx_backend_creates_a_session_and_advertises_batched_serving` is guarded: without the lock, `backend.supports_batched_serving()` and the session's `caps.multimodal` assertion would fail under the race (the XLA scaffold session reports `multimodal: false`, the opposite of what this test asserts for MLX). - `seam_delegates_to_real_mlx_loader_on_missing_dir` is guarded too, even though it would not fail outright under the race (both the MLX loader and the XLA scaffold's `load_unsupported()` return `Err` for a missing path): its docstring claims to prove the seam reaches the real MLX loader specifically, and without the lock a race could silently validate the XLA scaffold instead, defeating that claim without a visible test failure. All three of these sites were evaluated per the issue's discussion, and none were left unguarded. - Each guarded test carries a short comment explaining why the lock is needed, since under default features `select_backend()` reads no environment variable and the lock can otherwise look superfluous to a future reader. - Test-only change. `src/backend/mod.rs` (the feature-gated `select_backend` arm that reads `MLXCEL_BACKEND`) and `src/server/muse_glimmer_startup_guard_tests.rs` (already fixed by lablup#1157) are untouched, and no production code path changed. ## Test plan - [x] `cargo check --lib --tests` (default features) - [x] `cargo test --lib backend::tests` (default features): 5 passed, 0 failed - [x] `cargo clippy --lib --tests -- -D warnings` (default features): clean - [ ] Full-suite parallel run with `--features metal,accelerate,xla-backend`: not run. This machine is a CUDA/GB10 Linux box where `metal` is not applicable, no CI workflow builds `xla-backend`, and a cold `mlxcel-xla` build exceeds local verification time budgets. Per the issue's accepted evidence, this PR relies on code inspection (the guard follows the exact `let _env_guard = crate::test_support::env_lock::env_lock();` pattern established by lablup#1157 in `muse_glimmer_startup_guard_tests.rs`) plus the targeted default-feature run above. Closes lablup#1159
Summary
Fixes three pre-existing muse_glimmer test defects (introduced with #1116, unrelated to epic #1148) that prevented
cargo test --release --features metal,accelerate --libfrom being green on a machine without the pinnedmodels/mlx/muse-glimmer-30bcheckpoint.What changed
src/loading/vlm_muse_glimmer_tests.rs:pinned_weight_index_classifies_each_source_weight_oncenow checks whethermodel.safetensors.index.jsonexists before callingread_muse_weight_inventory_from_index, and skips with aneprintlnreason instead of panicking when the pinned checkpoint is absent, matching the pattern already used intests/prompt_cache_e2e.rs.src/vision/encoders/muse_glimmer_fusion_tests.rs:pinned_post_tower_weight_roots_and_shapes_match_published_contractskips the same way instead of asserting on the missing index file.src/server/muse_glimmer_startup_guard_tests.rs:muse_glimmer_startup_allows_baseline_and_keeps_video_disablednow acquires the crate-widecrate::test_support::env_lock::env_lock()guard before callingvalidate_muse_glimmer_unsupported_startup, which readsMLXCEL_BACKEND. The sibling testmuse_glimmer_startup_rejects_xla_backend_selectionin the same module already setsMLXCEL_BACKEND=xlaunder that lock; without the baseline test also taking it, the baseline test could intermittently observe the transient value under default parallel test execution and fail. A grep ofMLXCEL_BACKENDacrosssrc/confirmed no other test module mutates it, so no other module needs to share this lock.Both pinned-checkpoint tests still run their full contract check when the index file is present; that arm could not be exercised on this machine (no
models/mlx/directory) and is verified by code inspection only, as noted in the commit body.Test plan
cargo test --release --features metal,accelerate --lib muse_glimmer(80 passed, 0 failed, on a machine withoutmodels/mlx/muse-glimmer-30b)cargo test --release --features metal,accelerate --lib muse_glimmer_startup_guard, repeated 5 times under default parallelism (5 passed each run, no flakes observed)cargo check --lib --tests --features metal,acceleratecargo clippy --release --lib --tests --features metal,accelerate -- -D warnings(clean)cargo fmt --check(clean)Closes #1155