Skip to content

shpital/spectralnet_v5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpectralNet v5

Spectral Evaluation of 2D Chernoff--Remizov Trajectories: Resolving Interpolation Diffusion in 2D Darcy Inverse Problems

Sergey V. Shpital

DOI License: MIT Python 3.10+

Overview

This repository contains the code accompanying the paper:

S. V. Shpital. Spectral Evaluation of 2D Chernoff--Remizov Trajectories: Resolving Interpolation Diffusion in 2D Darcy Inverse Problems. Zenodo, April 20, 2026. doi:10.5281/zenodo.19664767

It is the 2D follow-up to the SpectralNet v4 study of differentiable Chernoff--Remizov trajectories for inverse problems. Where v4 established the constructive trajectory as a viable differentiable forward model on a 1D Darcy testbed and exposed three mechanistic regimes, v5 carries the programme into 2D and asks two questions:

  1. Does the 1D diagnostic framework transport to 2D?
  2. If a direct grid-based 2D extension underperforms, why does it underperform, and can the bottleneck be removed without abandoning the constructive trajectory?

We study the 2D Darcy inverse problem

$$L = \nabla \cdot \bigl(a(x,y),\nabla,\cdot\bigr),\qquad a(x,y) > 0,\quad (x,y) \in (0,1)^2,$$

with Dirichlet boundary conditions, recovering $a(x,y)$ from a single noisy observation $u_{\mathrm{obs}}$ of the steady state.

Main findings:

  • Direct 2D extension is forward-bias-limited on coarse grids. A grid-based 2D Lie--Trotter composition of the 1D Chernoff--Remizov step retains differentiability but is dominated by interpolation diffusion — repeated bilinear resampling at coefficient-dependent shift locations — yielding $10$–$26%$ inverse error and a non-monotonic $K$-dependence on $32 \times 32$ grids.
  • A spectral variant removes the bottleneck. Representing the state in a truncated discrete sine basis and evaluating the Chernoff--Remizov shift analytically on that basis (instead of through grid interpolation) lowers inverse error to $1$–$13%$ across four representative coefficient families ($2.0$–$9.2 \times$ improvement), restores strictly monotonic $K$-convergence on broadband fields, and is no slower than the grid variant on a modern GPU.
  • Two of three 1D regimes transport cleanly. Once interpolation diffusion is subtracted, the spectral variant exhibits a forward-limited regime (sub-$1%$ residual on smooth families, traced to a $\tau$-dependent pseudo-time fixed-point bias via a Strang-splitting diagnostic) and a parameterization-limited regime that is refined into an identifiability limit on localized features (M-ablation + closed-form basis-capacity baseline). The 1D approximation-limited regime does not separate into a distinct empirical signature on the families studied here.
  • Decomposition machine. What transports cleanly is the decomposition framework itself: failure modes separate into solver bias, basis capacity, and information-theoretic limits, and each component is directly measurable.

Installation

git clone https://github.com/shpital/spectralnet_v5.git
cd spectralnet_v5
pip install -r requirements.txt

Alternatively, with conda:

conda create -n spectralnet_310 python=3.10
conda activate spectralnet_310
pip install -r requirements.txt

Project Structure

