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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

torch.fft.irfft(torch.fft.rrft) is not identity on MPS #126649

Open
cjolif opened this issue May 19, 2024 · 0 comments 路 May be fixed by #126651
Open

torch.fft.irfft(torch.fft.rrft) is not identity on MPS #126649

cjolif opened this issue May 19, 2024 · 0 comments 路 May be fixed by #126651
Labels
module: mps Related to Apple Metal Performance Shaders framework triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@cjolif
Copy link

cjolif commented May 19, 2024

馃悰 Describe the bug

On CPU, call torch.fft.irfft(torch.fft.rrft) gives back the initial signal (as expected) it is not on MPS.

t = torch.linspace(0, 1, 5, device="cpu")
T = torch.fft.rfft(t)
roundtrip = torch.fft.irfft(T, t.numel())
print(t, roundtrip)
torch.testing.assert_close(roundtrip, t, check_stride=False)

t = torch.linspace(0, 1, 5, device="mps")
T = torch.fft.rfft(t)
roundtrip = torch.fft.irfft(T, t.numel())
print(t, roundtrip)
torch.testing.assert_close(roundtrip, t, check_stride=False)

gives

tensor([0.0000, 0.2500, 0.5000, 0.7500, 1.0000]) tensor([0.0000, 0.2500, 0.5000, 0.7500, 1.0000])
tensor([0.0000, 0.2500, 0.5000, 0.7500, 1.0000], device='mps:0') tensor([0.0000, 1.0000, 0.7500, 0.5000, 0.2500], device='mps:0')
Traceback (most recent call last):
  File "/Users/cjolif/Personnal/Playground/torch_playground.py", line 48, in <module>
    torch.testing.assert_close(roundtrip, t, check_stride=False)
  File "/Users/cjolif/Personnal/Playground/.venv_main/lib/python3.10/site-packages/torch/testing/_comparison.py", line 1523, in assert_close
    raise error_metas[0].to_error(msg)
AssertionError: Tensor-likes are not close!

Mismatched elements: 4 / 5 (80.0%)
Greatest absolute difference: 0.75 at index (1,) (up to 1e-05 allowed)
Greatest relative difference: 3.0 at index (1,) (up to 1.3e-06 allowed)

This was tested on both 2.3.1 and 2.4.0-rc

Versions

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

OS: macOS 14.5 (arm64)
GCC version: Could not collect
Clang version: 15.0.0 (clang-1500.3.9.4)
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.14 (main, May 18 2024, 21:07:07) [Clang 15.0.0 (clang-1500.3.9.4)] (64-bit runtime)
Python platform: macOS-14.5-arm64-arm-64bit
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
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Apple M3

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] torch==2.4.0.dev20240519
[pip3] torchaudio==2.2.0.dev20240519
[pip3] torchvision==0.19.0.dev20240519
[conda] Could not collect

cc @kulinseth @albanD @malfet @DenisVieriu97 @jhavukainen

cjolif added a commit to cjolif/pytorch that referenced this issue May 19, 2024
@drisspg drisspg added module: mps Related to Apple Metal Performance Shaders framework triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels May 20, 2024
cjolif added a commit to cjolif/pytorch that referenced this issue May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: mps Related to Apple Metal Performance Shaders framework triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants