Repository navigation
fix: pin f32 GEMMs in step3p7_parity for CUDA batched-decode parity - #2802
Merged
Merged
Conversation
tests/step3p7_parity.rs is a separate integration binary, so the suite's ctor pin (pin_full_precision_f32_matmuls_for_tests in src/lib.rs) is #[cfg(test)] and never reaches it. Under MLX's default TF32 GEMMs (cuBLAS CUBLAS_COMPUTE_32F_FAST_TF32) the B=2 batched decode and the B=1 solo decode take different f32 GEMM shapes and round differently: max abs error 8.07e-4/1.16e-3 against the 1e-5 bound (5.96e-7/4.47e-7 with MLX_ENABLE_TF32=0). The test failed deterministically 3/3 on GB10 since its introduction in #2672, whose validation ran on M3 Ultra only. Add a #[ctor::ctor(unsafe)] that sets MLX_ENABLE_TF32=0 only when unset, mirroring src/lib.rs and the per-binary pattern in tests/cuda_sdpa_determinism.rs. The 1e-5 bound is unchanged; widening the tolerance to about 2e-3 is rejected because the project treats TF32 output as not f32 evidence and 1e-3 would hide a real row-mixing bug at this logit scale. Validation on CUDA (GB10, --test-threads=1 under gpu-lock): all 8 tests pass with no env override, and an explicit operator MLX_ENABLE_TF32=1 still overrides the pin (the batched-decode test fails at the same line-583 assertion, proving the operator setting wins). No real-checkpoint check is possible: no Step-3 / step3p7 checkpoint exists under models/ or in ~/models-101/manifest.tsv. Metal is unaffected (no TF32 there); NAX-class Apple GPUs (generation 17) apply TF32 by default per src/lib.rs and would likely fail the same way without the pin, not verified. Closes #2793
inureyes
marked this pull request as ready for review
October 31, 2026 17:00
Closed
4 tasks
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
tests/step3p7_parity.rsis a separate integration binary, so the suite's ctor f32-GEMM pin (pin_full_precision_f32_matmuls_for_testsinsrc/lib.rs,#[cfg(test)]) never reaches it. Root cause of the deterministic CUDA failure oftext_decode_delegates_sequence_local_native_batching(3/3 on GB10 at the 1e-5 bound since its introduction in update: batch decode for mixed-cache model families #2672): TF32 GEMMs. The B=2 batched decode and the B=1 solo decode take different f32 GEMM shapes, and under cuBLASCUBLAS_COMPUTE_32F_FAST_TF32they round differently: row 0/1 max abs error 8.07e-4/1.16e-3 in default env vs 5.96e-7/4.47e-7 withMLX_ENABLE_TF32=0, with argmax identical in every case.What changed
#[ctor::ctor(unsafe)]totests/step3p7_parity.rsthat setsMLX_ENABLE_TF32=0only when unset, mirroringsrc/lib.rs:175-183and the per-binary pattern intests/cuda_sdpa_determinism.rs:51-60(ctoris already a dev-dependency).Test plan
cargo test --profile test-fast --features cuda --test step3p7_parity --no-run(unlocked), thengpu-lock run --tag step3p7 -- target/test-fast/deps/step3p7_parity-2ce1c28674f124d9 --test-threads=1: all 8 tests pass on CUDA (GB10) with no env override.MLX_ENABLE_TF32=1still overrides the pin: the batched-decode test fails at the same line-583 assertion under it, proving the operator setting wins over the pin.models/or in~/models-101/manifest.tsv.src/lib.rs, so they would likely fail the same way without the pin; not verified.Closes #2793