RuntimeError: false INTERNAL ASSERT FAILED at “/opt/conda/conda-bld/pytorch_1682343995622/work/aten/src/ATen/native/BatchLinearAlgebra.cpp”:1538, please report a bug to PyTorch. torch.linalg.lstsq: Argument 6 has illegal value. Most certainly there is a bug in the implementation calling the backend library.
The RuntimeError appear when run following code:
import torch
x = torch.arange(10, 50, step=1, dtype=torch.float32)
y = torch.exp(-((x-100)/(0.60056120439323*100))**2)
y = 100 * y + 10 * torch.randn(x.shape)
y = torch.log(y)
x = x.unsqueeze(dim=0)
y = y.unsqueeze(dim=0)
x = torch.linalg.vander(x, N = 3).flip(-1)
coefficients = torch.linalg.lstsq(x, y).solution
print(coefficients)

the code works fine if without add noise to data y, that is remove the line “y = 100 * y + 10 * torch.randn(x.shape)”
torch.version == 2.0.1

Hi auyb!

This looks like a known bug – see this pytorch github issue.

Note, I can reproduce your issue using your code on both pytorch version 2.3.0
and on the current pytorch nightly, 2.4.0.dev20240519, on the cpu. Your code
runs for me without error (but the results are nans) on the gpu on version 2.3.0.

Best.

K. Frank