Skip to content

test(models): take mlx_test_guard in every batched-decode harness test - #3573

Merged
inureyes merged 2 commits into
mainfrom
test/3567-mlx-test-guard-batched-decode
Nov 30, 2026
Merged

inureyes merged 2 commits into
mainfrom
test/3567-mlx-test-guard-batched-decode

Conversation

@inureyes

@inureyes inureyes commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Every lib test that drives batched_decode_harness now takes mlx_test_guard() as its first statement, so the model-owned multistep and native batched-decode tests no longer run in parallel and abort in cudaStreamEndCapture. The guard stays out of the harness because it is a non-reentrant Mutex.

The re-run sweep found 87 unguarded tests, not the 54 in the issue. The extra 33 are:

  • Tests that call a same-file helper which drives the harness (cohere2, gemma3n, mixed-cache, wrapper and VLM delegation tests, and others).
  • Macro-generated tests (fn $name) in llama_runtime_tests.rs (tensor-parallel Llama) and popular_dense_batched_decode_tests.rs.
  • Tests holding only a private mutex that does not exclude the other MLX tests: cohere2_tests.rs and cohere2_moe_tests.rs now take the shared guard before their local lock, and the popular-dense macro uses the shared guard in place of its private one.
  • A gemma4 test with an #[ignore] attribute between #[test] and fn.

Helpers that already take the guard internally were left alone, so nothing takes it twice.

New test

tests/mlx_test_guard_coverage.rs is a dependency-free text scan of src/. It flags any #[test] that calls a harness function (qualified or imported), directly or through a same-file helper that does not take the guard, and lists the offenders. A second test checks the scanner on small fixtures.

Verification

  • Revert check: with src/ restored to main, the scan fails and lists 87 tests; with this change it passes.
  • cargo clippy --lib --tests --features cuda -- -D warnings clean, cargo fmt --all -- --check clean, the five CI contract scripts pass.
  • cargo test --profile test-fast --features cuda --bin mlxcel: 363 passed.
  • Narrow lib selectors for a sample of the touched modules under gpu-lock : 65 passed, 0 failed, 8 ignored (popular_dense, cohere2, afmoe, inkling tiny, wrapper_batched_decode, mixed_cache, mixtral_style).
  • Full CUDA lib suite at default parallelism: the first run aborted in cudaStreamEndCapture inside audio:: tests that do not use the harness (audio::fastconformer aborts 6 of 6 parallel runs on its own). That is a wider pre-existing problem, now test(cuda): parallel lib tests abort in cudaStreamEndCapture #3574, so the issue's third acceptance criterion moves there (see the comment on test(models): take mlx_test_guard in every batched-decode harness test #3567). Metal was not available on this host.
  • After rebasing onto main with feat(vlm): add SoMark OXR-1.0 (oxr) support #3536 (SoMark OXR): the scan test, contract scripts, fmt, clippy, --bin mlxcel (363 passed) and the selectors popular_dense_batched, cohere2 and oxr pass.

Closes #3567

@inureyes inureyes added type:test Test related changes priority:low Low priority area:models Model architectures, weights, loading, metadata status:done Completed labels Nov 30, 2026
@inureyes
inureyes force-pushed the test/3567-mlx-test-guard-batched-decode branch from 4d7715b to 2b287f4 Compare November 30, 2026 01:03
inureyes added a commit that referenced this pull request Nov 30, 2026
Add the shared MLX serialization guard to the 87 tests that drive batched_decode_harness without it, and replace the private mutex in the popular-dense contract macro with the shared guard. Add tests/mlx_test_guard_coverage.rs, a dependency-free source scan that fails with the list of unguarded callers.

Closes #3567
@inureyes
inureyes force-pushed the test/3567-mlx-test-guard-batched-decode branch from 3611f77 to 001c8bb Compare November 30, 2026 01:20
@inureyes
inureyes marked this pull request as ready for review November 30, 2026 01:21
@inureyes
inureyes merged commit 363b755 into main Nov 30, 2026
15 checks passed
@inureyes
inureyes deleted the test/3567-mlx-test-guard-batched-decode branch November 30, 2026 01:21
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:models Model architectures, weights, loading, metadata priority:low Low priority status:done Completed type:test Test related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(models): take mlx_test_guard in every batched-decode harness test

1 participant