├── src/
│   ├── inverse_2d/                                 # Grid-based 2D Chernoff--Remizov pipeline
│   │   ├── remizov_2d.py                           #   Differentiable grid 2D step (Lie--Trotter)
│   │   ├── fd_solver_2d.py                         #   Reference 2D FD forward solver (u_obs only)
│   │   ├── coefficient_zoo_2d.py                   #   Four families: smooth_lowfreq / smooth_highfreq /
│   │   │                                           #   anisotropic / localized
│   │   ├── probe_2d_inverse.py                     #   Phase A inverse pilot (Adam → L-BFGS)
│   │   ├── probe_2d_k_sweep.py                     #   Single-family K-sweep
│   │   ├── probe_2d_k_sweep_multi.py               #   Four-family K-sweep
│   │   ├── probe_2d_noise.py                       #   Noise robustness (1% / 5%)
│   │   ├── probe_2d_basis_ablation.py              #   M-ablation on localized_2d
│   │   ├── probe_2d_nx_sweep.py                    #   Resolution-disambiguation study (Phase C)
│   │   └── smoke_test_2d.py                        #   Differentiability sanity check
│   └── spectral_remizov/                           # Spectral 2D variant + diagnostics
│       ├── remizov_spectral_2d.py                  #   Differentiable spectral 2D step (DST-I evaluation)
│       ├── remizov_spectral_1d.py                  #   1D companion / unit-test reference
│       ├── probe_spectral_vs_grid_2d.py            #   Forward-error spectral vs. grid (paired)
│       ├── probe_spectral_vs_grid_1d.py            #   1D check
│       ├── probe_inverse_spectral_vs_grid_2d.py    #   Inverse benchmark, four families (Sec. 6)
│       ├── probe_week4_benchmark_2d.py             #   Full benchmark (K-sweep + noise) for spectral variant
│       ├── probe_fourier_truncation_2d.py          #   Closed-form basis-capacity baseline (Sec. 7)
│       └── probe_pre_paper_2d.py                   #   Pre-paper diagnostics (Strang vs. Lie--Trotter, M-ablation)
├── scripts/                                        # Bash drivers — one per paper result
│   ├── run_phase_a_2d_inverse.sh                   #   Phase A inverse pilot (Sec. 5)
│   ├── run_phase_a_2d_k_sweep.sh                   #   K-sweep on a single family (Sec. 5)
│   ├── run_phase_a_2d_noise.sh                     #   Noise robustness (Sec. 6)
│   ├── run_phase_b_2d_basis_ablation.sh            #   M-ablation (Sec. 7)
│   ├── run_phase_b_2d_k_sweep_multi.sh             #   Four-family K-sweep (Sec. 5 / Sec. 6)
│   ├── run_phase_c_2d_nx_sweep.sh                  #   Resolution disambiguation (Sec. 5)
│   ├── run_spectral_vs_grid_1d.sh                  #   1D paired check (Sec. 6)
│   ├── run_spectral_vs_grid_2d.sh                  #   Spectral vs. grid forward (Sec. 6)
│   ├── run_inverse_spectral_vs_grid_2d.sh          #   Spectral vs. grid inverse, four families (Sec. 6)
│   ├── run_fourier_truncation.sh                   #   Basis-capacity baseline (Sec. 7)
│   ├── run_pre_paper.sh                            #   Strang vs. Lie--Trotter, M-ablation (Sec. 7)
│   ├── run_week4_benchmark.sh                      #   Full spectral benchmark
│   └── smoke_test_2d.sh                            #   End-to-end differentiability smoke test
├── requirements.txt
├── LICENSE
└── README.md

Reproducibility rule. Every experiment, smoke test and sanity check is driven by a committed .py / .sh file; no one-off inline terminal runs. Any reported number can be regenerated from the frozen scripts above.

Quick Start: Reproducing Key Results

1. Smoke test (gradients propagate end-to-end)

bash scripts/smoke_test_2d.sh

Differentiability sanity check on both the grid and the spectral 2D Chernoff--Remizov step.

2. Phase A: grid-based 2D inverse benchmark (Sec. 5)

bash scripts/run_phase_a_2d_inverse.sh
bash scripts/run_phase_b_2d_k_sweep_multi.sh

Reproduces the four-family inverse benchmark and joint forward/inverse $K$-sweep that exposes the non-monotonic $K$-dependence and the resolution-driven failure of the direct grid extension.

3. Resolution disambiguation (Sec. 5)

bash scripts/run_phase_c_2d_nx_sweep.sh

Confirms that the grid-side failure is driven by interpolation-diffusion mechanics rather than under-resolution: the failure pattern transports across $n \in {32, 48, 64}$.

4. Spectral 2D inverse benchmark (Sec. 6)

bash scripts/run_inverse_spectral_vs_grid_2d.sh
bash scripts/run_week4_benchmark.sh

