Repository navigation
mps amax NaN/-inf, Metal compares, cpu signed-zero min/max (#49) - #83
Merged
Merged
Conversation
…l; cpu min/max signed zero (#49) - amax on Metal: max_keepdim, then the first index equal to it (or the first NaN) and a gather, so all -inf rows answer -inf and NaN propagates. - compare ops off the cpu keep their common dtype instead of widening to f64 (candle has no Metal F32->F64 cast); scalars narrow to the operand's dtype as upstream does. to(bool) on mps uses ne(0) in its own dtype. - cpu min()/max() return upstream's zero sign (-0 for min, +0 for max when present); min.dim/max.dim keep the first equal element. - golden: opt-in signed_zero cases and a zero-sign fault mode. - randn/normal_ on mps already compute on the device; a test pins it. Red before: amax all -inf gave -FLT_MAX; eq.Tensor raised Metal to_dtype F32 F64; min([0,-0,0,-0]) gave 0.0. Nullified: each of the three fixes removed turns its test red.
Contributor
Gate on CI (issue #24)Full gate: 126 suites = 118 run on at least one CI runner + 8 local-only. The local gate (
Local-only: verified by no CI runner (8)
Suites that verified nothing, or failed, on a runner
Every suite, every runner
A SKIP is unverified on that runner, never passed. UNVERIFIED means the suite ran and every one of its tests skipped by name. |
…#49) PR #83's x86_64 CI: upstream's max() zero sign differs from the shim's there, so the signed-zero case fails clean and flipping the shim's zero lands on upstream's answer, read as a MISS of zero-sign. A corruption of a case that already fails says nothing about the comparator; the golden run reports the failing case itself. Here (arm64) zero-sign is still CAUGHT and the self-test PASSes.
4 tasks
b-re-w
added a commit
that referenced
this pull request
Oct 16, 2026
Conflicts in aten.rs with #94 (#93): - promote_operands: kept #80's result_type_of (dimensioned > 0-d > wrapped number, c10 ResultTypeState), which covers #94's narrower dim-vs-0-d combine_categories; that second combine_categories is removed (it also clashed by name with #80's). - compare_scalar: kept develop's narrowing (#83 device path, #93 cpu path with the default-float case for integral tensors), which #94's golden cases and test_cmpscalar pin. Rebuilt: test_promote0d, test_cmpscalar, test_mpsextreme, test_x86pins ok; golden 12363/12363; self-test PASS.
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.
Closes #49
Defect fixed
amaxon mps: all-infrows answer-inf(were-FLT_MAX), NaN propagates. Still computed on Metal (compute_encoders > 0,host_downloads == 0).eq/ne/lt/ge(Tensor and Scalar) andto(bool)on mps, empty tensors included: no longer die atMetal contiguous to_dtype F32 F64.min()/max(): upstream's zero sign (measured on torch 2.13.0, lengths 1..69, f32/f16/bf16).Test added
tests/devices/mps/test_mpsextreme.py(3),tests/ops/test_signedzero.py(3); 48 goldensigned_zerocases; golden fault modezero-sign.randn/normal_on mps already compute on the device on this build;test_randn_and_normal_on_mpspins it (it passed before the fix too).Evidence (local, this Mac, worktree)
amax all -inf ... [-3.40e+38, 2.0], upstream [-inf, 2.0];eq.Tensor ... Metal contiguous to_dtype F32 F64 not implemented;min([0,-0,0,-0]) = 0.0, upstream -0.0.suites=124/124 ok=2016 FAIL=2; both FAILs are worktree environment (no.caches/target-python, AGENTS.md §13.2):test_toolguard_wheel_staging,test_wheelmatrix.Not done
aten.aminis not implemented in this build; not added here.float32([0.1]) == 0.1is False (cpu compare widens to f64); upstream says True.