pytorch - 💡(How to fix) Fix [MPS] invalid `.fill_()` on offset view of 1D BoolTensor [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#183631Fetched 2026-05-14 03:28:02
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Error Message

Some brief tests suggest the error occurs on any 1-dimensional BoolTensor.

Code Example

import torch

x = torch.zeros((16,), dtype=torch.bool, device='mps')

a = x[1:]
a.fill_(True)

print(x)

---

tensor([ True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True, False,  True,  True,  True], device='mps:0')

---

tensor([ False,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True, True,  True,  True,  True, True], device='mps:0')

---

PyTorch version: 2.12.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 26.4.1 (arm64)
GCC version: Could not collect
Clang version: 21.0.0 (clang-2100.1.1.101)
CMake version: version 4.3.2
Libc version: N/A

Python version: 3.14.4 (main, Apr  7 2026, 13:13:20) [Clang 21.0.0 (clang-2100.0.123.102)] (64-bit runtime)
Python platform: macOS-26.4.1-arm64-arm-64bit-Mach-O
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

CPU:
Apple M3

Versions of relevant libraries:
[pip3] numpy==2.4.4
[pip3] torch==2.12.0
[conda] Could not collect
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

Tensor.fill_(True) on the following bool view on MPS with storage offset 1 writes to position 0 and skips position 12.

import torch

x = torch.zeros((16,), dtype=torch.bool, device='mps')

a = x[1:]
a.fill_(True)

print(x)

Produces the following x:

tensor([ True,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True,  True, False,  True,  True,  True], device='mps:0')

When our expected x value should be:

tensor([ False,  True,  True,  True,  True,  True,  True,  True,  True,  True,
         True, True,  True,  True,  True, True], device='mps:0')

Some brief tests suggest the error occurs on any 1-dimensional BoolTensor.

Versions

PyTorch version: 2.12.0
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 26.4.1 (arm64)
GCC version: Could not collect
Clang version: 21.0.0 (clang-2100.1.1.101)
CMake version: version 4.3.2
Libc version: N/A

Python version: 3.14.4 (main, Apr  7 2026, 13:13:20) [Clang 21.0.0 (clang-2100.0.123.102)] (64-bit runtime)
Python platform: macOS-26.4.1-arm64-arm-64bit-Mach-O
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True
Caching allocator config: N/A

CPU:
Apple M3

Versions of relevant libraries:
[pip3] numpy==2.4.4
[pip3] torch==2.12.0
[conda] Could not collect

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - 💡(How to fix) Fix [MPS] invalid `.fill_()` on offset view of 1D BoolTensor [1 participants]