- Home
- Library
- Computational Quantum Field Theory
- Variational Monte Carlo and Neural Quantum States
- Variational Monte Carlo and the Local Energy
Variational Monte Carlo and the Local Energy
A variational wavefunction has an energy above the ground-state energy, but a Monte Carlo estimate of that energy can lie below it. The first statement concerns an exact expectation value; the second concerns a random estimator. Confusing them can turn a statistical fluctuation into an apparent violation of the variational principle.
We derive the local-energy estimator and its gradient, optimize a six-spin Hamiltonian with both enumeration and sampled gradients, and then measure the coverage of independent energy intervals. The Hilbert space is small enough to evaluate every claimed variational energy directly.
Preparation: normalized state vectors, Pauli matrices, the variational principle and Monte Carlo errors.
The exact variational statement
Let be a Hermitian matrix for a specified finite regulator and let . With ,
Expanding the normalized state in eigenvectors of the same Hamiltonian gives
This inequality holds for every nonzero state, including an incompletely optimized neural state. It does not say that an optimizer found the best state in its ansatz, and it does not compare different lattice spacings, field cutoffs or boundary conditions. Those change the Hamiltonian or its approximation.
A local energy whose mean is the energy
In an orthonormal configuration basis, define
Then
The omitted configurations have zero contribution to this mean. For a complex state, individual local energies may be complex; Hermiticity makes the full mean real. The real part is an unbiased estimator of the energy, while a nonzero sampled imaginary mean can serve as a diagnostic. Our ground-state calculation below uses a real Hamiltonian and real positive amplitudes, so its local energies are real.
If the state has full support,
An exact eigenstate then has zero local-energy variance. At nodes this identity needs care: the left side misses any nonzero on a configuration with . Zero sampled local variance alone need not imply an eigenstate. Exercise 2 gives an exact counterexample.
The mean and local-gradient formulation are described in Vicentini et al., §3.3, Eqs. (11)–(16). The support qualification is essential when rewriting direct state-vector formulas as Born averages.
Estimate the energy of a product state
Take six periodic Pauli spins and the normalized product state . Its 64 amplitudes in the basis are equal. For the Hamiltonian , a spin flip leaves the amplitude ratio in the local energy equal to one. One uniform draw of six independent signs therefore gives
Each bond has zero mean and unit variance. Two distinct bonds have zero covariance because their product contains at least one sign to the first power. Thus the exact energy is and the local-energy variance is . Averaging independent configurations gives standard error . A draw with all spins aligned gives , even below the exact ground energy calculated below. The variational upper bound applies to the exact mean. This estimator is already usable before a parametrized wavefunction is introduced.
Differentiate the normalized state, not just the numerator
For a real parameter , differentiation gives
The term comes from differentiating the norm. Introduce the force
For a holomorphic complex parameterization, the Wirtinger derivative is ; the gradient in a real parameter direction is . These are different coordinate conventions, not conflicting factors.
Where dividing by the amplitude is legitimate, put . Then
The complex conjugate is on . At a moving node, can be nonzero where , so this covariance can miss a direct-gradient contribution. The retained implementation checks the direct formula first and uses ratios only for full-support real ground states.
For independent samples, a centered estimate using the same samples for both means is
The denominator makes this covariance unbiased at a fixed state. Dividing by instead produces the factor . This does not make the entire nonlinear optimization unbiased, particularly when a sampled metric is inverted for stochastic reconfiguration.
The six-spin reference problem
Use periodic Pauli spins with six distinct bonds:
The coefficients multiply Pauli matrices, not . Integer configurations run from 0 to 63, site 0 is the least significant bit, and . The local energy becomes
where flips spin . The diagonal interaction and the off-diagonal spin flips are both included; sampling only the diagonal term would optimize a different problem.
The global flip commutes with . For the trainable comparison use a restricted Boltzmann machine (RBM), a state obtained by summing auxiliary binary spins as in the derivation of its amplitudes. Its real amplitudes are projected with before normalization. The positive projection has full support. All basis states are retained in the exact diagonalization, which gives
An independent Kronecker-product assembly checks the bit-based matrix, and the and limits check its spectrum. The simple state has energy . A uniform product state with and has
Its minimum occurs at and gives . This product representative breaks global flip; it is a valid full-space variational comparator, not an exactly even state.
Width, starting point and stopping condition
Enumerated minimization uses hidden widths , with three fixed real starts at each width. Every parameter starts with standard deviation , using seed components . The parameter count is . Each fit uses analytic gradients and the same L-BFGS-B limits: iterations, function evaluations, relative objective tolerance and gradient tolerance .
The selected rows below expose the different outcomes; all nine fits and their parameters are retained.
| Width and start | Stopping reason | ||
|---|---|---|---|
| , start 0 | relative objective change | ||
| , start 0 | iteration cap | ||
| , start 1 | relative objective change | ||
| , start 2 | relative objective change | ||
| , start 0 | relative objective change |
The three starts give nearly the same energy. The three energy excesses range from to . In particular, the different outcomes show that a larger observed error can be an optimization failure rather than insufficient width.
None of the nine fits meets the independently evaluated gradient criterion. Eight report success because the relative objective change is small; one reaches the iteration cap. For example, the designated , start-0 state has gradient infinity norm despite its very accurate energy. This distinction follows the actual SciPy 1.13.1 L-BFGS-B stopping rules.
Correlations provide an additional check. Define
| State | |||
|---|---|---|---|
| exact ground | |||
| , start 0 | |||
| , start 0 | |||
| , start 0 |
Network width varies here while the Hilbert space and Hamiltonian stay fixed. The continuous scalar example separately varies its field representation. No six-spin result establishes thermodynamic or continuum convergence.
Optimizing with actual sampled gradients
To isolate gradient noise, start every trajectory from the same , start-0 initial parameters. Ordinary gradient descent makes updates with learning rate for the first and thereafter; an update-norm cap of is declared in advance. Each stochastic update uses fresh independent Born samples. Eight replicas use independent seed streams; paired SR comparisons use the same uniform streams with their own evolving distributions.
The sampler constructs the complete -state probability table and draws from its CDF. This is genuine stochastic estimation but an exponentially costly small-system sampling method. Enumeration eliminates Markov-chain autocorrelation at this size.
The enumerated ordinary-gradient trajectory ends at . The eight sampled trajectories have mean direct energy and between-replica standard deviation . That deviation describes optimizer variation, not the uncertainty of an energy estimate for one fixed state. The fixed schedule has not reached the accurate enumerated L-BFGS-B solution. The SR comparison changes the update geometry while retaining the same sample count and schedule.
Independent energy intervals and their coverage
Freeze replica 0 from ordinary gradients and from each of two shifted-SR methods. For each fixed state, generate independent validation batches at and . These samples were not used to optimize or select the states. Form the conventional normal interval
and test whether it contains that state's directly evaluated . The normal approximation is being tested, not assumed to provide exact finite-sample coverage.
| Fixed training method | Validation size | Covered batches out of 512 | 95% interval for coverage |
|---|---|---|---|
| gradient | |||
| gradient | |||
| SR, shift | |||
| SR, shift | |||
| SR, shift | |||
| SR, shift |
The last column is an exact binomial Clopper–Pearson interval for the coverage probability in this repeated-batch experiment. It is separate from each energy interval. All six intervals contain ; trials do not establish exact nominal coverage or validity for another state or sampler.
For the shift- state, of the size- energy estimates fall below the exact ground energy. The state's direct energy is nevertheless . Its energy excess is small compared with the single-batch estimator standard deviation, approximately . The noisy estimates do not inherit the variational inequality.
Left: direct variational energy excesses for all fixed starts, with the iteration-cap result retained. Right: independent coverage estimates with binomial 95% intervals. These bars quantify the finite coverage experiment; they are neither optimizer error bars nor energy uncertainties.
The companion directory examples/computational-qft/neural-quantum-states/ retains all models, stopping statuses, trajectories and coverage estimates. Its default verification modes evaluate saved states without optimizing or resampling. Reproduction writes to explicit new outputs.
Summary
VMC separates three objects: the exact energy of a chosen state, the random local-energy estimate, and the optimizer that changes the state. Enumeration makes those distinctions measurable in this example. Accurate energies do not certify a requested gradient tolerance, sampled energies need not obey a variational bound, and node-sensitive identities must be checked before replacing direct derivatives by logarithmic ratios.
Exercises
1. Recover the normalization term and the complex factor
Starting from , derive its variation for a real parameter. Then suppose is holomorphic in complex parameters. Identify the Wirtinger derivatives and the gradients in the real and imaginary parts of one parameter.
Solution
For an arbitrary variation,
For real , substitute to obtain . In holomorphic coordinates , . Hence
Dropping the derivative of the denominator would omit and give a gradient that changes under an irrelevant rescaling of the state.
2. A moving node hides both a gradient and a variance
Let and with real . At , compare the direct energy derivative, projective tangent norm and quantum energy variance with estimates that use only configurations of nonzero Born probability.
Solution
Directly,
At zero, and . The derivative is already orthogonal to the state, so its projective norm squared is 1. Since and , the quantum variance is also 1.
The Born sampler visits only the first component. Its local energy is , and its log derivative is 0. A covariance assembled only from that one event therefore returns zero gradient, zero tangent metric and zero local-energy variance. The missing second component has and even though its probability is zero. Direct state-vector formulas include these contributions. More samples from the same support cannot repair their omission.
References
- G. Carleo and M. Troyer, “Solving the Quantum Many-Body Problem with Artificial Neural Networks,” Science 355, 602–606 (2017), doi:10.1126/science.aag2302, arXiv:1606.02318v1. Ground-state optimization and Appendix C.
- SciPy developers, SciPy 1.13.1 Manual: L-BFGS-B options. Relative-objective, gradient and iteration stopping rules used in the retained fits.
- F. Vicentini et al., “NetKet 3: Machine Learning Toolbox for Many-Body Quantum Systems,” SciPost Physics Codebases 7 (2022), doi:10.21468/SciPostPhysCodeb.7, arXiv:2112.10526v2. Sections 3.3 and 4.1, Eqs. (11)–(16) and (26)–(31), and the nodal qualification in §3.5, footnote 14.
Scrollable formula. Use Left and Right arrow keys to reveal hidden content.
Scrollable table. Use Left and Right arrow keys to reveal hidden columns.
Scrollable figure. Use Left and Right arrow keys to reveal hidden content.