Skip to content

[MPS] Binary kernels produce incorrect results when one of the tensor arguments is from a wrapped scalar #152582

@qqaatw

Description

@qqaatw

🐛 Describe the bug

Repro:

import torch
tcpu = torch.tensor([1.0,2.0,3.0], device="cpu")
torch.copysign(tcpu, -2.0)  # tensor([-1., -2., -3.])
t = torch.tensor([1.0,2.0,3.0], device="mps")
torch.copysign(t, -2.0)  # tensor([1., 2., 3.], device='mps:0')

Internally, the scalar is wrapped into a cpu tensor and then re-dispatched.

Three possible solutions here:

  1. Wrap the scalar into an mps tensor instead of a cpu tensor.
  2. Send the cpu tensor to mps in the binary kernel.
  3. Error out rather than produce incorrect results.

Versions

nightly

cc @kulinseth @albanD @malfet @DenisVieriu97 @jhavukainen

Metadata

Metadata

Assignees

Labels

module: correctness (silent)issue that returns an incorrect result silentlymodule: mpsRelated to Apple Metal Performance Shaders frameworkmodule: regressionIt used to work, and now it doesn'ttriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions