Ketbook · Fundamentals wiki/optimization.md Draft · not yet reviewed by a curator

Edit this page ↗History ↗

Optimization

In brief. The energy gradient is a Monte Carlo estimate built from the same samples as the energy. Stochastic reconfiguration (SR) preconditions it with the quantum geometric tensor SS, which turns the update into a step of imaginary-time evolution projected onto the variational manifold, equivalently a natural-gradient step. For networks with more parameters than samples the same update is computed exactly from an Ns×NsN_s\times N_s kernel instead of the Np×NpN_p\times N_p matrix SS (minSR). Regularization is unavoidable because SS is singular, and the choice of regularizer, learning rate and sample size is part of the method.

Notation follows the conventions page. Centred quantities carry a bar: Oˉk=Ok−⟨Ok⟩\bar O_k=O_k-\langle O_k\rangle, Eˉloc=Eloc−⟨Eloc⟩\bar E_{\mathrm{loc}}=E_{\mathrm{loc}}-\langle E_{\mathrm{loc}}\rangle.

Minimizing EθE_\theta over the parameters of a neural quantum state is a stochastic optimization problem with three unusual features: the objective and its gradient are available only as noisy Monte Carlo estimates, the noise vanishes at the solution, and the parametrization is massively redundant, so the Euclidean geometry of θ\theta bears no relation to the geometry of the states ∣Ψθ⟩|\Psi_\theta\rangle. Stochastic reconfiguration addresses the third point; its kernel formulation makes it affordable for networks with 10510^5–10710^7 parameters.

Energy gradient

For real parameters,

Fk≡∂θkEθ=2Re⁡⟨Oˉk∗ Eˉloc⟩. F_k\equiv\partial_{\theta_k}E_\theta=2\operatorname{Re}\left\langle \bar O_k^{*}\,\bar E_{\mathrm{loc}}\right\rangle .

For complex parameters with log⁡Ψθ\log\Psi_\theta holomorphic in θ\theta (the standard complex RBM, for example) the natural object is the Wirtinger derivative with respect to θ∗\theta^*,

Fk≡∂Eθ∂θk∗=⟨Oˉk∗ Eˉloc⟩, F_k\equiv\frac{\partial E_\theta}{\partial\theta_k^{*}}=\left\langle \bar O_k^{*}\,\bar E_{\mathrm{loc}}\right\rangle ,

and steepest descent is θ←θ−ηF\theta\leftarrow\theta-\eta F without the factor 2. Mixed cases, real parameters feeding a complex output or separate amplitude and phase networks, reduce to the real formula with OkO_k complex. The centring with ⟨Eloc⟩\langle E_{\mathrm{loc}}\rangle does not change the expectation value but removes the dominant noise term: at an eigenstate Eˉloc=0\bar E_{\mathrm{loc}}=0 configuration by configuration, so the gradient estimator inherits the zero-variance property of the energy.

Plain gradient descent on FF works for small networks and is what Adam-type optimizers do with adaptive scaling. It fails in two predictable ways: parameters that change the state only weakly (flat directions of the network) receive the same step as parameters that change it violently, and the step length in parameter space has no meaning in Hilbert space. Both are fixed by measuring distance between states rather than between parameter vectors.

Stochastic reconfiguration

Stochastic reconfiguration (SR; Sorella, arXiv:cond-mat/9803107, arXiv:cond-mat/0009149) replaces the Euclidean metric with the metric induced on the variational manifold by the Hilbert-space inner product. For an infinitesimal change δθ\delta\theta,