Paired grid-vs-spectral inverse runs on the four families plus the full $K$-sweep / noise sweep for the spectral variant. Reproduces Tables 6.1, 6.2, 6.3 and Figures of Sec. 6.

5. Error-source decomposition (Sec. 7)

bash scripts/run_phase_b_2d_basis_ablation.sh   # M-ablation: more parameters worsen the inverse on localized_2d
bash scripts/run_fourier_truncation.sh          # Closed-form basis-capacity baseline (0.12 % reachability)
bash scripts/run_pre_paper.sh                   # Strang vs. Lie--Trotter (isolates τ-bias on smooth fields)

Reproduces the decomposition of Table 7.5 and the supporting Tables 7.1, 7.3.

6. 1D paired check (Appendix / Sec. 6)

bash scripts/run_spectral_vs_grid_1d.sh

Sanity check that the spectral evaluation reduces to the 1D Chernoff--Remizov of v4 when restricted to one axis.

Note: Scripts invoke Python through the $PYTHON environment variable, which defaults to plain python. To use a specific interpreter or conda/mamba environment, export it before running, e.g.

PYTHON="mamba run -n myenv python" bash scripts/run_week4_benchmark.sh

The 2D Chernoff--Remizov (CR) Step

For the 1D Darcy generator $L = a(x),\partial_{xx} + a'(x),\partial_x$, Remizov's constructive one-step map is the three-shift form

$$S(\tau)u = \tfrac{1}{4},u(x + \sigma(x)) + \tfrac{1}{4},u(x - \sigma(x)) + \tfrac{1}{2},u(x + \gamma(x)),$$

with diffusion shift $\sigma(x) = 2\sqrt{a(x),\tau}$ and drift shift $\gamma(x) = 2,a'(x),\tau$. Both shifts are $O(\sqrt{\tau})$ and $O(\tau)$ respectively, and Taylor expansion recovers $S'(0) = L$ in the Chernoff sense.

The 2D step composes two per-axis 1D steps via Lie--Trotter splitting:

$$S_{\mathrm{2D}}(\tau) = S^{(y)}(\tau) \circ S^{(x)}(\tau).$$

Two evaluation strategies, one operator. Because the per-axis step requires evaluating $u$ at non-grid shifted locations $x + \sigma$, $x - \sigma$, $x + \gamma$, the 2D step is determined entirely by how those off-grid evaluations are performed:

  • Grid variant (src/inverse_2d/remizov_2d.py): bilinear interpolation on the grid. Six per-step gathers, fully differentiable through torch.grid_sample autograd. This is the direct 2D analogue of the v4 implementation.
  • Spectral variant (src/spectral_remizov/remizov_spectral_2d.py): represent the state in a truncated discrete sine basis (DST-I); evaluate the shifted state analytically as $\sum_k \hat u_k,\sin(k\pi(x+s)/L)$. No interpolation, no per-step low-pass. Differentiable through torch.einsum.

Both variants share the same Lie--Trotter splitting, the same pseudo-time relaxation, the same coefficient parameterization, and the same Adam → L-BFGS optimizer stack; they differ only in the off-grid evaluation step. Differences in inverse error therefore reflect the forward model, not the optimizer.

What the Spectral Variant Buys

Family Grid inverse err. Spectral inverse err. Improvement
smooth_lowfreq_2d 9.87 % 1.07 % $9.2\times$
smooth_highfreq_2d 12.39 % 3.18 % $3.9\times$
anisotropic_2d 12.35 % 3.50 % $3.5\times$
localized_2d 25.58 % 13.00 % $2.0\times$

All numbers at $K = 512$, $n = 32$, four-family inverse benchmark (Sec. 6.1). Wall-clock is within $\pm 15%$ of the grid baseline on this hardware (spectral is in fact slightly faster on three of four families).

How the v4 Diagnostic Framework Transports

1D regime (v4) 2D analogue Diagnosed by
I. Forward-limited Sub-$1%$ residual on smooth families, isolated as a $\tau$-dependent pseudo-time fixed-point bias Strang vs. Lie--Trotter splitting (Sec. 7.3)
II. Approximation-limited Not separated into a distinct empirical signature on the four families studied — (open)
III. Parameterization-limited Refined into an identifiability limit on localized_2d: more parameters worsen the inverse M-ablation + closed-form basis-capacity baseline (Sec. 7.2, 7.4)

