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

torch.nextafter has an incorrect result for bf16 on XPU #1169

Closed
guangyey opened this issue Dec 16, 2024 · 0 comments · Fixed by #1298 or #1302
Closed

torch.nextafter has an incorrect result for bf16 on XPU #1169

guangyey opened this issue Dec 16, 2024 · 0 comments · Fixed by #1298 or #1302
Assignees
Labels
bug Something isn't working

Comments

@guangyey
Copy link
Contributor

guangyey commented Dec 16, 2024

As titled, this is a regression. IPEX could give a correct result for bf16 on XPU.

import torch

torch.manual_seed(0)

a = torch.randn(5, dtype=torch.bfloat16)
b = torch.randn(5, dtype=torch.bfloat16)
print(f"a: {a}")
print(f"b: {b}")
print(torch.nextafter(a, b))

x_a = a.to('xpu')
x_b = b.to('xpu')
print(torch.nextafter(x_a, x_b))

Output:

a: tensor([ 1.5391, -0.2930, -2.1719,  0.5703, -1.0859], dtype=torch.bfloat16)
b: tensor([-1.3984,  0.4043,  0.8398, -0.7188, -0.4043], dtype=torch.bfloat16)
tensor([ 1.5312, -0.2910, -2.1562,  0.5664, -1.0781], dtype=torch.bfloat16)
tensor([ 1.5391, -0.2930, -2.1719,  0.5703, -1.0859], device='xpu:0',
       dtype=torch.bfloat16)

Versions

None

cc @fengyuan14 @xytintel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants