Differentiable Quantum Field Theory on Anti-de Sitter spacetime.
DiffQFT implements holographic computations in Euclidean AdS₂ with full automatic differentiation through PyTorch. It computes Witten diagram integrals, bulk propagators, and correlation functions for the Sine-Gordon theory, and supports training neural surrogates that approximate expensive Monte Carlo integrations at a fraction of the cost.
Live Demo — interactive Poincaré half-plane visualization, runs entirely in the browser.
In the AdS/CFT correspondence, bulk physics in Anti-de Sitter space maps to a conformal field theory on the boundary. The central objects are Witten diagrams — Feynman diagrams evaluated in curved spacetime:
I_Δ = ∫ d²X √g · K_Δ(X; p₁) · K_Δ(X; p₂)
where K_Δ is the bulk-to-boundary propagator and √g = (L/z)² is the
volume element of the Poincaré half-plane. The scaling dimension
Δ = ½ + √(¼ + m²L²) determines how operators on the boundary couple to
bulk fields of mass m.
DiffQFT evaluates these integrals numerically via Monte Carlo sampling, wraps
everything in PyTorch's autograd, and trains neural networks to learn the
mapping distance → integral value so future evaluations are near-instant.
diffqft/
geometry.py Poincaré half-plane metric, chordal distance, kernels
propagators.py Bulk propagator via differentiable ₂F₁ (scipy + autograd)
fields.py Sine-Gordon theory, Witten diagram MC integration
neural.py MLP surrogate model and training loop
pinn.py Physics-informed neural net for Klein-Gordon equation
data.py CSV-backed simulation store for active learning
app/
api.py FastAPI backend with msgpack binary protocol
frontend.py Streamlit interactive workbench
examples/ Standalone scripts demonstrating the main workflows
tests/ pytest suite covering geometry, propagators, and fields
docs/ GitHub Pages interactive demo (pure JS, no backend)
macOS / Linux:
git clone https://github.com/erik2810/DiffQFT.git
cd DiffQFT
bash scripts/setup.sh
source .venv/bin/activateWindows:
git clone https://github.com/erik2810/DiffQFT.git
cd DiffQFT
scripts\setup.bat
.venv\Scripts\activate.batManual install:
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"Run the main example — computes the free two-point correlator and a first-order Witten diagram correction via Monte Carlo:
python examples/sine_gordon_ads.pyExpected output:
Setup: L=1.0, m=1.0, Delta=1.6180
Free correlator (analytic): 0.012095
Monte Carlo integration (eps=0.001)...
I_Delta (numeric): 0.1836xx
Train a neural surrogate that replaces the MC integration:
python examples/train_surrogate.pyRecover hidden coupling constants from synthetic boundary data:
python examples/inverse_discovery.pyThe REST API supports both JSON and msgpack binary protocol
(set Content-Type: application/x-msgpack):
uvicorn app.api:app --reload# JSON
curl -X POST http://localhost:8000/api/simulate/2pt \
-H "Content-Type: application/json" \
-d '{"p1": -2.0, "p2": 2.0, "samples": 50000}'# msgpack (Python)
import msgpack, httpx
data = msgpack.packb({"p1": -2.0, "p2": 2.0, "samples": 50000})
resp = httpx.post(
"http://localhost:8000/api/simulate/2pt",
content=data,
headers={
"Content-Type": "application/x-msgpack",
"Accept": "application/x-msgpack",
},
)
result = msgpack.unpackb(resp.content)streamlit run app/frontend.pypytest tests/ -vThe propagator G_Δ(X, X') is computed exactly using the hypergeometric
function ₂F₁, wrapped in a custom torch.autograd.Function so gradients
flow through it. This lets you do things like optimize coupling constants
via gradient descent on the mismatch between predicted and observed
correlation functions (see examples/inverse_discovery.py).
The physics-informed neural network (PINN) in diffqft/pinn.py learns to
solve the Klein-Gordon equation (z²/L²)(∂²_z + ∂²_x)φ − m²φ = 0
directly, without any training data — just the PDE residual as a loss
function, anchored by boundary conditions.
The implementation follows the formalism developed in a master's thesis on AdS/CFT holography, specifically:
- Chordal distance and geodesics (Eq. 2.17–2.18)
- Bulk-to-bulk propagator via ₂F₁ (Eq. 3.24–3.26)
- Scaling dimension from mass (Eq. 2.66, 3.12–3.14)
- Witten diagram integrals for Sine-Gordon theory (Eq. 4.47)
- Anomalous dimension extraction (Eq. 4.49)
MIT