What transports cleanly is the decomposition itself (Sec. 7.5): every entry of the residual error budget — forward bias, splitting error, $\tau$-bias, basis capacity, identifiability — is independently measurable on the same testbed.

Implementation and Reproducibility

Code layout. The experiments in the paper are reproduced from the modules src/inverse_2d/ (grid-based 2D Chernoff--Remizov, coefficient families, inverse probes) and src/spectral_remizov/ (spectral 2D variant, 2D and 1D sine-evaluation kernels, pre-paper diagnostics), driven by the bash scripts in scripts/.

Compute. Reported wall-clock numbers were obtained on a single NVIDIA RTX 5070 Ti, PyTorch 2.x with CUDA, float32 throughout. All runs fit comfortably in single-GPU memory.

Optimizer protocol. The inverse loop uses the same two-stage stack across all four families and across both variants:

  1. Adam warmup: 50 iterations, learning rate 0.05, on the coefficient parameter vector.
  2. L-BFGS refinement: up to 30 outer steps of PyTorch L-BFGS with strong Wolfe line search, max_iter=10 inner iterations per outer step, history_size=20, lr=1.0. Early stopping triggers when the relative loss change stays below $10^{-6}$ for 4 consecutive outer steps.

This gives a worst-case budget of $50 + 30 \times 10 = 350$ forward/backward evaluations of the $K$-step trajectory per inverse run. Identical protocol for grid and spectral variants, so differences in inverse error reflect the forward model rather than the optimizer.

Seeds and determinism. Paired grid/spectral runs within a family use the same random seed (observation-noise sampling, coefficient initialization). The reported numbers are from the same seed as the pre-paper diagnostics and the Week 4 benchmark; seed sensitivity on these problems is within a fraction of a percentage point on the inverse-error axis for all four families and does not change the grid-vs-spectral ordering.

Reporting convention. All error numbers in the paper are relative $L^2$ errors with denominators chosen consistently: forward errors against $\lVert u_{\mathrm{ref}} \rVert$; inverse errors against $\lVert a_{\mathrm{true}} \rVert$; state-mismatch errors at the L-BFGS minimum against $\lVert u_{\mathrm{obs}} \rVert$. Wall-clock runtimes are GPU seconds for the full inverse loop, excluding one-time JIT compilation of the DST matrices.

Role of the FD solver. A second-order finite-difference forward solver (src/inverse_2d/fd_solver_2d.py) is used in this work only to generate the synthetic observation $u_{\mathrm{obs}} = \mathrm{FD}(a_{\mathrm{true}}) + \eta$. It is not used as the inverse forward model, and a paired FD-adjoint inverse benchmark is left as future work — the contribution here is accuracy and diagnostics on the constructive trajectory, not a head-to-head runtime comparison with FD on a $32 \times 32$ grid.

License

This project is licensed under the MIT License.

Citation

If you find this work useful, please cite:

@misc{shpital2026spectralnetv5,
      title={Spectral Evaluation of 2D Chernoff--Remizov Trajectories:
             Resolving Interpolation Diffusion in 2D Darcy Inverse Problems},
      author={Sergey V. Shpital},
      year={2026},
      month=apr,
      doi={10.5281/zenodo.19664767},
      url={https://doi.org/10.5281/zenodo.19664767},
      publisher={Zenodo}
}

See Also

  • SpectralNet v1 — resolvent-inspired architecture, classification
  • SpectralNet v2 — operator learning with spectral-spatial blocks
  • SpectralNet v3 — Chernoff--Remizov preprocessing for neural operators
  • SpectralNet v4 — differentiable Chernoff--Remizov trajectories for 1D Darcy inverse problems (this paper's direct predecessor)

About

SpectralNet v5: spectral evaluation of 2D Chernoff–Remizov trajectories for 2D Darcy inverse problems. Companion code for Zenodo 10.5281/zenodo.19664767.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors