Function approximation with Haar-variant basis system, and KAN using it

root

KAN/H: Kolmogorov-Arnold Network Using Slash-Haar Bases

NB: targets whose name ends with Tensor use (untyped part of) HaskTorch, are still experimental, and are space inefficient because compression to PATRICIA-trees has not been implemented for them.

Preprint

https://arxiv.org/abs/2511.11736

Requirements

  • Glasgow Haskell Compiler and Cabal

install them via GHCup if you have not yet.

  • (optional) CPython environment with scipy installed, for experiments using scipy.special

Reproducing the results from the paper (first arXiv submission)

Firstly do not forget to execute:

cabal update

Section 4.2, Figure 4

cabal build testFloatingHV --flags="scipy -parallel"
cabal run testFloatingHV  --flags="scipy -parallel" -- 1000000 > floating.data
gnuplot
# within gnuplot run:
load "src/floating.gp"

Section 4.2.1

LIBTORCH_CUDA_VERSION=cu128  # for CUDA Version 12.8. Also set up variables according to https://hackage-content.haskell.org/package/libtorch-ffi-2.0.1.10 if you like.
source setenv
cabal build testHaarTensor --flags=cuda
time cabal run testHaarTensor --flags=cuda -- 100000000000

Section 4.3, Figure 5

cabal build rmse --flags="parallel -scipy"
REPEAT=1 time cabal run rmse --flags="parallel -scipy" -- toys +RTS -N < confs/rmse/kanX55X10Mb.5NoNormDep2fpPrec28Dom19id.conf |tee kanX55X10Mb.5NoNormDep2fpPrec28Dom19id.toys
REPEAT=1 time cabal run rmse --flags="parallel -scipy" -- feynmans +RTS -N < confs/rmse/kanX55X10Mb.5NoNormDep2fpPrec28Dom19id.conf |tee kanX55X10Mb.5NoNormDep2fpPrec28Dom19id.feynman
cabal build rmse --flags="-parallel scipy"
REPEAT=1 time cabal run rmse --flags="-parallel scipy" -- specials < confs/rmse/kanX55X10Mb.5NoNormDep2fpPrec28Dom19id.conf |tee kanX55X10Mb.5NoNormDep2fpPrec28Dom19id.specials
gnuplot
# within gnuplot run:
load "src/robustness.gp"

It turned out that multi-core parallelism should be exploited via hmatrix using big matrices rather than the GHC's parallel functionality, but that is not implemented yet.

Section 4.4, Table 1

cabal build MNIST
time cabal run MNIST -- +RTS -N8 < confs/MNIST/mnistKAN30prec820mid10id.conf
time cabal run MNIST -- +RTS -N8 < confs/MNIST/mnistKAN30prec820mid100id.conf