rfftn and irfftn operations in pt2 return different results compared to v1.12.1
Labels: module: cuda, triaged, module: third_party, module: fft

### 🐛 Describe the bug

When running inference on the [Lama inpainting model](https://github.com/advimman/lama) under PT2 using the supplied [predict.py](https://github.com/advimman/lama/blob/main/bin/predict.py) script, differences emerge after the FFT operations in the network architecture (specifically in lines 86 and 108 of [this file](https://github.com/advimman/lama/blob/main/saicinpainting/training/modules/ffc.py#L86), compared to older pre-PT2 versions.
These differences are cascaded through the network, and result in visible "grid" artifacts when running the inpainting model on large resolution images (around 1024 and above).

Example code that creates a very minor difference:
```
x = torch.rand((1,192,256,256), device='cuda')*3-1.2
ffted = torch.fft.rfftn(x, dim=(-2, -1), norm='ortho')
output = torch.fft.irfftn(ffted, s=ifft_shape_slice, dim=fft_dim, norm=self.fft_norm)
```
The actual differences I get when running the Lama model are much larger - after the first rfftn+irfftn operations on a similar sized input (from 1024x1024 input image), the MAD (mean-absolute difference) between the resulting tensors is around 0.15 and the max difference is 1.12.
It looks like most of the difference is created in the `irfftn` method (the inputs to this operation have MAD of 2e-8 and max difference of 8e-5).

I didn't see any related information in the release notes of the latest versions, so I wondered if these differences are expected.
BTW - this behavior also happens when running the Lama model using the [Lama Cleaner](https://github.com/Sanster/lama-cleaner) codebase

### Versions

Collecting environment information...
PyTorch version: 2.0.1+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.26.3
Libc version: glibc-2.31

Python version: 3.10.11 | packaged by conda-forge | (main, May 10 2023, 18:58:44) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-5.11.0-1022-aws-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 11.3.109
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA A10G
Nvidia driver version: 470.199.02
cuDNN version: Probably one of the following:
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn.so.8.2.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8.2.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_adv_train.so.8.2.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8.2.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8.2.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8.2.1
/usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudnn_ops_train.so.8.2.1
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   48 bits physical, 48 bits virtual
CPU(s):                          8
On-line CPU(s) list:             0-7
Thread(s) per core:              2
Core(s) per socket:              4
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       AuthenticAMD
CPU family:                      23
Model:                           49
Model name:                      AMD EPYC 7R32
Stepping:                        0
CPU MHz:                         2800.000
BogoMIPS:                        5600.00
Hypervisor vendor:               KVM
Virtualization type:             full
L1d cache:                       128 KiB
L1i cache:                       128 KiB
L2 cache:                        2 MiB
L3 cache:                        16 MiB
NUMA node0 CPU(s):               0-7
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Full AMD retpoline, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch topoext ssbd ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 clzero xsaveerptr rdpru wbnoinvd arat npt nrip_save rdpid

Versions of relevant libraries:
[pip3] flake8==6.0.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.24.3
[pip3] pytorch-lightning==1.2.9
[pip3] torch==2.0.1
[pip3] torch-model-archiver==0.8.1
[pip3] torchaudio==2.0.2
[pip3] torchmetrics==0.2.0
[pip3] torchserve==0.8.1
[pip3] torchvision==0.15.2
[pip3] triton==2.0.0
[conda] numpy                     1.24.3                   pypi_0    pypi
[conda] pytorch-cuda              11.7                 h778d358_5    pytorch
[conda] pytorch-lightning         1.2.9                    pypi_0    pypi
[conda] torch                     2.0.1                    pypi_0    pypi
[conda] torch-model-archiver      0.8.1                    pypi_0    pypi
[conda] torchaudio                2.0.2                    pypi_0    pypi
[conda] torchmetrics              0.2.0                    pypi_0    pypi
[conda] torchserve                0.8.1                    pypi_0    pypi
[conda] torchvision               0.15.2                   pypi_0    pypi
[conda] triton                    2.0.0                    pypi_0    pypi

cc @ptrblck @mruberry @peterbell10 @ezyang @msaroufim @wconstab @bdhirsh @anijain2305