I have recently been reproducing the efficient KAN project [GitHub - Blealtan/efficient-kan: An efficient pure-PyTorch implementation of Kolmogorov-Arnold Network (KAN).], which uses B-spline curves to replace the traditional activation functions in MLPs. In the project’s ./efficient_kan/kan, the class KANLinear defines a method curve2coeff
that involves solving for the coefficients of the interpolation curve using the least squares method, so that the input (x) and output (y) are approximated by a B-spline. However, when running this function, an error occurs with the message as follows. I believe there may have been some issues with the implementation of the numerical computations. The prompt also asks me to report that there might be a bug.
Traceback (most recent call last):
File “C:\Users\Yibin\Downloads\efficient-kan-master\tests\test_simple_math.py”, line 41, in
test_mul()
File “C:\Users\Yibin\Downloads\efficient-kan-master\tests\test_simple_math.py”, line 29, in test_mul
optimizer.step(closure)
File “C:\Users\Yibin.conda\envs\kan_env\lib\site-packages\torch\optim\optimizer.py”, line 487, in wrapper
out = func(*args, **kwargs)
File “C:\Users\Yibin.conda\envs\kan_env\lib\site-packages\torch\utils_contextlib.py”, line 116, in decorate_context
return func(*args, **kwargs)
File “C:\Users\Yibin.conda\envs\kan_env\lib\site-packages\torch\optim\lbfgs.py”, line 330, in step
orig_loss = closure()
File “C:\Users\Yibin.conda\envs\kan_env\lib\site-packages\torch\utils_contextlib.py”, line 116, in decorate_context
return func(*args, **kwargs)
File “C:\Users\Yibin\Downloads\efficient-kan-master\tests\test_simple_math.py”, line 18, in closure
y = kan(x, update_grid=(i % 20 == 0))
File “C:\Users\Yibin.conda\envs\kan_env\lib\site-packages\torch\nn\modules\module.py”, line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File “C:\Users\Yibin.conda\envs\kan_env\lib\site-packages\torch\nn\modules\module.py”, line 1747, in call_impl
return forward_call(*args, **kwargs)
File “C:\Users\Yibin\Downloads\efficient-kan-master\efficient_kan\kan.py”, line 277, in forward
layer.update_grid(x)
File “C:\Users\Yibin.conda\envs\kan_env\lib\site-packages\torch\utils_contextlib.py”, line 116, in decorate_context
return func(*args, **kwargs)
File “C:\Users\Yibin\Downloads\efficient-kan-master\efficient_kan\kan.py”, line 215, in update_grid
self.spline_weight.data.copy(self.curve2coeff(x, unreduced_spline_output))
File “C:\Users\Yibin\Downloads\efficient-kan-master\efficient_kan\kan.py”, line 131, in curve2coeff
solution = torch.linalg.lstsq(
RuntimeError: false INTERNAL ASSERT FAILED at “C:\cb\pytorch_1000000000000\work\aten\src\ATen\native\BatchLinearAlgebra.cpp”:1539, please report a bug to PyTorch. torch.linalg.lstsq: (Batch element 0): Argument 6 has illegal value. Most certainly there is a bug in the implementation calling the backend library.