I run this:
t = torch.Tensor([-1, 1, -1, 1, -1, 1, -1, 1])

torch.irfft(torch.rfft(t, signal_dim=1), signal_ndim=1)
This produces
tensor([-1.7778,  1.6706, -1.3619,  0.8889, -0.3087, -0.3087,  0.8889, -1.3619,          1.6706])
Which isn’t even a linearly dependent scaling of the input.
The intermediate result from rfft seems right:
tensor([[ 0.,  0.],
        [ 0., -0.],
        [ 0.,  0.],
        [ 0.,  0.],
        [-8.,  0.]])
What am I doing wrong?