Repository navigation
Description
Problem / Background
tests/step3p7_parity.rs::text_decode_delegates_sequence_local_native_batching fails deterministically on CUDA (GB10): 3/3 runs on 29c2f0c and on main 9f06fef with assertion failed: mlxcel_core::item_f32(&error) <= 1e-5 at tests/step3p7_parity.rs:566. It is the only failure in a full CUDA workspace run (14859 passed). The other 7 tests in the file pass.
Root Cause
TF32 GEMMs, not state mixing. Measured on main with a temporary print (same binary, both rows, synthetic f32 dense weights, logits max magnitude about 1.4, argmax identical in every case):
| Env | Row 0 max abs err | Row 1 max abs err |
|---|---|---|
default (MLX_ENABLE_TF32 unset, MLX default 1) |
8.07e-4 | 1.16e-3 |
MLX_ENABLE_TF32=0 |
5.96e-7 | 4.47e-7 |
With TF32 off the test passes unchanged. The B=2 batched decode and the B=1 solo decode take different f32 GEMM shapes, and under cuBLAS CUBLAS_COMPUTE_32F_FAST_TF32 they round differently. The test suite already pins full-precision f32 for this reason (pin_full_precision_f32_matmuls_for_tests, src/lib.rs:161-183, issues #1065, #1088, #1259), but that ctor is #[cfg(test)] and only reaches the lib unit-test binary. The sibling #2672 parity tests in src/models/mixed_cache_batched_decode_tests.rs inherit it and pass at the same 1e-5; tests/step3p7_parity.rs is a separate integration binary with no pin.
History: the test was added in ffea911 (#2672), whose validation ran on M3 Ultra only, so it has failed on CUDA since introduction. 9f06fef (#2767) is not involved: the test weights are unquantized, and the same binary passes with TF32 off.
Proposed Solution
Add a #[ctor::ctor(unsafe)] to tests/step3p7_parity.rs that sets MLX_ENABLE_TF32=0 only when unset, mirroring src/lib.rs:175-183 and the per-binary pattern in tests/cuda_sdpa_determinism.rs:51-60 (ctor is already a dev-dependency). Keep the 1e-5 bound. Widening the tolerance to about 2e-3 is rejected: the project treats TF32 output as not f32 evidence, and 1e-3 would hide a real row-mixing bug at this logit scale.
Out of scope: auditing other tests/*.rs parity binaries for the same missing pin (no integration test sets MLX_ENABLE_TF32 programmatically today); file separately if wanted.
Acceptance Criteria
- Root cause recorded in the PR (TF32 pin absent from the integration binary), with the measured magnitudes above
- Pin added; the 1e-5 assertion is unchanged
- The test passes on CUDA in default env; an explicit operator
MLX_ENABLE_TF32=1still overrides the pin - Real-checkpoint check: none possible, no Step-3 / step3p7 checkpoint exists under
models/or in~/models-101/manifest.tsv; state this in the PR - Metal: M3 Ultra is unaffected (no TF32 there); NAX-class Apple GPUs (generation 17) apply TF32 by default per
src/lib.rs, so they would likely fail the same way without the pin; note as not verified
Verification
cargo test --profile test-fast --features cuda --test step3p7_parity --no-run
gpu-lock run --tag step3p7 -- target/test-fast/deps/step3p7_parity-<hash> --test-threads=1Build unlocked and run only the printed test binary under gpu-lock (a cargo build inside the lock leaks it through the sccache daemon).
All 8 tests pass with no env override.
Activity
fix: pin f32 GEMMs in step3p7_parity for CUDA batched-decode parity (l…