Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/198674
Note: Links to docs will display an error until the docs builds have been completed. ❌ 8 New Failures, 2 Unrelated FailuresAs of commit a7aade8 with merge base f46ffe0 ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
huydhn
force-pushed
the
huydhn/mac-mps-add-macos-m1-15
branch
3 times, most recently
from
September 25, 2026 19:40
0cb9627 to
75195e9
Compare
huydhn
force-pushed
the
huydhn/mac-mps-add-macos-m1-15
branch
2 times, most recently
from
September 25, 2026 19:48
5eee103 to
5dc938e
Compare
Collaborator
|
@pytorchbot rebase -b main |
Collaborator
|
@pytorchbot started a rebase job onto refs/remotes/origin/main. Check the current status here |
…a failures pytorch-gha-infra#1535 moved the us-east-2 mac2 pool to Sequoia, and those pets briefly also carried macos-m1-stable. Every default shard that landed on one failed (22/22 on 2026-09-25); the same commits passed on Sonoma. Failing tests, with 0 failures across 2,658 Sonoma shards in the prior 3 days: - test_ops.py::TestCommonMPS::test_noncontiguous_samples_scatter_reduce_amin/amax_mps_int64 - test_mps.py::TestConsistencyMPS::test_output_match_scatter_reduce_amin_mps_int64 - test_mps.py::TestMPS::test_large_bmm_float16 / bfloat16 - test_nn.py::TestNNDeviceTypeMPS::test_grid_sample_large_index_2d_mps_float32 The infra fix put macos-m1-stable back to Sonoma-only, so the failures are no longer reproducible anywhere. This points every macOS job at macos-m1-15 so this PR's own CI run reproduces them in full. - trunk.yml: build runner-type, default shards 1-3, openreg - mac-mps.yml: build runner-type, and the test_mps entry that was macos-m1-14 - inductor-perf-test-nightly-macos.yml: build runner-type - actionlint.yaml: register macos-m1-15 Not merging this. macos-m1-15 is 9 runners in us-east-2, against ~96 Sonoma pets on macos-m1-stable, and the tests fail there by construction. Landing it would red-line and starve all macOS CI. It exists to produce a full failure set on demand; the real fix is in the MPS tests, after which us-east-1 migrates and macos-m1-stable follows the hardware. Left alone deliberately: the macos-m1-stable strings in .github/scripts/test_filter_test_configs.py (job-name parser fixtures) and test/test_reductions.py (a comment). Neither routes anything.
Collaborator
|
Successfully rebased |
pytorchmergebot
force-pushed
the
huydhn/mac-mps-add-macos-m1-15
branch
from
September 26, 2026 22:11
5dc938e to
9cf38ca
Compare
malfet
added a commit
to huydhn/pytorch
that referenced
this pull request
Sep 27, 2026
pytorch#198689 added `IS_APPLE_M1` as a `LazyVal` and gated `test_grid_sample_large_index_{2d,3d}` with `@skipMPSIf(MACOS_VERSION < 15.0 or IS_APPLE_M1, ...)`. `skipIf` only skips when its condition is a `str` or an actual `bool`. On macOS 14 the expression short-circuits to `True`, but on macOS 15 `or` returns the `LazyVal` object itself, which is truthy yet not a `bool`, so the skip is silently ignored and both tests still fail with `Invalid buffer size: 8.00 GiB` on the new `macos-m1-15` runners (e.g. https://github.com/pytorch/pytorch/actions/runs/36275460327/job/108500387624). Evaluate `IS_APPLE_M1` eagerly instead. It adds no import cost: `TEST_MPS = torch.backends.mps.is_available()` on the line above already initializes the Metal device, and the `TEST_MPS and` guard short-circuits on Linux/Windows and on MPS-less macOS builds, where `torch._C._mps_get_name` is not defined. The alternative, teaching `skipIf` to treat any truthy object as a skip, would be a broader behavior change for every `skip*If` user. Test Plan: Checked that the new expression produces a real bool on both macOS version branches: ``` python -c " import torch from torch.testing._internal.common_utils import TEST_MPS IS_APPLE_M1 = TEST_MPS and torch.backends.mps.get_name().startswith('Apple M1') for mv in (14.6, 15.5): d = mv < 15.0 or IS_APPLE_M1 print(mv, repr(d), isinstance(d, bool))" ``` CI on `macos-m1-15` (via pytorch#198674) should show `test_grid_sample_large_index_*` skipped. This PR was authored with the help of an AI assistant (Claude Code). Co-Authored-By: Claude Opus 5.5 <[email protected]>
pytorch#198689 added `IS_APPLE_M1` as a `LazyVal` and gated `test_grid_sample_large_index_{2d,3d}` with `@skipMPSIf(MACOS_VERSION < 15.0 or IS_APPLE_M1, ...)`. `skipIf` only skips when its condition is a `str` or an actual `bool`. On macOS 14 the expression short-circuits to `True`, but on macOS 15 `or` returns the `LazyVal` object itself, which is truthy yet not a `bool`, so the skip is silently ignored and both tests still fail with `Invalid buffer size: 8.00 GiB` on the new `macos-m1-15` runners (e.g. https://github.com/pytorch/pytorch/actions/runs/36275460327/job/108500387624). Evaluate `IS_APPLE_M1` eagerly instead. It adds no import cost: `TEST_MPS = torch.backends.mps.is_available()` on the line above already initializes the Metal device, and the `TEST_MPS and` guard short-circuits on Linux/Windows and on MPS-less macOS builds, where `torch._C._mps_get_name` is not defined. The alternative, teaching `skipIf` to treat any truthy object as a skip, would be a broader behavior change for every `skip*If` user. Test Plan: Checked that the new expression produces a real bool on both macOS version branches: ``` python -c " import torch from torch.testing._internal.common_utils import TEST_MPS IS_APPLE_M1 = TEST_MPS and torch.backends.mps.get_name().startswith('Apple M1') for mv in (14.6, 15.5): d = mv < 15.0 or IS_APPLE_M1 print(mv, repr(d), isinstance(d, bool))" ``` CI on `macos-m1-15` (via pytorch#198674) should show `test_grid_sample_large_index_*` skipped. This PR was authored with the help of an AI assistant (Claude Code). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…onvert
On aarch64, contiguous `x.byte()` for float16/bfloat16 still does a direct `static_cast<uint8_t>`, which clang lowers to a saturating `fcvtzu` (-1 -> 0), while strided copies go through `c10::convert`, which narrows via int64 (-1 -> 255). This breaks `test_non_contig_byte_cpu_{float16,bfloat16}`, `test_contig_vs_every_other_byte_cpu_{float16,bfloat16}` and their `_refs` variants on Apple Silicon (e.g. https://github.com/pytorch/pytorch/actions/runs/36282025606/job/108516516926). pytorch#196646 fixed the same mismatch for float32, but by widening to int64, which on NEON means going through float64 and halves the lane count.
This adds float16/bfloat16 specializations and switches float32 to narrow via int32 instead, using the fact that a type with p significant bits has only multiples of 256 above 2^(p+7): every finite fp16 fits in int32; bf16 is clamped to +-2^16; float32 maps |x| >= 2^31 to 0. All three match `c10::convert` bit for bit wherever it is defined (|x| < 2^63), verified exhaustively for every float16, bfloat16 and float32 bit pattern.
Performance of `x.byte()`, 4M elements, single thread, M5 Pro (us):
| dtype | main | this PR |
|----------|------|---------|
| float32 | 353 | 294 |
| float16 | 101 | 172 |
| bfloat16 | 170 | 281 |
For reference, a direct (UB) float32 -> uint8 cast takes ~180us, so the defined float32 path is now ~1.6x the plain cast instead of ~2x.
Question for reviewers: does defining this behavior make sense at all? `torch.Tensor.to` documents that when the truncated value cannot fit into the target type "the behavior is undefined and the result may vary across platforms", so the int64 wraparound is a convention that dates back to pytorch#36807 (CPU/CUDA consistency) rather than a documented contract. Keeping it costs ~1.7x for float16/bfloat16 relative to the plain cast. The alternative is to drop the int64 convention on the vectorized paths (including pytorch#196646's) and restrict the `byte` OpInfo's test inputs to the uint8 range (`domain=(0, None)`), accepting that contiguous and strided copies may disagree on out-of-range values.
The register-level `VecConvert<uint8_t, 1, float, N>` from pytorch#196646 (used by inductor) is left unchanged; it still narrows via int64 and gives identical results.
Test Plan:
```
python -m pytest test/test_unary_ufuncs.py test/test_ops.py -k "cpu and (byte or char or uint8 or _refs__conversions or float16 and to)" # 5560 passed
python -m pytest test/test_torch.py test/test_type_promotion.py -k "cpu and (uint8 or byte or cast or copy or to_)" # 219 passed
```
plus exhaustive bit-pattern checks of contiguous vs strided vs `x.double().to(torch.int64).to(torch.uint8)`.
This PR was authored with the help of an AI assistant (Claude Code).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The int32 routes matched c10::convert for every finite input below 2^63, but not for +inf and larger values, where the scalar int64 route saturates to 0xff. That made contiguous and strided copies disagree again for those inputs and broke test_float_to_int_conversion_nonfinite_cpu_uint8 on ARM64. Use the same int64 narrowing for all three dtypes so contiguous and strided results are identical for every input. Test Plan: ``` python test/test_tensor_creation_ops.py -k float_to_int_conversion # 12 passed python -m pytest test/test_unary_ufuncs.py test/test_ops.py -k "cpu and (byte or char or uint8 or _refs__conversions or float16 and to)" # 5560 passed ``` plus contiguous vs strided equality over every float16/bfloat16 bit pattern (incl. inf/nan) and 16M random float32 values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 30, 2026
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.
DO NOT MERGE. A reproduction vehicle: points every macOS job at
macos-m1-15so this PR's own CI exercises Sequoia on M1.Run 36181945977
produced 19 consistent failures. 10 are covered by #198689; 9 are not.
NOT covered by #198689 — needs an owner
Both groups are CPU, so the MPS gates in #198689 do nothing for them. These
are what still block Wave 2 (us-east-1 → Sequoia).
8 x byte→half conversion,
test_unary_ufuncsdefault 3/3oni-0bf334e585cb3d11bWrong values, not precision drift — the non-contiguous path reads garbage.
Worth noting this would hit users on macOS 15, not just CI.
1 x
linalg_pinvgradient,test_aotdispatchdefault 2/3oni-038ded07e7bdd9e9aSmall numeric drift on the compiled-vs-eager gradient — plausibly Accelerate/LAPACK
on macOS 15. Different in character from the byte bug; likely a separate issue.
Covered by #198689 — 10 MPS
test_mpsjob (widest view) ·also in
1/3·2/3·3/3test_ops.py::TestCommonMPS::test_dtypes_scatter_reduce_amin/amax_mpstest_ops.py::TestCommonMPS::test_noncontiguous_samples_scatter_reduce_amin/amax_mps_int64test_mps.py::TestConsistencyMPS::test_output_match_scatter_reduce_amin/amax_mps_int64test_mps.py::TestMPS::test_large_bmm_float16/bfloat16test_nn.py::TestNNDeviceTypeMPS::test_grid_sample_large_index_2d/3d_mps_float32Root cause:
MACOS_VERSIONused as a proxy for a hardware property (16 GB vs32 GB;
ulongatomics on Apple7 vs Apple8). #198689 addsor IS_APPLE_M1.What the run established
succeeded; tests still fail.
macos-m2-15and
macos-m2-26are green on the same artifact.mainrun36180577497
scheduled the identical 25758
test_unary_ufuncsitems and passed.Changes here
trunk.yml(build runner-type,default1-3,openreg),mac-mps.yml(buildrunner-type + the
macos-m1-14entry),inductor-perf-test-nightly-macos.yml(build runner-type),
actionlint.yaml(registermacos-m1-15).Close rather than merge:
macos-m1-15is ~10 runners against ~96 Sonoma pets,and the tests fail there by construction.
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01