Skip to content

fix: pin f32 GEMMs in step3p7_parity for CUDA batched-decode parity - #2802

Merged
inureyes merged 1 commit into
mainfrom
fix/issue-2793-step3p7-parity-tf32-pin
Oct 31, 2026
Merged

inureyes merged 1 commit into
mainfrom
fix/issue-2793-step3p7-parity-tf32-pin

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

  • tests/step3p7_parity.rs is a separate integration binary, so the suite's ctor f32-GEMM pin (pin_full_precision_f32_matmuls_for_tests in src/lib.rs, #[cfg(test)]) never reaches it. Root cause of the deterministic CUDA failure of text_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 cuBLAS CUBLAS_COMPUTE_32F_FAST_TF32 they round differently: row 0/1 max abs error 8.07e-4/1.16e-3 in default env vs 5.96e-7/4.47e-7 with MLX_ENABLE_TF32=0, with argmax identical in every case.

What changed

  • 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).
  • The 1e-5 assertion is unchanged. 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.

Test plan

  • cargo test --profile test-fast --features cuda --test step3p7_parity --no-run (unlocked), then gpu-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.
  • Explicit operator MLX_ENABLE_TF32=1 still overrides the pin: the batched-decode test fails at the same line-583 assertion under it, proving the operator setting wins over the pin.
  • Real-checkpoint check: none possible, no Step-3 / step3p7 checkpoint exists under models/ or in ~/models-101/manifest.tsv.
  • 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; not verified.

Closes #2793

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 inureyes added the status:review Under review label Oct 31, 2026
@inureyes
inureyes marked this pull request as ready for review October 31, 2026 17:00
@inureyes
inureyes merged commit 1be8118 into main Oct 31, 2026
31 checks passed
@inureyes inureyes added status:done Completed type:bug Bug fixes, error corrections, or issue resolutions priority:medium Medium priority area:models Model architectures, weights, loading, metadata platform:linux Linux (CUDA / packaging) specific and removed status:review Under review labels Nov 30, 2026
@inureyes inureyes added this to the 0.8 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 platform:linux Linux (CUDA / packaging) specific priority:medium Medium priority status:done Completed type:bug Bug fixes, error corrections, or issue resolutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Pin full-precision f32 in step3p7_parity so batched decode parity holds on CUDA

1 participant