Skip to content

Tensor plus add result seems wrong [with Mac mps] #79672

@limuyiju

Description

@limuyiju

🐛 Describe the bug

Hi,
I am running pytorch with latest M1 support on Mac.

Seems plus add(+=) have implementation issue --- The result is different to normal add.

Attached is a simple test:

>>> a = torch.ones((2, 2),).to(torch.device("mps"))
>>> b = torch.ones((2, 2),).to(torch.device("mps"))
>>> a[:, 0] += b[:, 0]
>>> a
>>> tensor([[1., 1.],
             [1., 1.]], device='mps:0')
>>>
>>> a[:, 0] = a[:, 0] + b[:, 0]
>>> a
>>> tensor([[2.0000, 2.0000],
          [1.0000, 1.0000]], device='mps:0')

Versions

Collecting environment information...
PyTorch version: 1.13.0.dev20220612
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.4 (arm64)
GCC version: Could not collect
Clang version: 13.1.6 (clang-1316.0.21.2.5)
CMake version: version 3.22.0-rc2
Libc version: N/A

Python version: 3.8.13 (default, Mar 28 2022, 06:13:39)  [Clang 12.0.0 ] (64-bit runtime)
Python platform: macOS-12.4-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.22.3
[pip3] numpy-quaternion==2022.4.2
[pip3] torch==1.13.0.dev20220612
[pip3] torchaudio==0.14.0.dev20220603
[pip3] torchvision==0.14.0a0+f9f721d
[conda] numpy                     1.22.3           py38h25ab29e_0  
[conda] numpy-base                1.22.3           py38h974a1f5_0  
[conda] numpy-quaternion          2022.4.2                 pypi_0    pypi
[conda] pytorch                   1.13.0.dev20220612         py3.8_0    pytorch-nightly
[conda] torchaudio                0.14.0.dev20220603          pypi_0    pypi
[conda] torchvision               0.14.0a0+f9f721d          pypi_0    pypi

cc @kulinseth @albanD

Metadata

Metadata

Assignees

Labels

module: mpsRelated to Apple Metal Performance Shaders frameworktriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions