quantax.optimizer.QNGD#
- class quantax.optimizer.QNGD#
Base class of quantum natural gradient descent. It solves the linear equation \(\bar O \dot \theta = \bar \epsilon\), in which \(\bar O\) is the centered Jacobian matrix and \(\bar \epsilon\) is defined by the gradient source
grad. The behavior is composed from three pluggable parts: the gradient source (e.g.EnergyGrad), the numericalsolver, and theupdaterstrategy (e.g.Spring).- __init__(state: Variational, grad: EnergyGrad | OverlapGrad, imag_time: bool = True, solver: Callable[[...], Array] | None = None, updater: Updater | None = None, file: str | Path | BinaryIO | None = None)#
- Parameters:
state – Variational state to be optimized.
grad – The gradient source defining \(\bar \epsilon\), e.g.
EnergyGradorOverlapGrad.imag_time – Whether to use imaginary-time evolution.
solver – The numerical solver for the matrix inverse, default to
auto_shift_eig.updater – The update strategy applied around the equation solve, default to
PlainUpdater.file – The file with stored buffers of the optimizer.
- property state: Variational#
Variational state to be optimized.
- property holomorphic: bool#
Whether the state is holomorphic.
- property imag_time: bool#
Whether to use imaginary-time evolution.
- property hamiltonian: Operator | None#
The Hamiltonian for the evolution,
Nonewhen the gradient source doesn’t define it.
- property energy: Array | ndarray | bool | number | bool | int | float | complex | None#
Energy of the current step,
Nonewhen the gradient source doesn’t define it.
- property VarE: Array | ndarray | bool | number | bool | int | float | complex | None#
Energy variance \(\left< (H - E)^2 \right>\) of the current step,
Nonewhen the gradient source doesn’t define it.
- solve(Obar: Array, Ebar: Array, buffers: dict) tuple[Array, dict]#
Generate the optimization step for given \(\bar O\) and \(\bar \epsilon\) by applying the updater strategy around
solve_equation.
- solve_equation(Obar: Array, Ebar: Array, **solver_kwargs) Array#
Solve the linear equation \(\bar O \dot \theta = \bar \epsilon\) for given \(\bar O\) and \(\bar \epsilon\). Real and imaginary parts are stacked for non-holomorphic states, and extra keyword arguments are forwarded to the numerical solver.
A
diag_preconditionerkeyword is handled here: if the solver declares it as an argument (e.g.lsmr), it is passed through; otherwise the right preconditioning is emulated by solving with \(\bar O / d\) and rescaling the output by \(1 / d\).
- save(file: str | Path | BinaryIO) None#
Save the optimizer buffers to a file.