Repository navigation
test: compare same-device regression round-trips at float32 precision - #1341
Merged
Merged
Conversation
ggprior
force-pushed
the
georg/mps-save-load-tolerance
branch
from
October 1, 2026 18:46
87ee007 to
59c8073
Compare
Inference runs in float32, and on MPS the regression border remap sums in a nondeterministic order, so two predicts can differ by one float32 step. Six fixed decimals demand bit-identical float32 for predictions in the hundreds; compare against the predictions' own scale instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018qH4DKrmQVSS3qbzViv5nf
ggprior
force-pushed
the
georg/mps-save-load-tolerance
branch
2 times, most recently
from
October 1, 2026 20:36
5361d2b to
67987e8
Compare
ggprior
marked this pull request as ready for review
October 1, 2026 23:00
ggprior
enabled auto-merge
October 1, 2026 23:00
Contributor
|
Just pushed a change to compute the atol excluding the shift. |
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.
mainfails two slow MPS save/load tests on the macos-15 job:test__save_and_load_fit_with_cache__predictions_equal[regression-mps-mps-v3]test__save_and_load_fit_with_cache_twice__predictions_equal[regression-mps-mps-v3]One of 40 regression predictions differs by 1.5e-5 (8.6e-8 relative) between the original and the reloaded model, which is one float32 step at a value of about 179. The check used
assert_array_almost_equal, which requires agreement to 6 decimals. For values in the hundreds that means bit-identical float32 outputs, which float32 inference doesn't guarantee.Change
Same-device regression round-trips now compare with
assert_allclose(atol=1e-6 × max(|prediction|, 1)). That's float32-level precision relative to the predictions' own scale; for these predictions it allows about 2.5e-4. Classifier labels and probabilities keep the existing check.Since #1311, regression outputs are decoded in z-space and mapped back in float64, which moved where float32 rounding happens and exposed the existing difference on one row. The underlying difference comes from the regression border remap. On non-CUDA devices it accumulates with
index_add_, which on MPS sums in a different order on each call, so the aggregated logits can change in the last bit between two predicts of the same model. Everything upstream (weights, KV caches, per-estimator outputs) is bit-identical. A deterministic remap on MPS is a separate change.Verification
PR CI skips slow tests. Two temporary commits made this PR's macos-15 job run
tests/test_save_load_fitted_model.pyincluding the slow MPS cases, then repeat the four MPSfit_with_cacheregression round-trips 10 times. All 41 + 10 × 4 passed on the fix (job, along with the rest of CI. After rebasing onto currentmain, a further temporary commit ran the whole suite including slow tests on macos-15, the same scope as the post-mergemainrun: 2646 passed (job). The temporary commits have been dropped; the failure is intermittent (a CI-only run without the fix also happened to pass), which is the nondeterminism described above.🤖 Generated with Claude Code
https://claude.ai/code/session_018qH4DKrmQVSS3qbzViv5nf