Symplectic Recurrent Block
Implementation & benchmark of arXiv:2607.09549 — Backward error analysis for matrix discretizations of 2-D Euler equations
Source paper: Backward error analysis for matrix discretizations of 2-D Euler equations arXiv:2607.09549 ⓘ · analyzed Aug 30, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Use a symplectic Hamiltonian update as a recurrent or state-space neural block, preserving a learned modified energy across many layers or time steps. This targets residual and recurrent architectures where ordinary Euler updates accumulate drift during long rollouts.
Formulas
Mathematical statement
For a phase-space state $y=(q,p)$, the paper's canonical Hamiltonian dynamics are $\dot y=J^{-1}\nabla H(y)$ with $J=\begin{bmatrix}0&-I\\I&0\end{bmatrix}$. A symplectic discretization is represented by backward error analysis as the exact flow of a modified vector field, $\Phi_h(y)=y+B_f(a)(y)=y+B_{\tilde f_h}(1/\gamma)(y)$, and for Hamiltonian systems $\tilde f_h=J^{-1}\nabla\tilde H_h$. Here $q,p$ are hidden-state position and momentum, $H_\phi$ is a learned scalar Hamiltonian, $h$ is the layer step, and $\phi$ are trainable weights. The transferable property is preservation of a nearby invariant over long compositions, not exact preservation of the original learned energy.
Implementation notes
Insert the block between residual or state-space layers as a two-channel hidden state $(q,p)$, each with width $d$. Construct a scalar Hamiltonian $H_\phi(q,p,x)=U_\phi(q,x)+K_\phi(p)$, where $x$ is the block input, $U_\phi$ is a small MLP potential, and $K_\phi(p)=\frac12p^\top\operatorname{softplus}(m_\phi)^{-1}p$ with positive learned masses. Apply the three displayed leapfrog substeps, using automatic differentiation of the scalar Hamiltonian to obtain $\nabla_qH_\phi$ and $\nabla_pH_\phi$. Keep $x$ fixed during internal substeps. Use two or four substeps per block and expose either $q_{k+1}$ or a projected concatenation $[q_{k+1},p_{k+1}]$ to the next layer. Initialize $q$ from the incoming residual and $p=0$ or a learned projection of $x$. Train with the task loss; an optional small term $\lambda|H_{k+1}-H_k|^2$ may be used only as an ablation. The symplectic property follows analytically from the splitting, while the Hamiltonian scale and stable step size are learned or tuned. Test a six-layer residual MLP and a small Transformer on sequential MNIST, comparing Euler residual, gated residual, and symplectic blocks at matched parameters. Repeat each model 100–200 times at inference to test rollout stability. Record hidden-state norms, $H_k$, gradient norms, accuracy, and wall-clock cost. Success is bounded state and energy drift, fewer exploding gradients, and stable accuracy at long rollout lengths without disproportionate compute.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Confirmed ✓
Stage 2 · Practical benchmark result: Significantly worse ✗
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 PyTorch learned separable-Hamiltonian SymplecticBlock with leapfrog substeps and a deterministic nonlinear oscillator verification. The core claim was clearly observed: leapfrog had Jacobian determinant 1.0, bounded norm, and small bounded energy error over 10,000 steps, while Euler had determinant 1.06352 and diverged rapidly. A tiny learned one-step regression also showed a slight MSE improvement, but with substantially more parameters, so the practical accuracy win is only a weak signal.
- Agent confidence
- 9/10
- Baseline
- Explicit Euler: Jacobian determinant 1.06352; at h=0.1 diverged at step 189 with maximum energy error 7.39e264; at h=0.2 diverged at step 58.
- Idea
- Leapfrog: Jacobian determinant 1.0; over 10,000 steps maximum norm 1.134 and maximum absolute energy error 0.00173 at h=0.1, with no divergence. Learned one-step MSE was 0.00823 versus 0.00885 for the Euler analogue, using 355 versus 164 parameters.
Limitations: Only a toy nonlinear oscillator and tiny one-step regression were tested. No sequential-MNIST, Transformer, multilayer residual benchmark, matched-FLOP comparison, repeated training seeds, or GPU speed measurement was performed. The learned symplectic block is more expensive because it computes internal Hamiltonian gradients with autograd.
How to run: python3 experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.09549)
Significantly WORSE than the tuned baseline (+294.7%, p=0.0081, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0016
- Idea mean
- 0.0063
- Effect (Δ)
- 0.0047 (+294.7%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Confirmed ✓
- Practical effect
- Hurts
- Baseline tuning
- swept over 3 configs
The compact protocol used 400 training examples, 200 test examples, and 12 epochs. The symplectic model was not parameter- or FLOP-matched to the GRU, only one substep configuration was tested, and no longer rollout evaluation beyond the built-in next-angle task metric was performed.
How to run: python3 bench_experiment.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 10/10
Implemented a matched end-to-end SymplecticRNN replacement for the GRU on the structurally appropriate dynamics track, using train_model and 8 paired seeds. The trained symplectic transition preserved the predicted near-unit Jacobian determinant, with log|det J|=0.00388, but test MSE was significantly worse than the tuned GRU baseline: 0.00631 versus 0.00160, paired delta +0.00471 and permutation p=0.0081. The mechanism was confirmed, but the system did not produce a benchmark win.
- Baseline
- rnn_small GRU, best lr=0.005: test MSE 0.0015987288497854024 ± 0.0004723450985826372 over 8 seeds
- Idea
- SymplecticRNN, best lr=0.005 and step=0.12: test MSE 0.006309549498837441 ± 0.0013831181007421675 over 8 seeds; trained transition log|det J|=0.00387675897218287
Benchmark result
Significantly WORSE than the tuned baseline (+294.7%, p=0.0081, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0016
- Idea mean
- 0.0063
- Effect (Δ)
- 0.0047 (+294.7%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0081 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- n/a
- Mechanism
- Confirmed ✓
- Practical effect
- Hurts
- Baseline tuning
- swept over 3 configs
The compact protocol used 400 training examples, 200 test examples, and 12 epochs. The symplectic model was not parameter- or FLOP-matched to the GRU, only one substep configuration was tested, and no longer rollout evaluation beyond the built-in next-angle task metric was performed.
How to run: python3 bench_experiment.py
Artifacts
- bench_experiment.py 6.9 KB View Raw
- bench_report.json 3.7 KB View Raw
- experiment.py 3.1 KB View Raw
- report.md 1.5 KB View
- report_bench_2026-09-04T211541.md 3.3 KB View
- results.json 2.7 KB View Raw
- symplectic_block.py 1.8 KB View Raw