Compile Once, Differentiate Everywhere ✛

Original: "Compile Once, Differentiate Everywhere: A Differentiable Meta-Circular Interpreter"
· Lucas Sheneman
arXiv:2606.09930 · 2026-06-07 · CC BY 4.0 · 1 min
A Scheme interpreter compiled into a differentiable graph lets you optimize any program as data.

The interpreter learns from every word. It sits in the conference room and translates. But instead of just translating, it remembers which phrases caused confusion and changes them. An hour later, its translation is more accurate. The same idea applies here: a Scheme interpreter, compiled once, can execute any program passed to it as data, and simultaneously compute gradients to improve those programs.

Previously, every scientific model had to be manually rewritten in a differentiable form to apply gradient optimization. That's like needing to hire a new interpreter for every new text. Now, the interpreter itself becomes trainable: it doesn't just translate, but also understands how to change the text to make it better. The authors built a compiler that translates Scheme source code into an intermediate representation called ComputeGraph, and then into PyTorch or JAX modules. The key feature is that the interpreter itself becomes differentiable, not individual programs.

The Scheme interpreter, written in Scheme itself, takes only 288 lines of code. It supports closures, recursion, lists, and tail calls, enough for self-application.

The interpreter now doesn't just translate; it learns from every word. It can automatically calibrate parameters of models generated by language models in scientific and engineering tasks. This is like having an interpreter who, given a draft from a writer, polishes it to perfection without requiring a rewrite from scratch.

The Scheme interpreter written in Scheme itself is only 288 lines of code. Yet it supports closures, recursion, lists, and tail calls, sufficient for self-application.

The idea of a program that can modify and improve itself through gradients echoes the concept of Gödel machines by Jürgen Schmidhuber, described in his work on universal self-improvement.

\frac{\|\nabla_{\theta} L_{\text{DMCI}} - \nabla_{\theta} L_{\text{direct}}\|_2}{\|\nabla_{\theta} L_{\text{direct}}\|_2} \approx 0
The relative gradient error is close to zero, confirming correctness.
\text{throughput speedup} = \frac{\text{time sequential}}{\text{time batched}}
Ratio of sequential execution time to batched time.
L(\theta) = \ell(\pi(\text{eval}(P(\theta), x)))
The loss is computed as a differentiable function of the interpreter's output.
Scientists
Niels BohrPascual JordanWerner HeisenbergJoseph Fourier
Concepts
classifier autoencoder decoder neural network data reconstruction ai self correction independent component analysis Explainable AI computation generative model brain computer interface xgboost deep neural network parallel processing differential form dimensionality reduction Natural Language Processing model selection cross validation support vector machine sigma clipping