Real-Time Dynamics in Two Dimensions with Tensor Network States via Time-Dependent Variational Monte Carlo Method¶
Partial Yantao Wu, Jannes Nys · arXiv:2512.06768 · Code
Figure 2(a,b) · 6×6 PEPS versus exact densities. The exact and variational densities after a corner quench on a six-by-six Hofstadter lattice.
Figure 2(a,b) protocol at 6×6
Data: summary.npz (Density, infidelity, jackknife errors, and effective sample sizes)
Setup¶
At two-thirds filling and flux 2π/3, a PEPS prepared by imaginary-time VMC evolves with centered SR and RK4 after the corner potential is removed. Independent Gaussian Born proposals are reweighted by PEPS amplitudes to estimate densities.
Agreement and simplifications¶
The benchmark uses 6×6 open sites, 24 fermions, D=4, exact single-layer contractions and snapshots at t=0, 2, 4, and 8. The paper uses a 12×12 lattice, approximate boundary-MPS contractions, and evolves to t=12. The 6×6 lattice spans two magnetic unit cells and tests density agreement after a corner quench. The paper's edge propagation, four-site time series and entanglement panels remain outside this benchmark. The migration uses RK4 with step 0.2 and 10,240 exchange-Metropolis samples per stage. The paper uses RK4 with step 0.01 and 40,960 sequential samples, and its parameter-space solve projects out gauge directions. The migration uses a shifted full parameter-space solve during real-time evolution. At t=8 the migrated run has a density RMSE of 0.001041 versus the exact solution, exceeding the upstream target of 0.001.
Paper scale¶
Figure 2 of the paper evolves a 12×12 lattice at D=4 to t=12 with RK4 step 0.01 (1,200 steps), 40,960 samples, about 28k parameters, and boundary-MPS contraction at D'=16; the paper reports 399 s per step on one 141 GB GPU, about 5.5 GPU-days. This design does not reach that scale. The bound below is analytical, from the path search and nominal throughput, not a measured run. The cached exact path at 12×12, D=4 costs about 4×10¹² operations per amplitude, with a largest intermediate of 2.7×10⁸ entries (4 GiB in complex128). At 96 fermions, each sample and RK stage contracts 193 amplitudes for the local energy (192 connected configurations and the base) and 145 for the exchange sweep. At 40,960 samples, four stages, and the paper's 34 TFLOPS FP64, one step needs at least about 80 GPU-days. The energy batch over connected configurations would hold about 770 GiB of intermediates per sample unless chunked. The dense score matrix would take about 17 GiB and the metric about 12 GiB. Reaching the paper needs boundary-MPS amplitudes (#11) and streamed SR moments (#9).
Scales¶
| Scale | Device | Runtime | Memory |
|---|---|---|---|
test |
cpu | 9 s | 620 MiB peak RSS |
default |
gpu | 2 h 44 min | 8.7 GiB sampled device peak |
python reproductions/2026_peps_tvmc_chern_edge/main.py # default scale, writes outputs/
python reproductions/2026_peps_tvmc_chern_edge/main.py --scale test --out /tmp/out
Components and features¶
- Components:
tencirlab.fermion,tencirlab.peps,tencirlab.vmc - Upstream features: Fermionic Gaussian State (
tc.FGSSimulator) - Topics: Topological Phase, Many-Body Physics, Tensor Network
- Migrated from: tensorcircuit/tensorcircuit-ng#134 (77f02116fc8d96c8eb433b26c6505a3edcc7a69d)
- Contributors: QingyunQian
Details¶
Figure 2(a,b) of Wu and Nys compares exact and fermionic PEPS densities after releasing a corner potential on an open Hofstadter lattice. This migration of TensorCircuit-NG PR #134 uses the same reduced benchmark as that PR, with 24 fermions on a 6×6 lattice, D=4, and snapshots at t=0, 2, 4, 8. The paper uses 12×12 sites, boundary-MPS contraction, and evolves to t=12. The smaller lattice spans two magnetic unit cells and serves as an exact-density benchmark after the quench. Paper · Migration source
Run¶
PYTHONPATH=. python reproductions/2026_peps_tvmc_chern_edge/main.py
PYTHONPATH=. python reproductions/2026_peps_tvmc_chern_edge/main.py --scale test --out /tmp/peps-test
python reproductions/2026_peps_tvmc_chern_edge/verify.py
The default writes outputs/result.png and outputs/summary.npz relative to the script. Use --seed to select the root key for initialization, bond enlargement, training chains, and independent measurement frames. Pass --output to verify.py to check another numerical summary and --upstream to compare to the archived upstream summary.
Protocol¶
- Order sites by
i = yL_x + x, withyincreasing upward. Vertical hopping has Peierls phaseexp(−2πix/3). The initial attractive potential at the upper-left site has strength −1 and is removed att=0. - Start from a random
D=2fermionic PEPS and perform 100 imaginary-time Euler steps. Embed it atD=4, add noise to activate new entries, and perform 100 coarse and 60 refinement steps. All preparation steps have size 0.05. Evolve the preparedD=4PEPS through 40 real-time RK4 steps of size 0.2, using 10,240 fixed-number chains and one exchange sweep per RK stage. - Use exact single-layer contractions along cached paths, complex128 arithmetic, and centered stochastic reconfiguration with a positive diagonal shift. TenCirPauli supplies the Jordan–Wigner mapping. In the migrated RK4 run, the time step is 0.2, each stage uses 10,240 Metropolis samples, and the full parameter-space metric has a diagonal shift of 10⁻⁵. The 12×12 paper run uses RK4 with step 0.01 and 40,960 samples, boundary-MPS contraction at contraction bond dimension 16, and sequential sampling. Its parameter-space method projects out the gauge directions and uses a Cholesky solve with a 10⁻⁸ regulator. Paper, Table I and gauge-fixing section
- TensorCircuit-NG supplies the independent exact Gaussian evolution. Each plotted PEPS frame uses 4,194,304 independent proposals from the evolved Slater determinant, reweighted by exactly contracted PEPS amplitudes. The Gaussian reference enters the density and overlap measurements after training. The saved estimates include 32-block jackknife errors and effective sample sizes.
- Both plot rows use the same fixed density-excess scale from 0 to 0.04. The arrays retain the signed excess through the raw densities and the separate unpinned ground-state background.
Results¶
The regenerated 6×6 run took 2 h 44 min on one GPU and used 8.7 GiB of sampled peak device memory. Exact densities agree with the upstream archive to within 2.3 × 10⁻¹⁵, and the density-excess peak sites agree between PEPS and exact results at all four times.
| Time | Density RMSE vs. exact | Upstream RMSE vs. exact | PEPS density RMSE vs. upstream PEPS |
|---|---|---|---|
| 0 | 0.000184 | 0.000234 | 0.000325 |
| 2 | 0.000250 | 0.000260 | 0.000285 |
| 4 | 0.000361 | 0.000376 | 0.000359 |
| 8 | 0.001041 | 0.000853 | 0.001051 |
The final frame exceeds the upstream RMSE target of 0.001 by 4.1 × 10⁻⁵. Its maximum site error is 0.002628 and its RMS jackknife standard error across sites is 0.000230. The two independently trained trajectories use different random streams. The verifier requires RMSE below 0.001 for the first three frames. For the last frame it reports the upstream target miss separately and requires RMSE below 0.0015, allowing a margin of roughly two RMS site measurement errors above the upstream target. It also checks exact evolution, particle number, peak locations, maximum site error, overlap and effective sample size.
Code¶
main.py
"""
Reproduction of "Real-Time Dynamics in Two Dimensions with Tensor Network States
via Time-Dependent Variational Monte Carlo Method"
Link: https://arxiv.org/abs/2512.06768
Description:
This script reproduces the corner-quench density comparison of Figure 2(a,b)
on a reduced lattice using TenCirLab components.
"""
import argparse
from pathlib import Path
from time import perf_counter
import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import numpy as np
import tencirpauli as tcp
import tensorcircuit as tc
from tencirlab.fermion import slater_amplitude, slater_sample
from tencirlab.peps import PEPS
from tencirlab import vmc
SCALES = {
"test": {
"shape": (2, 3),
"preparation": ((2, 48, 2, 1e-3), (4, 64, 2, 1e-3), (4, 64, 2, 1e-4)),
"frames": (0, 1),
"counts": 64,
"blocks": 4,
"batches_per_block": 2,
"measure_batch": 32,
"train_batch": 16,
"sample_batch": 16,
"warm_sweeps": 2,
"steps_per_chunk": 1,
},
"default": {
"shape": (6, 6),
"preparation": (
(2, 2048, 100, 1e-3),
(4, 4096, 100, 1e-3),
(4, 10240, 60, 1e-4),
),
"frames": (0, 10, 20, 40),
"counts": 10240,
"blocks": 32,
"batches_per_block": 128,
"measure_batch": 1024,
"train_batch": 64,
"sample_batch": 1024,
"warm_sweeps": 8,
"steps_per_chunk": 10,
},
}
def hofstadter(rows, columns):
matrix = np.zeros((rows * columns,) * 2, dtype=np.complex128)
for y in range(rows):
for x in range(columns):
site = y * columns + x
if x + 1 < columns:
matrix[site, site + 1] = -1
if y + 1 < rows:
matrix[site, site + columns] = -np.exp(-2j * np.pi * x / 3)
hopping = matrix + matrix.conj().T
pinned = hopping.copy()
corner = (rows - 1) * columns
pinned[corner, corner] = -1
return hopping, pinned
def occupation_operator(matrix):
terms = [
(((int(i), "create"), (int(j), "annihilate")), complex(matrix[i, j]))
for i, j in zip(*matrix.nonzero())
]
return vmc.pauli_local(
tcp.FermionOperator.from_terms(len(matrix), terms).map_fermions()
)
def reference(hopping, pinned, particles, time):
_, orbitals = jnp.linalg.eigh(pinned)
occupied, empty = orbitals[:, :particles], orbitals[:, particles:]
zero = jnp.zeros_like(hopping)
simulator = tc.FGSSimulator(
len(hopping),
alpha=jax.scipy.linalg.block_diag(empty, occupied.conj()),
)
simulator.evol_hamiltonian(time * jnp.block([[hopping, zero], [zero, -hopping.T]]))
return simulator.alpha[len(hopping) :, len(hopping) - particles :].conj()
def optimize(peps, theta, operator, particles, count, shift, dt, imaginary, key, scale):
batch_size = min(count, scale["train_batch"])
sample_batch_size = min(count, scale["sample_batch"])
rounds = scale["warm_sweeps"] * peps.nsites
start_key, key = jax.random.split(key)
order = jnp.argsort(jax.random.uniform(start_key, (count, peps.nsites)), axis=1)
initial = (order < particles).astype(jnp.int32)
equilibrate = jax.jit(
lambda p, s, k: vmc.exchange_metropolis(
peps.amplitude, p, s, k, rounds, sample_batch_size
)
)
states, _, key = equilibrate(theta, initial, key)
velocity = vmc.tvmc_velocity(
peps.amplitude,
operator,
1,
shift,
imaginary,
min(operator.flips.shape[0], 4 * min(particles, peps.nsites - particles)),
batch_size,
sample_batch_size,
)
chunk = scale["steps_per_chunk"]
solver = vmc.euler_step if imaginary else vmc.rk4_step
update = (
jax.jit(
lambda p, carry: vmc.integrate(
solver, velocity, p, carry, dt, chunk, peps.normalize
)
)
.lower(theta, (states, key))
.compile()
)
return update, (theta, (states, key))
def advance(update, state, start, stop, chunk, label):
began = perf_counter()
for step in range(start, stop, chunk):
theta, carry, info = update(*state)
energy = float(info[-1, 0].block_until_ready())
if not np.isfinite(energy):
raise FloatingPointError(
f"Nonfinite energy at {label}, step {step + chunk}"
)
state = (theta, carry)
print(
f"{label} {step + chunk}/{stop} "
f"E={energy:.8f} {perf_counter() - began:.1f}s",
flush=True,
)
return state
def measurement(peps, blocks, batches_per_block, batch_size):
def block(theta, orbitals, key):
def batch(total, batch_key):
states = jax.vmap(slater_sample, (None, 0))(
orbitals, jax.random.split(batch_key, batch_size)
)
trial = jax.vmap(peps.amplitude, (None, 0))(theta, states)
proposal = jax.vmap(slater_amplitude, (None, 0))(orbitals, states)
return total + vmc.overlap_block(trial / proposal, states), None
zero = jnp.zeros(4 + peps.nsites, dtype=theta.dtype)
return jax.lax.scan(batch, zero, jax.random.split(key, batches_per_block))[0]
block = jax.jit(block)
def measure(theta, orbitals, key):
sums = [
np.asarray(block(theta, orbitals, k)) for k in jax.random.split(key, blocks)
]
return vmc.overlap_estimate(np.stack(sums))
return measure
def simulate(scale, seed):
rows, columns = scale["shape"]
hopping, pinned = hofstadter(rows, columns)
particles = 2 * len(hopping) // 3
plan = scale["preparation"]
models = {d: PEPS(rows, columns, d) for d in sorted({p[0] for p in plan})}
peps = models[plan[0][0]]
init_key, bond_key, train_key, evolve_key, measure_key = jax.random.split(
jax.random.key(seed), 5
)
theta = peps.random_parameters(init_key)
pinned_operator = occupation_operator(pinned)
chunk = scale["steps_per_chunk"]
train_keys = jax.random.split(train_key, len(plan))
for (d, count, steps, shift), key in zip(plan, train_keys):
model = models[d]
if model is not peps:
theta = model.normalize(
model.embed(theta, peps) + 0.05 * model.random_parameters(bond_key)
)
peps = model
update, state = optimize(
peps,
theta,
pinned_operator,
particles,
count,
shift,
0.05,
True,
key,
scale,
)
theta, _ = advance(update, state, 0, steps, chunk, f"prepare D={d}, N={count}")
dt = 0.2
update, state = optimize(
peps,
theta,
occupation_operator(hopping),
particles,
scale["counts"],
1e-5,
dt,
False,
evolve_key,
scale,
)
times, exact, estimates = [], [], []
measure = measurement(
peps, scale["blocks"], scale["batches_per_block"], scale["measure_batch"]
)
keys = jax.random.split(measure_key, len(scale["frames"]))
start = 0
for stop, key in zip(scale["frames"], keys):
state = advance(update, state, start, stop, chunk, "evolve")
start = stop
time = stop * dt
orbitals = reference(hopping, pinned, particles, time)
density = np.asarray(jnp.sum(jnp.abs(orbitals) ** 2, axis=1))
estimate = measure(state[0], orbitals, key)
rmse = np.sqrt(np.mean((estimate["observables"] - density) ** 2))
print(
f"t={time:g} density RMSE={rmse:.6g} "
f"infidelity={estimate['infidelity']:.6g}",
flush=True,
)
times.append(time)
exact.append(density)
estimates.append(estimate)
background = np.sum(np.abs(np.linalg.eigh(hopping)[1][:, :particles]) ** 2, axis=1)
return {
"shape": scale["shape"],
"seed": seed,
"particles": particles,
"times": times,
"background": background,
"exact_density": exact,
"density": [e["observables"] for e in estimates],
"density_stderr": [e["observables_error"] for e in estimates],
"infidelity": [e["infidelity"] for e in estimates],
"infidelity_stderr": [e["infidelity_error"] for e in estimates],
"effective_samples": [e["effective_samples"] for e in estimates],
"measurement_samples": scale["blocks"]
* scale["batches_per_block"]
* scale["measure_batch"],
}
def plot(summary, output):
rows, columns = summary["shape"]
times = summary["times"]
fig, axes = plt.subplots(
2, len(times), figsize=(2 * len(times) + 1, 4), layout="constrained"
)
background = summary["background"]
for row, field in zip(axes, ("exact_density", "density")):
for ax, frame in zip(row, summary[field]):
image = ax.imshow(
(frame - background).reshape(rows, columns),
origin="lower",
cmap="magma",
vmin=0,
vmax=0.04,
interpolation="nearest",
)
ax.set(xticks=[], yticks=[])
for ax, time in zip(axes[0], times):
ax.set_title(f"$t={time:g}$")
axes[0, 0].set_ylabel("Exact (FGS)")
axes[1, 0].set_ylabel("PEPS–tVMC")
fig.colorbar(image, ax=axes, label="Density excess", extend="both")
fig.savefig(output, dpi=160)
plt.close(fig)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--scale", choices=SCALES, default="default")
parser.add_argument("--out", type=Path)
parser.add_argument("--seed", type=int, default=17)
args = parser.parse_args()
default_dir = "outputs" if args.scale == "default" else "test_output"
out = args.out or Path(__file__).resolve().parent / default_dir
out.mkdir(parents=True, exist_ok=True)
tc.set_backend("jax")
tc.set_dtype("complex128")
jax.config.update("jax_enable_x64", True)
started = perf_counter()
summary = simulate(SCALES[args.scale], args.seed)
np.savez_compressed(out / "summary.npz", **summary)
plot(summary, out / "result.png")
print(f"Total: {perf_counter() - started:.1f}s", flush=True)
if __name__ == "__main__":
main()
verify.py
"""Validate saved densities against an independent exact quench calculation."""
import argparse
from pathlib import Path
import numpy as np
from scipy.linalg import expm
def exact_densities(rows, columns, particles, times):
adjacency = np.eye(columns, k=1) + np.eye(columns, k=-1)
phase = np.diag(np.exp(-2j * np.pi / 3 * np.arange(columns)))
vertical = np.kron(np.eye(rows, k=1), phase)
hopping = -np.kron(np.eye(rows), adjacency) - vertical - vertical.conj().T
pinned = hopping.copy()
pinned[-columns, -columns] -= 1
ground = np.linalg.eigh(hopping)[1][:, :particles]
initial = np.linalg.eigh(pinned)[1][:, :particles]
background = (np.abs(ground) ** 2).sum(axis=1)
frames = [
(np.abs(expm(-1j * time * hopping) @ initial) ** 2).sum(axis=1)
for time in times
]
return background, frames
def report(output, upstream):
with np.load(output) as archive:
data = dict(archive.items())
check_summary(data, upstream)
def check_summary(data, upstream):
rows, columns = data["shape"]
particles = data["particles"]
background, exact = exact_densities(rows, columns, particles, data["times"])
np.testing.assert_allclose(data["background"], background, atol=2e-12)
np.testing.assert_allclose(data["exact_density"], exact, atol=2e-12)
np.testing.assert_allclose(data["density"].sum(axis=1), particles, atol=2e-11)
density = data["density"]
stderr = data["density_stderr"]
assert np.all((0 <= density) & (density <= 1))
assert np.all(np.isfinite(stderr) & (stderr > 0))
assert np.all(np.isfinite(data["infidelity"]))
assert np.all(data["effective_samples"] > 1)
assert np.all(data["effective_samples"] <= data["measurement_samples"])
if upstream:
with np.load(upstream) as archived:
for name in ("times", "background", "exact_density"):
np.testing.assert_allclose(data[name], archived[name], atol=2e-12)
delta = np.sqrt(np.mean((density - archived["density"]) ** 2, axis=1))
print("PEPS density RMSE versus upstream:", delta)
error = data["density"] - data["exact_density"]
rmse = np.sqrt(np.mean(error**2, axis=1))
maximum = np.max(np.abs(error), axis=1)
print("PEPS density RMSE versus exact:", rmse)
print("Maximum site error:", maximum)
print("Infidelity:", data["infidelity"])
print(
"Effective sample fraction:",
data["effective_samples"] / data["measurement_samples"],
)
if (rows, columns) == (6, 6):
np.testing.assert_array_equal(data["times"], [0, 2, 4, 8])
np.testing.assert_array_equal(
np.argmax(density - background, axis=1),
np.argmax(np.asarray(exact) - background, axis=1),
)
print("Frames reaching or exceeding the upstream RMSE target of 0.001:")
print(data["times"][rmse >= 0.001])
# The final frame has a separate regression bound documented in the README.
np.testing.assert_array_less(rmse, [0.001, 0.001, 0.001, 0.0015])
np.testing.assert_array_less(maximum, 0.003)
np.testing.assert_array_less(
data["infidelity"] + 3 * data["infidelity_stderr"], 0.003
)
assert np.all(data["effective_samples"] > data["measurement_samples"] / 2)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--output",
type=Path,
default=Path(__file__).resolve().parent / "outputs" / "summary.npz",
)
parser.add_argument("--upstream", type=Path)
args = parser.parse_args()
report(args.output, args.upstream)
if __name__ == "__main__":
main()
History¶
| Date | Pull request | Kind | Change |
|---|---|---|---|
| 2026-12-02 | #12 | docs | Design reproductions for the paper's scale |
| 2026-12-01 | #10 | migration | Fermionic PEPS–tVMC corner quench |