KAN Guide: Kolmogorov-Arnold Networks & Spline AI Models

The Problem: The Inherent Architectural Bottlenecks of Multi-Layer Perceptrons
For more than three decades, the foundational building block of deep learning has been the Multi-Layer Perceptron (MLP). From early feedforward networks to modern decoder-only foundation models, MLPs form the core of parameter capacity. In state-of-the-art transformer blocks, feedforward network (FFN) layers—such as SwiGLU, GeGLU, and standard gated projections—account for approximately two-thirds of the model’s total parameter count. In high-concurrency automated intelligence pipelines and real-time knowledge extractors powered by aiFetchly, MLPs serve as the primary associative memory stores responsible for retaining factual patterns, synthesizing numerical records, and executing multi-step reasoning.
However, despite their universal adoption, traditional MLPs are bound by structural assumptions rooted in the Universal Approximation Theorem. These design choices create acute theoretical and hardware bottlenecks in production:
The Structural Divergence: Multi-Layer Perceptrons vs. Kolmogorov-Arnold Networks
┌─────────────────────────────────────────────────────────────────────────────────┐
│ Traditional Multi-Layer Perceptron (MLP): │
│ • Linear affine transformation on edges: z = W · x │
│ • Fixed, static non-linear activation functions on nodes: y = σ(z) │
│ • Activations: ReLU, GeLU, SiLU applied uniformly across all neurons │
│ ❌ Global weight entanglement: any gradient step alters the entire domain │
│ ❌ Curse of dimensionality on compositional functions: requires massive width │
│ ❌ Uninterpretable black box: impossible to extract symbolic physical laws │
└─────────────────────────────────────────────────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ Kolmogorov-Arnold Network (KAN): │
│ • Learnable 1D univariate non-linear functions directly on edges: φ_{l,j,i}(x) │
│ • Parameterized via localized B-splines, orthogonal polynomials, or wavelets │
│ • Pure linear summation on nodes: x_{l+1,j} = Σ_i φ_{l,j,i}(x_{l,i}) │
│ ✔ Localized compact support: updates to one region never corrupt distant knots │
│ ✔ Faster neural scaling laws: O(N^-4) error convergence vs O(N^-2) for MLPs │
│ ✔ Transparent interpretability: prunes inactive edges to uncover closed formulas│
└─────────────────────────────────────────────────────────────────────────────────┘ 1. The Fixed Activation Dilemma and Width Inflation
In an MLP layer, weights are learnable linear coefficients arranged in a matrix $W \in \mathbb{R}^{d_{\text{out}} \times d_{\text{in}}}$, while the non-linear activation function $\sigma(\cdot)$ placed at each node is fixed, static, and immutable. Whether utilizing standard Rectified Linear Units (ReLU), Gaussian Error Linear Units (GELU), or Swish/SiLU, the activation function cannot adapt its shape.
To approximate complex multivariate non-linear surfaces, MLPs must scale horizontally by expanding hidden layer width ($d_{\text{ffn}} = 4d_{\text{model}}$ or $8d_{\text{model}}$). Because each neuron merely computes an affine hyperplane slice followed by a static kink or curve, capturing high-frequency oscillations or steep non-linear gradients requires combining hundreds or thousands of linear boundaries. This geometric inefficiency inflates parameter budgets and demands massive amounts of GPU memory bandwidth.
2. Catastrophic Forgetting from Global Weight Entanglement
In traditional linear layers, every weight parameter $W_{ij}$ influences the entire input space globally. When an engineering team updates an existing language model or embedding network on a new domain—such as indexing newly harvested financial disclosures through automated data fetching—backpropagation calculates gradient updates across all matrix entries:
$$\Delta W_{ij} = -\eta \frac{\partial \mathcal{L}}{\partial W_{ij}}$$
Because linear transformations have infinite, unbounded support across $\mathbb{R}$, adjusting $W_{ij}$ to satisfy the loss on a new data cluster inevitably shifts the hyperplanes that correctly classified historical data. This global weight coupling is the fundamental root cause of catastrophic forgetting in continual learning and fine-tuning.
3. The Black-Box Opacity Wall and Vanishing Interpretability
Modern neural networks are notoriously uninterpretable. An MLP layer with dimensions $4096 \times 14336$ contains over 58 million scalar coefficients. Looking at these matrices reveals zero human-comprehensible intuition regarding what mathematical relationships the network has synthesized.
In mission-critical enterprise applications—such as scientific simulations, pharmaceutical molecule binding calculations, algorithmic risk auditing, and automated financial extraction through high-speed web scraping—stakeholders cannot tolerate unverifiable predictions. When a model produces a critical prediction, regulators and researchers demand closed-form symbolic relationships, not opaque floating-point dot products.
4. The Curse of Dimensionality in Compositional Manifolds
According to the classical Universal Approximation Theorem (Cybenko, 1989; Hornik, 1991), a single hidden layer MLP with sufficiently many neurons can approximate any continuous function on a compact subset of $\mathbb{R}^n$. However, the theorem provides no guarantee of parameter efficiency. For an arbitrary $n$-dimensional function with smoothness order $k$, the approximation error $\epsilon$ scales asymptotically as:
$$\epsilon \sim \mathcal{O}\left(N^{-\frac{k}{n}}\right)$$
Where $N$ is the number of parameters. As the input dimensionality $n$ increases, the exponent $-k/n$ approaches zero, causing the parameter requirement to explode exponentially. This curse of dimensionality forces models to consume billions of parameters to learn basic compositional structures that could theoretically be represented by a handful of mathematical operations.
The Mathematical Foundation: The Kolmogorov-Arnold Representation Theorem
To solve the structural limitations of Multi-Layer Perceptrons, a research consortium led by Ziming Liu, Max Tegmark, and collaborators at MIT, Harvard, and Caltech introduced Kolmogorov-Arnold Networks (KANs). Rather than relying on the Universal Approximation Theorem, KANs are directly inspired by the seminal Kolmogorov-Arnold Representation Theorem (Kolmogorov, 1957; Arnold, 1957).
1. Classical Kolmogorov-Arnold Theorem Formulation
The Kolmogorov-Arnold representation theorem proved a profound mathematical result regarding multivariate functions: any continuous multivariate function defined on a bounded domain can be written as a finite composition of continuous functions of a single variable and the binary operation of addition.
Formally, for any continuous function $f: [0, 1]^n \to \mathbb{R}$:
$$f(x_1, x_2, \dots, x_n) = \sum_{q=1}^{2n+1} \Phi_q \left( \sum_{p=1}^n \phi_{q,p}(x_p) \right)$$
Where:
- $\phi_{q,p}: [0, 1] \to \mathbb{R}$ are continuous, univariate functions that map each individual input coordinate $x_p$ into an intermediate scalar representation.
- $\Phi_q: \mathbb{R} \to \mathbb{R}$ are continuous, univariate outer functions.
- The inner and outer summations represent exact linear additions without non-linear cross-terms.
This theorem establishes that multivariate functions do not fundamentally require high-dimensional non-linear interactions; they can be decomposed entirely into 1D univariate non-linearities and additions.
Classical Kolmogorov-Arnold Representation vs. Multi-Layer KAN
┌─────────────────────────────────────────────────────────────────────────────┐
│ Classical Kolmogorov-Arnold Form (2 Layers): │
│ │
│ x₁ ───► [ φ_{1,1}(x₁) ] ──┐ │
│ x₂ ───► [ φ_{1,2}(x₂) ] ──┼──► ( Σ ) ──► [ Φ₁(·) ] ──┐ │
│ x₃ ───► [ φ_{1,3}(x₃) ] ──┘ │ │
│ ├──► ( Σ ) ──► f(x) │
│ x₁ ───► [ φ_{2n+1,1}(x₁) ] ─┐ │ │
│ x₂ ───► [ φ_{2n+1,2}(x₂) ] ─┼──► ( Σ ) ──► [ Φ_{2n+1}(·) ] ┘ │
│ x₃ ───► [ φ_{2n+1,3}(x₃) ] ─┘ │
│ │
│ • Theoretical drawback: With only 2 layers, φ and Φ can be non-smooth or │
│ fractal, making optimization challenging in practice. │
└─────────────────────────────────────────────────────────────────────────────┘
▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ Deep Kolmogorov-Arnold Network (Arbitrary Depth & Width): │
│ │
│ Layer l: Layer l+1: Layer l+2: │
│ ( Node i ) ───[ Learnable φ ]───► ( Node j ) ───[ φ ]───► ( Node k ) │
│ │
│ • Arbitrary depth L allows smooth, well-behaved univariate spline functions.│
│ • Hierarchical composition unlocks faster neural scaling laws: O(N^-4). │
└─────────────────────────────────────────────────────────────────────────────┘ 2. From Classical 2-Layer Representation to Deep Arbitrary-Depth KANs
Historically, machine learning researchers dismissed the Kolmogorov-Arnold theorem as impractical for neural computation because the classical theorem restricts the network depth to exactly two layers ($2n+1$ inner terms). In a strict two-layer configuration, the required 1D functions $\phi_{q,p}$ and $\Phi_q$ can be pathological, non-differentiable, or fractal-like, making them impossible to fit reliably with gradient descent.
The breakthrough of modern KANs is the generalization from a rigid two-layer formula to an arbitrary-depth, arbitrary-width computational graph. Just as deep MLPs stack multiple linear-plus-activation layers to form hierarchical abstractions, a deep Kolmogorov-Arnold Network stacks multiple KAN layers:
$$\mathbf{x}_{l+1} = \mathbf{\Phi}_l(\mathbf{x}_l)$$
Where each layer $\mathbf{\Phi}l$ is a matrix of 1D functions. If layer $l$ has $n{\text{in}}$ inputs and $n_{\text{out}}$ outputs, the layer consists of $n_{\text{in}} \times n_{\text{out}}$ independent, learnable univariate functions:
$$ \mathbf{\Phi}l = \begin{pmatrix} \phi{l,1,1}(\cdot) & \phi_{l,1,2}(\cdot) & \cdots & \phi_{l,1,n_{\text{in}}}(\cdot) \ \phi_{l,2,1}(\cdot) & \phi_{l,2,2}(\cdot) & \cdots & \phi_{l,2,n_{\text{in}}}(\cdot) \ \vdots & \vdots & \ddots & \vdots \ \phi_{l,n_{\text{out}},1}(\cdot) & \phi_{l,n_{\text{out}},2}(\cdot) & \cdots & \phi_{l,n_{\text{out}},n_{\text{in}}}(\cdot) \end{pmatrix} $$
The activation value of node $j$ in layer $l+1$ is simply the sum of all incoming 1D functions applied to the nodes of layer $l$:
$$x_{l+1,j} = \sum_{i=1}^{n_{\text{in}}} \phi_{l,j,i}(x_{l,i})$$
In this architecture, nodes perform zero non-linear transformations; they act purely as summing junctions. All learnable non-linear complexity resides entirely on the directed edges connecting the nodes.
3. Edge-Parameterized Learnable Univariate Functions
To make edge functions $\phi(x)$ differentiable and computationally tractable on modern accelerators, KAN parameterizes each 1D edge as a linear combination of a smooth residual base function and a localized spline:
$$\phi(x) = w_b b(x) + w_s \text{spline}(x)$$
Where:
- $b(x)$ is a standard smooth activation function, typically the SiLU (Swish) function: $$b(x) = \text{SiLU}(x) = \frac{x}{1 + e^{-x}}$$
- $w_b$ is a learnable scalar weight that controls the linear residual magnitude.
- $w_s$ is a learnable scaling factor for the spline component.
- $\text{spline}(x)$ is a learnable linear combination of B-spline basis functions.
This residual formulation ensures that at initialization, the KAN layer behaves similarly to a standard linear layer with SiLU activations, ensuring stable gradient flow and preventing gradient vanishing during early training iterations.
4. B-Spline Parameterization and Cox-de Boor Recursion
The spline component is constructed using linear combinations of $B$-spline basis functions defined over a discrete grid of knots:
$$\text{spline}(x) = \sum_{i=0}^{G + k - 1} c_i B_i(x)$$
Where:
- $G$ is the number of grid intervals.
- $k$ is the polynomial degree of the B-splines (typically cubic splines, $k = 3$).
- $c_i$ are learnable coefficients (control points).
- $B_i(x)$ are $B$-spline basis functions evaluated recursively using the standard Cox-de Boor recursion formula:
For degree $0$:
$$ B_{i,0}(x) = \begin{cases} 1 & \text{if } t_i \le x \< t_{i+1} \ 0 & \text{otherwise} \end{cases} $$
For degree $p \ge 1$: $$B_{i,p}(x) = \frac{x - t_i}{t_{i+p} - t_i} B_{i,p-1}(x) + \frac{t_{i+p+1} - x}{t_{i+p+1} - t_{i+1}} B_{i+1,p-1}(x)$$
Where ${t_i}$ is the knot vector partitioning the input interval $[-1, 1]$ into $G$ equal segments, augmented with $k$ boundary knots on each end.
Because each basis function $B_{i,p}(x)$ has compact local support—it evaluates to non-zero values only across $k+1$ consecutive knot intervals $[t_i, t_{i+k+1}]$—evaluating or updating a B-spline for a given input value $x$ touches only $k+1$ coefficients out of $G+k$.
B-Spline Local Support vs. Global Linear Activations
Input Domain: [-1.0] ────── [ -0.5 ] ────── [ 0.0 ] ────── [ +0.5 ] ────── [ +1.0 ]
Knot Intervals: |─── G₁ ───|─── G₂ ───|─── G₃ ───|─── G₄ ───|
B-Spline B₁(x): [======= Non-Zero ======] 0 0 0
B-Spline B₂(x): 0 [======= Non-Zero ======] 0 0
B-Spline B₃(x): 0 0 [======= Non-Zero ======] 0
B-Spline B₄(x): 0 0 0 [======= Non-Zero ======]
▲
Incoming Input Token x = 0.2
Activates ONLY Splines B₂ and B₃!
Splines B₁ and B₄ remain completely dormant.
Updates to x = 0.2 NEVER modify parameters of B₁ or B₄! Core Architectural Mechanics of Kolmogorov-Arnold Networks
1. Residual Edge Activation Functions: Spline Plus Basis
The dual formulation $\phi(x) = w_b b(x) + w_s \text{spline}(x)$ provides a crucial bridge between continuous optimization and expressive non-linear modeling.
During training:
- The base branch $w_b \text{SiLU}(x)$ allows the model to quickly capture broad, coarse linear trends across the dataset with minimal computational overhead.
- The spline branch $w_s \sum_i c_i B_i(x)$ acts as a high-resolution localized non-linear residual. It bends, flexes, and adapts to intricate local curvatures, fitting complex functional transitions without altering global gradients.
- Both the spline coefficients ${c_i}$ and the scalar weights $w_b, w_s$ are jointly trained end-to-end via standard backpropagation using optimizers like AdamW or SGD.
2. Dynamic Grid Extension and Knot Vector Adaptation
One of the most remarkable properties of KANs is their ability to perform grid extension (knot refinement) during training.
In traditional neural networks, scaling model capacity requires adding more layers (depth) or increasing hidden dimensions (width), both of which alter the weight matrix shapes and require training from scratch or complex layer-dropping heuristics. In contrast, a KAN can scale its parameter capacity by simply refining its 1D spline grids:
Dynamic Grid Extension Workflow:
Step 1: Train coarse KAN with G = 3 grid intervals (Few parameters, fast convergence)
Grid: [-1.0] ────────────── [ -0.33 ] ────────────── [ +0.33 ] ────────────── [+1.0]
Step 2: Interpolate learned spline onto fine grid with G = 10 grid intervals
Grid: [-1.0][-.8][-.6][-.4][-.2][ 0.0 ][+.2][+.4][+.6][+.8][+1.0]
• Fit new B-spline coefficients c'_j via least-squares on existing spline:
Σ c'_j B'_j(x) ≈ Σ c_i B_i(x)
• Achieves ZERO loss degradation upon grid extension!
Step 3: Resume training at high grid resolution to learn fine-grained micro-features By initializing training on a coarse grid ($G = 3$ or $G = 5$) and dynamically expanding to fine grids ($G = 10, 20,$ or $50$), KANs avoid local minima during early training and converge to exceptionally low loss values that are mathematically unreachable by MLPs of equivalent size.
3. L1 Sparsification, Edge Pruning, and Symbolic Distillation
In addition to high accuracy, KANs were engineered specifically for mechanistic interpretability and scientific discovery. KANs achieve this through a 4-step pruning and symbolic regression pipeline:
- L1 Regularization on Edge Functions: During training, an L1 penalty is applied to the active magnitude of each edge function. The magnitude of an edge $\phi$ across a batch of $N$ samples is defined as its $L_1$ norm: $$|\phi|1 = \frac{1}{N} \sum{p=1}^N |\phi(x^{(p)})|$$ The training objective adds an edge-sparsity loss: $$\mathcal{L}{\text{total}} = \mathcal{L}{\text{task}} + \lambda_{\text{reg}} \sum_{l,j,i} |\phi_{l,j,i}|_1$$
- Edge Pruning: After training with sparsity regularization, edges whose norm $|\phi|1$ falls below a defined threshold $\epsilon{\text{prune}}$ (e.g., $10^{-2}$) are pruned from the computational graph. Nodes with no incoming or outgoing connections are eliminated entirely.
- Symbolic Function Snapping: For remaining active edges, researchers can visually inspect the 1D curve $\phi(x)$. By running symbolic regression against a dictionary of elementary functions ($\sin, \cos, \exp, \log, x^2, x^3, \sqrt{x}, 1/x$), the learned spline is replaced with an exact analytic formula: $$\phi(x) \approx c \cdot \sin(\omega x + \theta)$$
- Closed-Form Equation Extraction: Once all active edges are snapped to symbolic functions, the entire deep network collapses into a human-readable mathematical equation, converting an artificial neural network into an exact, verifiable scientific law.
4. Locality of B-Splines: Immunity to Catastrophic Forgetting
In traditional MLPs, activation functions like ReLU or SiLU have infinite support: activating a neuron on an input $x = 10.0$ impacts its gradients across all future inputs $x \in (-\infty, \infty)$.
In a KAN, B-spline basis functions are strictly locally supported. If a model receives training data concentrated in the interval $[0.2, 0.4]$, only the spline coefficients associated with the knot intervals covering $[0.2, 0.4]$ receive non-zero gradients. The coefficients governing $[-1.0, 0.0]$ and $[0.6, 1.0]$ experience zero gradient updates:
$$\frac{\partial \mathcal{L}}{\partial c_m} = \frac{\partial \mathcal{L}}{\partial \phi(x)} \cdot B_m(x) = 0 \quad \text{if } x \notin [t_m, t_{m+k+1}]$$
Consequently, when deployed in continual learning environments—such as autonomous scraping agents continuously learning new DOM structures via seamless API integration—KANs can incorporate new domain distributions without overwriting previously consolidated parameters.
Kolmogorov-Arnold Transformers (KAT) & Fast-KAN Engineering
While original KAN implementations demonstrated remarkable mathematical properties on scientific computing tasks, scaling them to large-scale natural language processing and computer vision revealed a severe systems bottleneck: B-splines evaluated sequentially on GPUs are slow.
In vanilla KANs, evaluating recursive Cox-de Boor algorithms requires branching logic, uncoalesced memory reads, and high memory footprints when materializing the 3D tensor of basis evaluations $\mathcal{O}(B \times L \times n_{\text{in}} \times G)$.
To integrate KANs into production transformers, systems researchers introduced Kolmogorov-Arnold Transformers (KAT) and high-throughput GPU kernels:
Standard Transformer vs. Kolmogorov-Arnold Transformer (KAT) Block
┌────────────────────────────────────────────────────────┐
│ Standard Transformer Decoder Block: │
│ Input Tokens ──► RMSNorm ──► Self-Attention ──► (+) │
│ │ ▲ │
│ └────────────────────────────────┘ │
│ Tokens ──► RMSNorm ──► SwiGLU / MLP Layer ────► (+) │
│ • Linear Up-Projection: W_gate · x ⊙ W_up · x │
│ • Linear Down-Projection: W_down · z │
│ • Accounts for 66% of model parameters │
└────────────────────────────────────────────────────────┘
▼
┌────────────────────────────────────────────────────────┐
│ Kolmogorov-Arnold Transformer (KAT) Block: │
│ Input Tokens ──► RMSNorm ──► Self-Attention ──► (+) │
│ │ ▲ │
│ └────────────────────────────────┘ │
│ Tokens ──► RMSNorm ──► Kolmogorov-Arnold FFN ──► (+) │
│ • Fast-KAN or ChebyKAN Layer: │
│ y_j = Σ_i [ w_b · SiLU(x_i) + w_s · φ(x_i) ] │
│ • Down-Projection Linear Fusion │
│ • 50% fewer FFN parameters for equal perplexity │
│ • Higher mathematical and reasoning expressivity │
└────────────────────────────────────────────────────────┘ 1. Replacing SwiGLU / MLP FFN Blocks in Transformer Decoders
In standard LLaMA-style architectures, the feed-forward network computes:
$$\text{FFN}{\text{SwiGLU}}(x) = \left( \text{SiLU}(x W{\text{gate}}) \odot x W_{\text{up}} \right) W_{\text{down}}$$
Where $W_{\text{gate}}, W_{\text{up}} \in \mathbb{R}^{d \times d_{\text{ffn}}}$ and $W_{\text{down}} \in \mathbb{R}^{d_{\text{ffn}} \times d}$.
In a Kolmogorov-Arnold Transformer (KAT), this block is replaced by a two-stage KAN-FFN:
- KAN Expansion: Ingests normalized token embeddings $x \in \mathbb{R}^d$ and projects them through a matrix of learnable univariate edge functions into hidden dimension $d_{\text{kan}}$ (where $d_{\text{kan}} \approx 1.5d_{\text{model}}$ to $2d_{\text{model}}$, rather than $4d_{\text{model}}$ used in MLPs).
- Linear Down-Projection: A standard linear projection matrix $W_{\text{down}} \in \mathbb{R}^{d_{\text{kan}} \times d}$ fuses the non-linear outputs back into the residual stream.
Because each KAN edge possesses non-linear approximation capacity, $d_{\text{kan}}$ can be set significantly smaller than traditional FFN intermediate dimensions, reducing overall parameter counts while maintaining or exceeding downstream task performance.
2. Fast-KAN: Radial Basis Functions (RBF) and GPU Tensorization
To eliminate the sequential recursion of Cox-de Boor B-splines on CUDA cores, the Fast-KAN framework (Li, 2024) replaces B-splines with Gaussian Radial Basis Functions (RBFs):
$$\psi_i(x) = \exp \left( -\left( \frac{x - \mu_i}{h} \right)^2 \right)$$
Where $\mu_i$ are uniformly spaced grid centers and $h$ is a bandwidth hyperparameter.
The profound engineering advantage of Gaussian RBFs is that they can be computed purely via element-wise matrix arithmetic:
- Normalize input tensor $X$.
- Compute distance matrix $(X - \mu)^2$ via fast fused broadcast subtraction.
- Compute exponentiation $\exp(\cdot)$ using high-throughput GPU special function units (SFU).
- Compute edge outputs via standard matrix multiplication (GEMM): $$Y = \text{RBF}(X) \cdot C$$ Where $C$ is the learnable coefficient matrix.
By reformulating spline evaluation into a dense GEMM operation, Fast-KAN achieves up to $3.3\times$ faster training throughput compared to naive B-spline implementations, fully saturating modern NVIDIA Tensor Cores.
3. ChebyKAN: Orthogonal Chebyshev Polynomial Expansions
Another highly efficient KAN variant is ChebyKAN, which replaces splines with truncated Chebyshev polynomials of the first kind ($T_n(x)$):
$$\phi(x) = \sum_{n=0}^N c_n T_n(x)$$
Chebyshev polynomials are defined recursively on the interval $[-1, 1]$: $$T_0(x) = 1$$ $$T_1(x) = x$$ $$T_{n+1}(x) = 2x T_n(x) - T_{n-1}(x)$$
Because Chebyshev polynomials form an orthogonal basis:
- They minimize Runge’s phenomenon (wild oscillations at domain boundaries).
- The polynomial evaluation vector $[T_0(x), T_1(x), \dots, T_N(x)]$ can be computed in parallel across all tokens in $\mathcal{O}(N)$ arithmetic steps.
- The projection $\sum_n c_n T_n(x)$ is computed via a single standard PyTorch
torch.matmul, executing at near-peak FLOP utilization on both client GPUs and datacenter clusters.
4. Training Throughput vs Parameter Efficiency Trade-Offs
When evaluating KAN layers against traditional MLPs for enterprise deployment, systems architects must balance parameter count against wall-clock FLOP efficiency:
Hardware Scaling Trade-offs: MLP vs. B-Spline KAN vs. Fast-KAN vs. ChebyKAN
┌──────────────────┬─────────────────┬──────────────────┬──────────────────┬─────────────────┐
│ Metric │ Standard SwiGLU │ Vanilla B-Spline │ Fast-KAN (RBF) │ ChebyKAN │
├──────────────────┼─────────────────┼──────────────────┼──────────────────┼─────────────────┤
│ Parameter Budget │ 1.0x (Baseline) │ 0.5x - 0.7x │ 0.6x - 0.7x │ 0.5x - 0.6x │
│ Forward FLOPs │ Dense GEMM │ Branching Spline │ Fast SFU + GEMM │ Orthogonal GEMM │
│ GPU Training QPS │ 100% (Fastest) │ ~15% - 25% (Slow)│ ~70% - 85% │ ~80% - 90% │
│ Catastrophic │ Severe │ Near-Zero │ Low │ Moderate │
│ Forgetting Risk │ (Global drift) │ (Local Support) │ (Local Support) │ (Global basis) │
│ Symbolic Extract │ Impossible │ Native (Closed) │ Approximated │ Polynomial Form │
└──────────────────┴─────────────────┴──────────────────┴──────────────────┴─────────────────┘ For large language models where maximum token throughput per second dominates infrastructure budgets, Fast-KAN and ChebyKAN represent the optimal engineering compromise—delivering KAN’s superior parameter efficiency and mathematical expressivity while maintaining standard GEMM compatibility.
End-to-End PyTorch Implementation: Building a Kolmogorov-Arnold Layer and KAN-FFN
To demonstrate how Kolmogorov-Arnold Networks operate in production, we implement a complete, optimized PyTorch module. We first construct a modular KANLinear layer utilizing B-splines with Cox-de Boor evaluation and residual SiLU connections, followed by a drop-in KolmogorovArnoldFFN block designed for transformer architectures.
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
class KANLinear(nn.Module):
# Kolmogorov-Arnold Network (KAN) Linear Layer
# Replaces static weights with learnable 1D B-spline functions on edges:
# phi(x) = w_b * SiLU(x) + w_s * spline(x)
def __init__(
self,
in_features: int,
out_features: int,
grid_size: int = 5,
spline_order: int = 3,
scale_noise: float = 0.1,
scale_base: float = 1.0,
scale_spline: float = 1.0,
grid_range: tuple = (-1.0, 1.0),
):
super().__init__()
self.in_features = in_features
self.out_features = out_features
self.grid_size = grid_size
self.spline_order = spline_order
self.scale_base = scale_base
self.scale_spline = scale_spline
# Compute knot vector for B-splines
h = (grid_range[1] - grid_range[0]) / grid_size
grid = torch.linspace(
grid_range[0] - spline_order * h,
grid_range[1] + spline_order * h,
grid_size + 2 * spline_order + 1,
dtype=torch.float32,
)
self.register_buffer("grid", grid)
# Base residual weight matrix (Linear affine transformation)
self.base_weight = nn.Parameter(torch.empty(out_features, in_features))
# Spline coefficient tensor: [out_features, in_features, num_spline_bases]
num_bases = grid_size + spline_order
self.spline_weight = nn.Parameter(torch.empty(out_features, in_features, num_bases))
# Learnable scaling factors
self.spline_scaler = nn.Parameter(torch.ones(out_features, in_features))
self.reset_parameters(scale_noise)
def reset_parameters(self, scale_noise: float):
nn.init.kaiming_uniform_(self.base_weight, a=math.sqrt(5) * self.scale_base)
with torch.no_grad():
noise = (torch.rand_like(self.spline_weight) - 0.5) * scale_noise
self.spline_weight.copy_(noise)
def compute_b_splines(self, x: torch.Tensor) -> torch.Tensor:
# Evaluates B-spline basis functions using Cox-de Boor recurrence relation
# Args: x of shape [batch_size, in_features]
# Returns: bases tensor of shape [batch_size, in_features, num_bases]
x_expanded = x.unsqueeze(-1)
grid = self.grid
# Degree 0 basis functions (indicator functions)
bases = ((x_expanded >= grid[:-1]) & (x_expanded < grid[1:])).to(x.dtype)
# Recursive computation for degrees 1 through spline_order
for k in range(1, self.spline_order + 1):
left_denom = grid[k:-1] - grid[:-(k + 1)]
right_denom = grid[k + 1:] - grid[1:-k]
left_term = (x_expanded - grid[:-(k + 1)]) / left_denom * bases[..., :-1]
right_term = (grid[k + 1:] - x_expanded) / right_denom * bases[..., 1:]
bases = left_term + right_term
return bases
def forward(self, x: torch.Tensor) -> torch.Tensor:
# Forward execution of KAN Linear Layer:
# y_j = Sum_i [ w_b * SiLU(x_i) + w_s * spline(x_i) ]
orig_shape = x.shape
x_flat = x.view(-1, self.in_features)
# 1. Base residual branch: SiLU activation + linear projection
base_output = F.linear(F.silu(x_flat), self.base_weight)
# 2. Spline branch: Compute B-spline bases and contract with coefficients
spline_bases = self.compute_b_splines(x_flat) # [B, in_features, num_bases]
# Contract over spline bases: sum_k (bases[b, i, k] * weight[j, i, k])
spline_output = torch.einsum("bik,jik->bj", spline_bases, self.spline_weight * self.spline_scaler.unsqueeze(-1))
# Combine base and spline branches
output = base_output + spline_output
return output.view(*orig_shape[:-1], self.out_features)
class KolmogorovArnoldFFN(nn.Module):
# Drop-in Kolmogorov-Arnold Feed-Forward Network for Transformers
# Replaces standard SwiGLU/MLP layers with a high-expressivity KAN block
def __init__(
self,
d_model: int,
d_kan: int = None,
grid_size: int = 5,
spline_order: int = 3,
dropout: float = 0.0,
):
super().__init__()
# KAN layers require fewer intermediate hidden dimensions than MLPs (e.g. 1.5x vs 4x)
if d_kan is None:
d_kan = int(d_model * 1.5)
self.kan_up = KANLinear(
in_features=d_model,
out_features=d_kan,
grid_size=grid_size,
spline_order=spline_order,
)
self.layer_norm = nn.LayerNorm(d_kan)
self.dropout = nn.Dropout(dropout)
self.linear_down = nn.Linear(d_kan, d_model)
def forward(self, x: torch.Tensor) -> torch.Tensor:
# Step 1: Up-projection through learnable edge functions
h = self.kan_up(x)
h = self.layer_norm(h)
h = self.dropout(h)
# Step 2: Linear down-projection back to model residual stream
out = self.linear_down(h)
return out
# Verification and smoke test
if __name__ == "__main__":
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(f"Initializing KAN verification on {device}...")
batch_size = 4
seq_len = 128
d_model = 512
dummy_tokens = torch.randn(batch_size, seq_len, d_model, device=device)
# Initialize Kolmogorov-Arnold Transformer FFN Block
kan_ffn = KolmogorovArnoldFFN(d_model=d_model, d_kan=768).to(device)
# Execute forward pass
output = kan_ffn(dummy_tokens)
print(f"Input Tensor Shape: {list(dummy_tokens.shape)}")
print(f"Output Tensor Shape: {list(output.shape)}")
assert output.shape == dummy_tokens.shape, "Output shape must match input shape!"
# Calculate parameter count
total_params = sum(p.numel() for p in kan_ffn.parameters() if p.requires_grad)
print(f"Total Trainable Parameters in KAN-FFN: {total_params:,}")
print("KAN Layer execution verified successfully!") Explanation of the Implementation
compute_b_splines: Vectorizes Cox-de Boor recursion across PyTorch tensors. Rather than computing basis curves one token at a time, it evaluates the basis coefficients simultaneously across all input features using broadcast arithmetic.torch.einsum("bik,jik->bj", ...): Contracts the evaluated basis tensor with the learnable 3D coefficient tensor, calculating the spline activation for all input-output edge pairs in a single parallel operation.KolmogorovArnoldFFN: Packages the non-linear KAN expansion with normalization and linear down-projection, allowing seamless drop-in replacement inside transformer blocks without modifying self-attention mechanisms or residual topologies.
Empirical Benchmarks: KAN vs. Modern Dense MLPs
Across academic evaluations and systems benchmarks—spanning the original MIT KAN studies, KAN 2.0 scientific benchmarks, and Kolmogorov-Arnold Transformer (KAT) evaluations—KANs display distinct scaling characteristics compared to standard Multi-Layer Perceptrons:
| Benchmark / Evaluation Metric | Traditional MLP (SwiGLU / GeLU) | Vanilla B-Spline KAN | Fast-KAN / ChebyKAN (KAT) | Architectural Rationale |
|---|---|---|---|---|
| Neural Scaling Exponent ($\alpha$) | $\alpha \approx 1.0 - 2.0$ ($\mathcal{O}(N^{-1})$) | $\alpha \approx 4.0$ ($\mathcal{O}(N^{-4})$) | $\alpha \approx 3.5$ ($\mathcal{O}(N^{-3.5})$) | KAN’s univariate decomposition escapes the curse of dimensionality on smooth functions. |
| Parameter Efficiency on Math Tasks | Baseline (100% params) | 50% - 60% fewer params | 45% - 55% fewer params | Non-linear edges capture complex curvatures without requiring wide hidden layers. |
| Continual Learning Memory Retention | 24% - 38% accuracy retention | 88% - 94% retention | 78% - 86% retention | B-splines have compact local support; new tasks do not alter historical knot coefficients. |
| Symbolic Discovery Capability | Impossible (Black-Box weights) | Exact closed-form extraction | Polynomial approximation | Edge pruning and symbolic snapping uncover explicit equations ($f = x_1 x_2 + \sin(x_3)$). |
| GPU Kernel Arithmetic Intensity | 100% Tensor Core saturated | ~20% - 30% (Sequential knots) | 80% - 88% (Dense GEMM) | Fast-KAN and ChebyKAN reformulate polynomial evaluation into standard matrix multiplies. |
| High-Resolution Grid Adaptation | Requires retraining from scratch | Lossless grid extension | Lossless grid extension | Increasing spline knots interpolates existing weights with zero accuracy degradation. |
Neural Scaling Laws on Scientific Data
The most striking theoretical result documented in the original KAN paper is the scaling law comparison. For a standard 2-layer MLP fitting a special mathematical function (such as Bessel functions or relativistic kinematics), the test root-mean-square error (RMSE) scales with parameter count $N$ as $\text{RMSE} \sim N^{-1}$.
In contrast, a 2-layer KAN achieves a scaling exponent of $\text{RMSE} \sim N^{-4}$. This means that scaling a KAN by an order of magnitude in parameters reduces test error by four orders of magnitude, whereas an MLP requires four orders of magnitude more parameters to achieve a comparable reduction.
Enterprise Production Playbook & aiFetchly Integration
To deploy Kolmogorov-Arnold Networks effectively within production enterprise workflows—such as automated data extraction, continuous machine learning pipelines, and autonomous research agents powered by aiFetchly—engineering teams should follow this systematic production playbook.
1. Workload Categorization: When to Choose KAN vs. MLP
Decision Matrix for Selecting KAN vs. Standard MLP Architectures:
┌────────────────────────────────────────────────────────┐
│ Choose Kolmogorov-Arnold Networks (KAN / KAT) When: │
│ • Numerical & Scientific Workloads: │
│ Tabular data, physical simulations, PDE solving, │
│ and quantitative financial modeling. │
│ • Continual / Online Learning: │
│ Models deployed in live streaming pipelines that │
│ ingest continuous new data without retraining. │
│ • High-Auditing & Regulated Domains: │
│ Compliance verification, clinical decision trees, │
│ and explainable AI requiring symbolic verification. │
│ • Edge & IoT Constrained Footprints: │
│ Target devices where minimizing parameter count and │
│ VRAM footprint is more critical than raw FLOP speed. │
└────────────────────────────────────────────────────────┘
▲
│ Evaluate Core Deployment Constraints
▼
┌────────────────────────────────────────────────────────┐
│ Choose Traditional MLPs (SwiGLU / GeGLU) When: │
│ • Giant Pre-Training Clusters: │
│ Massive 70B+ LLM pretraining where maximizing peak │
│ Tensor Core MFU across thousands of GPUs dominates. │
│ • Highly Discrete Lexical Workloads: │
│ Standard language modeling dominated by token │
│ embeddings and coarse syntax lookups. │
│ • Maximum Inference Throughput on Standard Engines: │
│ Deploying on off-the-shelf runtimes (vLLM, TensorRT) │
│ without custom Triton or CUDA kernel compilation. │
└────────────────────────────────────────────────────────┘ 2. High-Speed Web Data Scraping & Regression Verification
In automated data harvesting engines, scrapers often encounter unstructured numerical reports: quarterly SEC disclosures, supply chain pricing sheets, and real-time commodity indices. When agents parse tables using automated web scraping, extracted figures must often be cross-validated against non-linear accounting formulas or physical conservation laws.
By training lightweight KAN layers on extracted numerical fields:
- The KAN model learns the non-linear relationship between reported variables (e.g., Gross Margins, Operating Cash Flow, Depreciation).
- The agent executes edge pruning and symbolic snapping to automatically discover the underlying accounting equation used by the target firm.
- If future web extractions violate this discovered equation, the agent immediately flags anomalous data, preventing corrupt records from polluting enterprise data warehouses.
3. Continual Schema Adaptation Without Catastrophic Forgetting
Enterprise web crawlers and API extraction daemons frequently encounter schema drift—websites update their DOM layout, modify pricing tiers, or adjust reporting formats.
When updating agent models to recognize new HTML structures:
- A standard transformer fine-tuned on new website layouts suffers from representation drift, degrading its accuracy on previously mastered sites.
- A Kolmogorov-Arnold Transformer (KAT) localizes parameter adjustments to the specific B-spline intervals triggered by the new layout tokens. Historical token activations remain pinned to their existing knot coefficients, providing robust zero-forgetting performance.
For development teams evaluating enterprise automation pipelines, explore our transparent pricing tiers or review our comprehensive technical API documentation to integrate intelligent agent models into production.
Frequently Asked Questions (FAQ)
What is the primary difference between a KAN and an MLP?
The fundamental difference lies in where learnable non-linear operations occur. In a traditional Multi-Layer Perceptron (MLP), activation functions (such as ReLU, GELU, or SiLU) are fixed and placed at the nodes (neurons), while network edges compute simple linear matrix multiplications ($W \cdot x$). In a Kolmogorov-Arnold Network (KAN), nodes perform simple linear summation ($\sum$), while network edges compute learnable 1D univariate non-linear functions parameterized by localized B-splines or orthogonal polynomials.
How do Kolmogorov-Arnold Networks avoid catastrophic forgetting?
KANs utilize B-spline basis functions that have compact local support. Each B-spline basis function is non-zero only across a small number of adjacent knot intervals. When a KAN learns new information located in a specific numerical region, backpropagation updates only the local spline coefficients governing that specific interval. The parameters governing distant input regions receive zero gradients, preventing the network from overwriting historical knowledge.
What are Kolmogorov-Arnold Transformers (KAT)?
Kolmogorov-Arnold Transformers (KAT) are modern transformer architectures that replace traditional feed-forward network (FFN) blocks—such as SwiGLU or GeGLU—with KAN-based layers (typically Fast-KAN or ChebyKAN). Because KAN edges possess non-linear approximation capacity, KAT models achieve comparable or superior perplexity with up to 50% fewer FFN parameters.
Are KANs slower to train on GPUs than traditional MLPs?
Vanilla B-spline KANs can be significantly slower than MLPs on GPUs because evaluating recursive Cox-de Boor algorithms involves branching operations that do not map efficiently to hardware Tensor Cores. However, modern optimized variants like Fast-KAN (which uses Gaussian Radial Basis Functions) and ChebyKAN (which uses orthogonal Chebyshev polynomials) reformulate spline evaluations into standard dense matrix multiplications (GEMMs), achieving 70% to 90% of standard MLP training speeds while retaining KAN’s superior parameter efficiency.