1−∣⟨Ψθ∣Ψθ+δθ⟩∥Ψθ∥ ∥Ψθ+δθ∥∣2=∑kk′δθk∗ Skk′ δθk′+O(δθ3),Skk′=⟨Oˉk∗ Oˉk′⟩. 1-\left|\frac{\langle\Psi_\theta|\Psi_{\theta+\delta\theta}\rangle}{\|\Psi_\theta\|\,\|\Psi_{\theta+\delta\theta}\|}\right|^2 =\sum_{kk'}\delta\theta_k^{*}\,S_{kk'}\,\delta\theta_{k'}+O(\delta\theta^3), \qquad S_{kk'}=\left\langle \bar O_k^{*}\,\bar O_{k'}\right\rangle .

SS is the quantum geometric tensor restricted to the variational manifold; its real part is the Fubini–Study metric. The SR update is the natural-gradient step in this metric,

δθ=−η S−1F,orδθ=−η [Re⁡S]−1F \delta\theta=-\eta\,S^{-1}F , \qquad\text{or}\qquad \delta\theta=-\eta\,\bigl[\operatorname{Re}S\bigr]^{-1}F

for complex-holomorphic and real parametrizations respectively. The same update is obtained by projecting one step of imaginary-time evolution onto the manifold: minimizing the Fubini–Study distance between ∣Ψθ+δθ⟩|\Psi_{\theta+\delta\theta}\rangle and (1−τH)∣Ψθ⟩(1-\tau H)|\Psi_\theta\rangle gives S δθ=−τFS\,\delta\theta=-\tau F, so η\eta is literally an imaginary-time step (Stokes et al., arXiv:1909.02108; Yuan et al., arXiv:1812.08767). Replacing τ\tau by i dti\,\mathrm{d}t gives the time-dependent variational principle used for real-time dynamics with the same SS and FF (Carleo and Troyer, arXiv:1606.02318; Schmitt and Heyl, arXiv:1912.08828).

SR is invariant under reparametrization of θ\theta, so rescaling a layer or changing the activation's normalization does not change the trajectory in state space. And the energy decreases to first order in η\eta for any positive semi-definite SS, with the decrease −ηF†S−1F-\eta F^\dagger S^{-1}F bounded by the inverse metric rather than by the raw gradient norm.

Estimating SS and FF from the same NsN_s samples is standard. SS is then a rank-≤Ns\le N_s matrix of size Np×NpN_p\times N_p; building and inverting it costs O(NsNp2+Np3)O(N_sN_p^2+N_p^3) in time and O(Np2)O(N_p^2) in memory, which caps SR at a few 10410^4 parameters when done naively. Iterative solvers (conjugate gradient on S δθ=−ηFS\,\delta\theta=-\eta F using only matrix-vector products Oˉ†(Oˉv)\bar O^\dagger(\bar O v)) remove the memory cost but still need many passes over the Jacobian per step.

Natural gradient and information geometry

In the real case Re⁡S\operatorname{Re}S is a Fisher information matrix in disguise. Write Ψθ=pθ eiϕθ\Psi_\theta=\sqrt{p_\theta}\,e^{i\phi_\theta} up to normalization. Then

Re⁡Skk′=14 Fkk′+Cov⁡pθ ⁣(∂kϕθ,∂k′ϕθ),Fkk′=Epθ ⁣[∂klog⁡pθ ∂k′log⁡pθ]. \operatorname{Re}S_{kk'}=\tfrac14\,\mathcal F_{kk'}+\operatorname{Cov}_{p_\theta}\!\left(\partial_k\phi_\theta,\partial_{k'}\phi_\theta\right), \qquad \mathcal F_{kk'}=\mathbb{E}_{p_\theta}\!\left[\partial_k\log p_\theta\,\partial_{k'}\log p_\theta\right].

The first term is Amari's natural-gradient metric for the sampling distribution; the second is the phase contribution that has no classical counterpart. For a real positive ansatz SR is natural gradient descent on pθp_\theta up to the factor 14\tfrac14; for a state with nontrivial phase structure the phase term is what prevents the optimizer from changing the sign structure too fast relative to the amplitudes. Park and Kastoryano (arXiv:1910.11163) analyse the resulting geometry for complex-parameter networks, including the degenerate directions that make regularization unavoidable.

The kernel formulation (minSR)

Collect the centred log-derivatives into the Ns×NpN_s\times N_p matrix Xik=Oˉk(σi)/NsX_{ik}=\bar O_k(\boldsymbol{\sigma}_i)/\sqrt{N_s} and the centred local energies into εi=Eˉloc(σi)/Ns\varepsilon_i=\bar E_{\mathrm{loc}}(\boldsymbol{\sigma}_i)/\sqrt{N_s}. Then the Monte Carlo estimates are simply

S=X†X,F=X†ε, S=X^\dagger X,\qquad F=X^\dagger\varepsilon ,

and the SR step is the least-squares solution of the overdetermined (or, for Np>NsN_p>N_s, underdetermined) linear system X δθ=−η εX\,\delta\theta=-\eta\,\varepsilon. The push-through identity

(X†X+λ 1Np)−1X†=X†(XX†+λ 1Ns)−1 \left(X^\dagger X+\lambda\,\mathbb 1_{N_p}\right)^{-1}X^\dagger =X^\dagger\left(XX^\dagger+\lambda\,\mathbb 1_{N_s}\right)^{-1}

moves the inversion from the Np×NpN_p\times N_p matrix SS to the Ns×NsN_s\times N_s kernel T=XX†T=XX^\dagger, whose entries are overlaps between samples, Tij=1Ns∑kOˉk∗(σi)Oˉk(σj)T_{ij}=\tfrac1{N_s}\sum_k\bar O_k^*(\boldsymbol{\sigma}_i)\bar O_k(\boldsymbol{\sigma}_j), the empirical neural tangent kernel of the log-amplitude. The update becomes

δθ=−η X†(T+λ 1)−1ε, \delta\theta=-\eta\,X^\dagger\left(T+\lambda\,\mathbb 1\right)^{-1}\varepsilon ,

at a cost of O(NpNs2+Ns3)O(N_pN_s^2+N_s^3) and memory O(NsNp)O(N_sN_p) for the Jacobian, which is what a reverse-mode pass stores anyway. Chen and Heyl (arXiv:2302.01941) derived this as the minimum-norm solution of the least-squares problem and used it to optimize deep networks with far more parameters than samples; Rende et al. (arXiv:2310.05715) pointed out the identity above and the fact that no approximation is involved: for λ→0\lambda\to0 the kernel update coincides with SR using the pseudo-inverse of SS. For real parameters and complex Ψ\Psi, stack real and imaginary parts, X~=(Re⁡XIm⁡X)\tilde X=\begin{pmatrix}\operatorname{Re}X\\ \operatorname{Im}X\end{pmatrix}, ε~=(Re⁡εIm⁡ε)\tilde\varepsilon=\begin{pmatrix}\operatorname{Re}\varepsilon\\ \operatorname{Im}\varepsilon\end{pmatrix}, and invert the real 2Ns×2Ns2N_s\times 2N_s kernel X~X~⊤\tilde X\tilde X^{\top}.

The kernel picture also clarifies what SR can and cannot do with finite samples. SS estimated from NsN_s samples has rank at most NsN_s, so with Np>NsN_p>N_s the update lives in the NsN_s-dimensional span of the sampled log-derivative vectors; directions of parameter space invisible to the current batch are not moved. This is a feature (no spurious updates from unsampled directions) and the reason why increasing NsN_s keeps improving minSR optimizations well beyond the point where the gradient itself is converged.

Regularization

SS is singular whenever parameters are redundant, which for a neural network is always: the normalization of Ψ\Psi is a flat direction, and so are the gauge freedoms of each layer. Finite sampling adds noise to the small eigenvalues that S−1S^{-1} then amplifies. The standard remedies are:

  • Diagonal shift, S→S+λ 1S\to S+\lambda\,\mathbb 1 with λ∼10−4\lambda\sim10^{-4}–10−210^{-2}. Equivalent to adding λ∥δθ∥2\lambda\|\delta\theta\|^2 to the Fubini–Study distance, i.e. a trust region in parameter space. Breaks the reparametrization invariance of SR by the amount λ\lambda.
  • Scale-invariant (relative) shift, Skk→Skk(1+λ)S_{kk}\to S_{kk}(1+\lambda) (Sorella, Casula, Rocca, arXiv:cond-mat/0702349, Eq. 11). Regularizes each direction relative to its own curvature, so parameters with tiny natural scale are not frozen by a uniform shift. The same idea applied to the kernel is T→T+λdiag⁡(T)T\to T+\lambda\operatorname{diag}(T).
  • Spectral cut-off: diagonalize SS (or TT) and discard eigen-directions with eigenvalue below a threshold relative to the largest. Equivalent to the pseudo-inverse with a tolerance; the threshold sets how many effective directions are updated per step.
  • Signal-to-noise filtering (Schmitt and Heyl, arXiv:1912.08828): in the eigenbasis of SS, estimate the Monte Carlo error of each component of FF and zero the components whose signal-to-noise ratio is below a cut. Unlike a fixed cut-off this adapts to the actual noise level and is the method of choice for real-time evolution, where unfiltered noise is integrated instead of damped.

Regularization strength, learning rate and sample size are coupled: a larger λ\lambda permits a larger η\eta, and a larger NsN_s permits a smaller λ\lambda. Published protocols usually quote all three plus a schedule.

Practical protocol

  1. Choose NsN_s by the gradient noise, not by NpN_p. With the kernel formulation Ns≪NpN_s\ll N_p is routine; 10310^3–10410^4 samples per step is typical for lattice models, with a few Metropolis sweeps between stored samples so that successive samples are weakly correlated.
  2. Use a learning-rate schedule. SR with constant η∼10−2\eta\sim10^{-2}–10−110^{-1} reaches the basin quickly; the last decades of energy are gained with η\eta decreased by one to two orders of magnitude, often together with a decrease of λ\lambda and an increase of NsN_s.
  3. Impose symmetries after the fact when possible. Projecting the state onto an irreducible representation of the lattice symmetry group (translations, point group, spin flip) lowers the energy at a cost linear in the group size and changes the local energy, not the optimizer.
  4. Monitor the variance as well as the energy. A decreasing energy with a stagnating or rising variance signals that the optimizer is trading sign-structure quality for amplitude quality, a common precursor to a plateau on frustrated models (Bukov, Schmitt, Dupont, arXiv:2011.11214).
  5. Evaluate the final state separately. Freeze θ\theta, run long chains, and apply the binning analysis to obtain the error bar. The energy reported in a paper, and in Ketboard, is this number, not the last value of the optimization trace.

Alternatives and extensions

  • Linear method (Toulouse and Umrigar, arXiv:physics/0701039): diagonalize HH in the basis {∣Ψθ⟩,∂k∣Ψθ⟩}\{|\Psi_\theta\rangle,\partial_k|\Psi_\theta\rangle\} each step. Quadratic convergence near the minimum and no step-size tuning, at the price of a generalized eigenproblem of size Np+1N_p+1; used for Jastrow–Slater and small networks, impractical beyond 10410^4 parameters.
  • Lanczos steps: apply (1+α1H+… )(1+\alpha_1 H+\dots) to the optimized state and optimize the few αp\alpha_p. Each step is a legitimate variational state whose energy can be evaluated directly, so it is eligible for Ketboard; the subsequent zero-variance extrapolation is not (Hu et al., arXiv:1304.2630; Nomura and Imada, arXiv:2005.14142).
  • First-order optimizers with preconditioning (Adam, RMSProp): no SS at all, cheap per step, competitive in early optimization and for autoregressive models where exact sampling makes gradients clean. Converge slowly in the final phase on frustrated models, where the metric matters most.
  • Supervised and projected schemes: fit the network to H∣Ψ⟩H|\Psi\rangle or to a power-method target instead of minimizing the energy; the final state is still variational and its directly evaluated energy qualifies, provided the number reported is ⟨Ψθ∣H∣Ψθ⟩/⟨Ψθ∣Ψθ⟩\langle\Psi_\theta|H|\Psi_\theta\rangle/\langle\Psi_\theta|\Psi_\theta\rangle and not a projected estimate.

References

  • S. Sorella, Green function Monte Carlo with stochastic reconfiguration, arXiv:cond-mat/9803107 (1998). The SR update.
  • S. Sorella, Generalized Lanczos algorithm for variational quantum Monte Carlo, arXiv:cond-mat/0009149 (2000). SR as imaginary-time projection; Lanczos steps on a variational state.
  • S. Sorella, M. Casula, D. Rocca, Weak binding between two aromatic rings: Feeling the van der Waals attraction by quantum Monte Carlo methods, arXiv:cond-mat/0702349 (2007). Scale-invariant regularization of SR.
  • S. Amari, Natural gradient works efficiently in learning, Neural Computation 10, 251 (1998). The natural gradient.
  • J. Stokes, J. Izaac, N. Killoran, G. Carleo, Quantum natural gradient, arXiv:1909.02108 (2019). The Fubini–Study metric as the natural metric for variational states.
  • X. Yuan, S. Endo, Q. Zhao, Y. Li, S. Benjamin, Theory of variational quantum simulation, arXiv:1812.08767 (2018). Variational principles for imaginary- and real-time evolution.
  • C.-Y. Park, M. J. Kastoryano, Geometry of learning neural quantum states, arXiv:1910.11163 (2019). The geometry of SS for complex-parameter networks.
  • A. Chen, M. Heyl, Empowering deep neural quantum states through efficient optimization, arXiv:2302.01941 (2023). minSR.
  • R. Rende, L. L. Viteritti, L. Bardone, F. Becca, S. Goldt, A simple linear algebra identity to optimize large-scale neural network quantum states, arXiv:2310.05715 (2023). The kernel identity and its real-parameter form.
  • M. Schmitt, M. Heyl, Quantum many-body dynamics in two dimensions with artificial neural networks, arXiv:1912.08828 (2019). Signal-to-noise regularization.
  • J. Toulouse, C. J. Umrigar, Optimization of quantum Monte Carlo wave functions by energy minimization, arXiv:physics/0701039 (2007). The linear method.
  • M. Bukov, M. Schmitt, M. Dupont, Learning the ground state of a non-stoquastic quantum Hamiltonian in a rugged neural network landscape, arXiv:2011.11214 (2020). Optimization landscapes with sign structure.
  • F. Vicentini et al., NetKet 3: Machine learning toolbox for many-body quantum systems, arXiv:2112.10526 (2021). Reference implementations.

Edit this page

Corrections, sharper derivations and missing references are welcome. Edit the Markdown on GitHub and open a pull request; LaTeX is rendered at build time.

Edit on GitHub ↗