neuralqx.driver.vmc module

Variational Monte Carlo driver adapted from NetKet.

This module provides a VMC driver that closely follows NetKet’s implementation, with a small behavioural difference around operator handling. In particular, it avoids explicitly unwrapping a Squared lazy wrapper operator type and instead forwards the Hamiltonian object directly to the variational state’s expectation and gradient routines.

The driver supports passing either a single operator or a list of operators. It checks that all operators act on the same Hilbert space as the provided variational state. It then performs gradient based optimisation of the minimized quantity, labelled as “Constraint” in the driver.

NOTE: parts of this file are derived from NetKet source code, and the original NetKet copyright and license apply in addition to neuraLQX licensing.

class VMC(hamiltonian, optimizer, *, variational_state, preconditioner=<netket.optimizer.preconditioner.IdentityPreconditioner object>)

Bases: AbstractVariationalDriver

Variational Monte Carlo optimisation driver.

This driver minimises the expectation value of a Hamiltonian like objective using samples produced by the provided variational state. It computes the loss statistics and gradient via variational_state.expect_and_grad, optionally applies a preconditioner, and forwards the resulting update direction to the underlying AbstractVariationalDriver optimisation loop.

Parameters:
  • hamiltonian (AbstractOperator | list) – The operator to minimise, or a list of operators to be passed directly to variational_state.expect_and_grad.

  • optimizer (Any) – Optimiser defining how parameter updates are applied given a gradient.

  • variational_state (VariationalState) – Variational state that supplies sampling, expectation values, and gradients.

  • preconditioner (Callable[[VariationalState, Any, Any | None], Any]) – Callable that transforms the raw gradient before optimisation. If None, the identity preconditioner is used.

Raises:

TypeError – If any operator Hilbert space differs from variational_state.hilbert.

property preconditioner

Return the preconditioner used to modify the raw gradient.

The preconditioner is a callable with signature

preconditioner(vstate, grad, step)

where vstate is the variational state, grad is the PyTree gradient, and step is the current optimisation step count. If the preconditioner was set to None, the identity preconditioner is used.

Returns:

The current preconditioner callable.

property energy: Stats

Return the most recently computed loss statistics.

The returned value corresponds to the statistics produced by the last call to the forward and backward evaluation, and represents the expectation value being minimised by this driver.

Returns:

A netket.stats.Stats instance for the current objective estimate.