quantax.optimizer.TimeEvol#

class quantax.optimizer.TimeEvol#

Bases: SR

Time evolution optimizer, equivalent to real-time SR. This optimizer assumes the number of samples is more than the number of parameters, and is more memory-efficient than SR when this is the case.

__init__(state: Variational, hamiltonian: Operator, solver: Callable[[Array, Array], Array] | None = None)#
Parameters:
  • state – Variational state to be evolved.

  • hamiltonian – Hamiltonian operator for time evolution.

  • solver – The numerical solver for \(Sx = F\), default to pseudo-inverse.

property energy: Array | ndarray | bool | number | bool | int | float | complex | None#

Energy of the current step.

property VarE: Array | ndarray | bool | number | bool | int | float | complex | None#

Energy variance \(\left< (H - E)^2 \right>\) of the current step.

get_SF(samples: Samples) tuple[Array, Array]#

Compute \(S = \bar O^\dagger \bar O\) and \(F = \bar O^\dagger \bar \epsilon\) with the given samples. When the number of samples is large, this function will automatically switch to a more memory-efficient implementation.

solve_SF(Smat: Array, Fvec: Array) Array#

Solve the time evolution equation \(S \dot\theta = F\) for the parameter update, given the matrix \(S\) and vector \(F\) from get_SF.

get_step(samples: Samples | Array) Array#

Obtain the optimization step by solving the equation \(\bar O \dot \theta = \bar \epsilon\) for given samples.

get_Ebar(samples: Samples | Array) Array#

Compute \(\bar \epsilon\) of the gradient source for given samples.

get_Obar(samples: Samples | Array) Array#

Calculate \(\bar O = \frac{1}{\sqrt{N_s}}(\frac{1}{\psi} \frac{\partial \psi}{\partial \theta} - \left< \frac{1}{\psi} \frac{\partial \psi}{\partial \theta} \right>)\) for given samples.

property hamiltonian: Operator | None#

The Hamiltonian for the evolution, None when the gradient source doesn’t define it.

property holomorphic: bool#

Whether the state is holomorphic.

property imag_time: bool#

Whether to use imaginary-time evolution.

save(file: str | Path | BinaryIO) None#

Save the optimizer buffers to a file.

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_preconditioner keyword 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\).

property state: Variational#

Variational state to be optimized.

property vs_type: VS_TYPE#

The vs_type of the state, see VS_TYPE.