Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result for torch.pow mismatch between PyTorch eager and PyTorch/XLA. #6750

Open
ysiraichi opened this issue Mar 14, 2024 · 0 comments
Open
Labels

Comments

@ysiraichi
Copy link
Collaborator

🐛 Bug

The following cases to torch.pow result in mismatched results, when comparing with PyTorch eager:

>>> x = torch.tensor([-3, -2, -1,  0,  1])

>>> torch.pow(x, -1)
# > Expected: RuntimeError: Integers to negative integer powers are not allowed.
# >   Actual: tensor([ 0,  0, -1, -1,  1], device='xla:0')

>>> torch.pow(x, torch.tensor(-1))
# > Expected: tensor([ 0,  0, -1,  0,  1])
# >   Actual: tensor([ 0,  0, -1, -1,  1], device='xla:0')

>>> torch.pow(0, torch.tensor(-1))
# > Expected: tensor(0)
# >   Actual: tensor(-1, device='xla:0')

Interestingly, the result of these other cases match:

>>> torch.pow(x, -1 * torch.ones(x.shape))
>>> torch.pow(0, -1 * torch.ones(x.shape))

Here are some observation:

  • 0 ** (-1) should be inf. Not 0 nor 1
  • The results seem to mismatch when XLA has to broadcast the result (?)

Environment

  • Reproducible on XLA backend [CPU/TPU/CUDA]: CUDA
  • torch_xla version: 99c41ba

cc @miladm @JackCaoG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant