Hard-Constrained Bernstein Memory Head
Implementation & benchmark of arXiv:2607.11110 — Neural Discovery of Memory and Nonlocal Kernels in Integro-Differential Equations with Constrained Kolmogorov--Arnold Networks
Source paper: Neural Discovery of Memory and Nonlocal Kernels in Integro-Differential Equations with Constrained Kolmogorov--Arnold Networks arXiv:2607.11110 ⓘ · analyzed Aug 30, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Add a causal memory branch whose lag-response function is represented by a Bernstein polynomial with coefficients constrained to produce a nonnegative, decreasing, convex kernel. The branch aggregates past hidden states using this kernel, giving the model a learnable long-memory profile while preventing oscillatory, negative, or increasing historical influence.
Formulas
Mathematical statement
The paper formulates an integro-differential operator containing a causal memory kernel, $K(t-s,\mathbf{x}-\mathbf{y})$, through $\int_0^t\int_{\Omega}K(t-s,\mathbf{x}-\mathbf{y})\mathcal{F}[u](s,\mathbf{y})\,d\mathbf{y}\,ds$. Here $t$ is the current time, $s$ is a past time, $\mathbf{x},\mathbf{y}\in\Omega$ are spatial locations, $u$ is the observed field, $\mathcal{F}[u]$ is the quantity filtered by the kernel, and $K$ is the unknown causal kernel. The MC-KAN construction described in the paper uses a Bernstein polynomial $k(z)=\sum_{j=0}^{m}c_j B_{j,m}(z)$ on $z\in[0,1]$, where $B_{j,m}(z)=\binom{m}{j}z^j(1-z)^{m-j}$, $m$ is the polynomial degree, and $c_j$ are trainable coefficients. Because Bernstein basis functions are nonnegative and sum to one, $c_j\geq 0$ implies $k(z)\geq0$; $c_j\geq c_{j+1}$ implies monotone decrease; and $c_j-2c_{j+1}+c_{j+2}\geq0$ implies convexity. These conditions follow from the Bernstein derivative identities $k'(z)=m\sum_{j=0}^{m-1}(c_{j+1}-c_j)B_{j,m-1}(z)$ and $k''(z)=m(m-1)\sum_{j=0}^{m-2}(c_j-2c_{j+1}+c_{j+2})B_{j,m-2}(z)$. For a neural sequence model, $z_r=\min(r\Delta/\tau,1)$ is the normalized lag for lag index $r$, timestep $\Delta$, and memory horizon $\tau$; the memory output is $m_t=\sum_{r=1}^{L}k(z_r)v_{t-r}$, where $v_{t-r}\in\mathbb{R}^d$ is a past value vector and $L$ is the retained context length.
Implementation notes
(1) Integration point: insert the module after the value projection in each Transformer block, or beside the state update in an SSM. For hidden states $h_{1:T}\in\mathbb{R}^{T\times d}$, compute values $v_t=W_vh_t$, construct the causal memory vector $m_t$, and add it through a learned projection and scalar gate as $h_t^{\mathrm{out}}=h_t+gW_mm_t$. Start with one shared kernel per layer; optionally use one kernel per attention head.
(2) Pseudocode:
input h[1:T]
v = h @ Wv
raw = softplus(theta[m+1])
q = raw
for j = m-1 down to 0:
d[j] = sum(q[j:m])
c[m] = softplus(a)
for j = m-1 down to 0:
c[j] = c[j+1] + d[j]
for z in lag_grid:
k[z] = sum_j c[j] * binom(m,j) * z**j * (1-z)**(m-j)
w = k(lag_grid) / (sum(k(lag_grid)) + eps)
for t in 1..T:
memory[t] = sum_{r=1}^{min(L,t-1)} w[r] * v[t-r]
out = h + sigmoid(g) * (memory @ Wm)
The nested cumulative sums enforce positivity, monotone decrease, and convexity without penalty losses. Use torch.flip and cumulative sums to vectorize coefficient construction, and use a causal depthwise convolution or FFT convolution for long contexts.
(3) Computed from the paper's mathematics: the Bernstein basis, coefficient-difference constraints, and the causal kernel convolution. Estimated empirically: the degree $m$, memory horizon $\tau$, gate $g$, projection matrices, and whether one shared kernel or per-head kernels are preferable. If $\tau$ is learned, parameterize it as softplus(tau_raw) and clip it to a practical range. Monitor the discrete first differences $k_r-k_{r+1}$ and second differences $k_r-2k_{r+1}+k_{r+2}$ to verify the implementation.
(4) First cheap experiment: train a 4-layer, 8-head Transformer on synthetic autoregressive sequences generated by a known mixture of exponential and power-law memory, with random input corruption and only 10-20% observed training tokens. Compare the constrained head against standard attention, an unconstrained learned depthwise lag convolution with the same number of parameters, and a single exponential kernel. Evaluate validation MSE, stability on sequences 4x longer than training, and sensitivity to noise. Success is lower extrapolation error and fewer exploding or oscillating runs at equal FLOPs, while the learned kernel shape remains stable across random seeds.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Not reproduced ✗
Stage 2 · Practical benchmark result: No measurable effect
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 9/10
Built a hard-constrained Bernstein memory kernel with coefficients parameterized to enforce positivity, monotone decrease, and convexity, plus normalized causal lag aggregation. All three mechanism predictions were confirmed: zero shape violations across 100 random parameterizations, first- and second-difference margins scaled with observed slope 1.0000000000000007 versus predicted 1.0, and the saturation lag exactly matched ceil(tau/dt) for all five tested horizons. In the small regression test, the constrained model achieved MSE 0.03887 versus 0.04552 for an unconstrained ridge lag model, but this comparison is favorable partly because the constrained model uses only 7 parameters versus 32 and does not establish a Transformer-level win.
- Agent confidence
- 9/10
- Baseline
- Unconstrained 32-lag ridge: validation MSE 0.0455218983
- Idea
- Hard-constrained degree-6 Bernstein kernel: validation MSE 0.0388737258; improvement -0.0066481726. Mechanism checks: max shape violation 0, margin slopes 1.0000000000000007, horizon plateau predictions 5/5 exact.
Limitations: Did not test a Transformer or SSM, long-sequence extrapolation, multiple random training seeds, equal-parameter baseline, learned tau, or FLOP-normalized training. The toy comparison uses a fixed horizon and a linear regression task; CUDA was used for the constrained fit.
How to run: python3 experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.11110)
Ahead of the baseline (−0.8%) but not statistically significant (p=0.556, wins 6 / 8 paired seeds).
- Benchmark
- Sequence modeling
- Model
- transformer_tiny
- Paired seeds
- 8
- Baseline mean
- 0.3444
- Idea mean
- 0.3415
- Effect (Δ)
- -0.0029 (−0.8%; negative = idea better)
- Wins
- 6 / 8 paired seeds
- p-value
- 0.556 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±3.2%
- Mechanism
- Not confirmed ✗
- Practical effect
- No effect
- Baseline tuning
- swept over 3 configs
Only the built-in sequence forecast track was tested. Long-context extrapolation, alternative sequence datasets, FLOP or speed comparison, and per-head kernels were not evaluated. The experiment used 20 epochs, a three-value tau sweep, four-seed configuration selection, and eight paired final seeds.
How to run: python3 stage2_bernstein_bench.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 9/10
Implemented a hard-constrained Bernstein causal memory branch in a parity-matched tiny Transformer and evaluated it on the structurally appropriate sequence track. The trained kernel was nonnegative, decreasing, and convex, but the task improvement was not statistically significant: idea MSE 0.34153 versus baseline 0.34445, paired delta -0.00291, permutation p=0.55595. The mechanism worked as designed, but the benchmark did not establish a reliable neural-network win.
- Baseline
- Best swept lr=0.0015, 20 epochs; 8-seed test MSE 0.3444453143
- Idea
- Best tau=20.0, lr=0.0015, 20 epochs; 8-seed test MSE 0.3415325731; paired delta -0.0029127412; p=0.55595; 6/8 seed wins
- Mechanism signature
- Trained-model kernel minimum 0.6814163, maximum increase 0, minimum second difference 0; confirmed=true
Benchmark result
Ahead of the baseline (−0.8%) but not statistically significant (p=0.556, wins 6 / 8 paired seeds).
- Benchmark
- Sequence modeling
- Model
- transformer_tiny
- Paired seeds
- 8
- Baseline mean
- 0.3444
- Idea mean
- 0.3415
- Effect (Δ)
- -0.0029 (−0.8%; negative = idea better)
- Wins
- 6 / 8 paired seeds
- p-value
- 0.556 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±3.2%
- Mechanism
- Not confirmed ✗
- Practical effect
- No effect
- Baseline tuning
- swept over 3 configs
Only the built-in sequence forecast track was tested. Long-context extrapolation, alternative sequence datasets, FLOP or speed comparison, and per-head kernels were not evaluated. The experiment used 20 epochs, a three-value tau sweep, four-seed configuration selection, and eight paired final seeds.
How to run: python3 stage2_bernstein_bench.py
Artifacts
- bench_report.json 3.6 KB View Raw
- experiment.py 6.6 KB View Raw
- report.md 1.6 KB View
- report_bench_2026-08-31T004750.md 4.0 KB View
- results.json 2.0 KB View Raw
- stage2_bernstein_bench.py 5.7 KB View Raw