quimb.tensor.tensor_2d_tebd

Tools for performing TEBD like algorithms on a 2D lattice.

Classes

LocalHam2D

A 2D Hamiltonian represented as local terms. This combines all two site

TEBD2D

Generic class for performing two dimensional time evolving block

SimpleUpdate

A simple subclass of TEBD2D that overrides two key methods in

FullUpdate

Implements the 'Full Update' version of 2D imaginary time evolution,

Functions

conditioner(tn[, value, sweeps, balance_bonds])

gate_full_update_als(ket, env, bra, G, where, ...[, ...])

gate_full_update_autodiff_fidelity(ket, env, bra, G, ...)

get_default_full_update_fit_opts()

The default options for the full update gate fitting procedure.

parse_specific_gate_opts(strategy, fit_opts)

Parse the options from fit_opts which are relevant for strategy.

Module Contents

class quimb.tensor.tensor_2d_tebd.LocalHam2D(Lx, Ly, H2, H1=None, cyclic=False)[source]

Bases: quimb.tensor.tensor_arbgeom_tebd.LocalHamGen

A 2D Hamiltonian represented as local terms. This combines all two site and one site terms into a single interaction per lattice pair, and caches operations on the terms such as getting their exponential.

Parameters:
  • Lx (int) – The number of rows.

  • Ly (int) – The number of columns.

  • H2 (array_like or dict[tuple[tuple[int]], array_like]) – The two site term(s). If a single array is given, assume to be the default interaction for all nearest neighbours. If a dict is supplied, the keys should represent specific pairs of coordinates like ((ia, ja), (ib, jb)) with the values the array representing the interaction for that pair. A default term for all remaining nearest neighbours interactions can still be supplied with the key None.

  • H1 (array_like or dict[tuple[int], array_like], optional) – The one site term(s). If a single array is given, assume to be the default onsite term for all terms. If a dict is supplied, the keys should represent specific coordinates like (i, j) with the values the array representing the local term for that site. A default term for all remaining sites can still be supplied with the key None.

terms

The total effective local term for each interaction (with single site terms appropriately absorbed). Each key is a pair of coordinates ija, ijb with ija < ijb.

Type:

dict[tuple[tuple[int]], array_like]

Lx
Ly
property nsites

The number of sites in the system.

__repr__()[source]
draw(ordering='sort', show_norm=True, figsize=None, fontsize=8, legend=True, ax=None, **kwargs)[source]

Plot this Hamiltonian as a network.

Parameters:
  • ordering ({'sort', None, 'random'}, optional) – An ordering of the termns, or an argument to be supplied to quimb.tensor.tensor_2d_tebd.LocalHam2D.get_auto_ordering() to generate this automatically.

  • show_norm (bool, optional) – Show the norm of each term as edge labels.

  • figsize (None or tuple[int], optional) – Size of the figure, defaults to size of Hamiltonian.

  • fontsize (int, optional) – Font size for norm labels.

  • legend (bool, optional) – Whether to show the legend of which terms are in which group.

  • ax (None or matplotlib.Axes, optional) – Add to a existing set of axes.

graph[source]
class quimb.tensor.tensor_2d_tebd.TEBD2D(psi0, ham, tau=0.01, D=None, chi=None, imag=True, gate_opts=None, ordering=None, second_order_reflect=False, compute_energy_every=None, compute_energy_final=True, compute_energy_opts=None, compute_energy_fn=None, compute_energy_per_site=False, callback=None, keep_best=False, progbar=True)[source]

Bases: quimb.tensor.tensor_arbgeom_tebd.TEBDGen

Generic class for performing two dimensional time evolving block decimation, i.e. applying the exponential of a Hamiltonian using a product formula that involves applying local exponentiated gates only.

Parameters:
  • psi0 (TensorNetwork2DVector) – The initial state.

  • ham (LocalHam2D) – The Hamtiltonian consisting of local terms.

  • tau (float, optional) – The default local exponent, if considered as time real values here imply imaginary time.

  • max_bond ({'psi0', int, None}, optional) – The maximum bond dimension to keep when applying each gate.

  • gate_opts (dict, optional) – Supplied to quimb.tensor.tensor_2d.TensorNetwork2DVector.gate(), in addition to max_bond. By default contract is set to ‘reduce-split’ and cutoff is set to 0.0.

  • ordering (str, tuple[tuple[int]], callable, optional) – How to order the terms, if a string is given then use this as the strategy given to get_auto_ordering(). An explicit list of coordinate pairs can also be given. The default is to greedily form an ‘edge coloring’ based on the sorted list of Hamiltonian pair coordinates. If a callable is supplied it will be used to generate the ordering before each sweep.

  • second_order_reflect (bool, optional) – If True, then apply each layer of gates in ordering forward with half the time step, then the same with reverse order.

  • compute_energy_every (None or int, optional) – How often to compute and record the energy. If a positive integer ‘n’, the energy is computed before every nth sweep (i.e. including before the zeroth).

  • compute_energy_final (bool, optional) – Whether to compute and record the energy at the end of the sweeps regardless of the value of compute_energy_every. If you start sweeping again then this final energy is the same as the zeroth of the next set of sweeps and won’t be recomputed.

  • compute_energy_opts (dict, optional) – Supplied to compute_local_expectation(). By default max_bond is set to max(8, D**2) where D is the maximum bond to use for applying the gate, cutoff is set to 0.0 and normalized is set to True.

  • compute_energy_fn (callable, optional) – Supply your own function to compute the energy, it should take the TEBD2D object as its only argument.

  • callback (callable, optional) – A custom callback to run after every sweep, it should take the TEBD2D object as its only argument. If it returns any value that boolean evaluates to True then terminal the evolution.

  • progbar (boolean, optional) – Whether to show a live progress bar during the evolution.

  • kwargs – Extra options for the specific TEBD2D subclass.

state

The current state.

Type:

TensorNetwork2DVector

ham

The Hamiltonian being used to evolve.

Type:

LocalHam2D

energy

The current of the current state, this will trigger a computation if the energy at this iteration hasn’t been computed yet.

Type:

float

energies

The energies that have been computed, if any.

Type:

list[float]

its

The corresponding sequence of iteration numbers that energies have been computed at.

Type:

list[int]

taus

The corresponding sequence of time steps that energies have been computed at.

Type:

list[float]

best

If keep_best was set then the best recorded energy and the corresponding state that was computed - keys 'energy' and 'state' respectively.

Type:

dict

compute_energy()[source]

Compute and return the energy of the current state.

property chi
__repr__()[source]
quimb.tensor.tensor_2d_tebd.conditioner(tn, value=None, sweeps=2, balance_bonds=True)[source]
class quimb.tensor.tensor_2d_tebd.SimpleUpdate(psi0, ham, tau=0.01, D=None, chi=None, gauge_renorm=True, gauge_smudge=1e-06, condition_tensors=True, condition_balance_bonds=True, long_range_use_swaps=False, long_range_path_sequence='random', imag=True, gate_opts=None, ordering=None, second_order_reflect=False, compute_energy_every=None, compute_energy_final=True, compute_energy_opts=None, compute_energy_fn=None, compute_energy_per_site=False, callback=None, keep_best=False, progbar=True)[source]

Bases: TEBD2D

A simple subclass of TEBD2D that overrides two key methods in order to keep ‘diagonal gauges’ living on the bonds of a PEPS. The gauges are stored separately from the main PEPS in the gauges attribute. Before and after a gate is applied they are absorbed and then extracted. When accessing the state attribute they are automatically inserted or you can call get_state(absorb_gauges=False) to lazily add them as hyperedge weights only. Reference: https://arxiv.org/abs/0806.3719.

Parameters:
  • psi0 (TensorNetwork2DVector) – The initial state.

  • ham (LocalHam2D) – The Hamtiltonian consisting of local terms.

  • tau (float, optional) – The default local exponent, if considered as time real values here imply imaginary time.

  • max_bond ({'psi0', int, None}, optional) – The maximum bond dimension to keep when applying each gate.

  • gate_opts (dict, optional) – Supplied to quimb.tensor.tensor_2d.TensorNetwork2DVector.gate(), in addition to max_bond. By default contract is set to ‘reduce-split’ and cutoff is set to 0.0.

  • ordering (str, tuple[tuple[int]], callable, optional) – How to order the terms, if a string is given then use this as the strategy given to get_auto_ordering(). An explicit list of coordinate pairs can also be given. The default is to greedily form an ‘edge coloring’ based on the sorted list of Hamiltonian pair coordinates. If a callable is supplied it will be used to generate the ordering before each sweep.

  • second_order_reflect (bool, optional) – If True, then apply each layer of gates in ordering forward with half the time step, then the same with reverse order.

  • compute_energy_every (None or int, optional) – How often to compute and record the energy. If a positive integer ‘n’, the energy is computed before every nth sweep (i.e. including before the zeroth).

  • compute_energy_final (bool, optional) – Whether to compute and record the energy at the end of the sweeps regardless of the value of compute_energy_every. If you start sweeping again then this final energy is the same as the zeroth of the next set of sweeps and won’t be recomputed.

  • compute_energy_opts (dict, optional) – Supplied to compute_local_expectation(). By default max_bond is set to max(8, D**2) where D is the maximum bond to use for applying the gate, cutoff is set to 0.0 and normalized is set to True.

  • compute_energy_fn (callable, optional) – Supply your own function to compute the energy, it should take the TEBD2D object as its only argument.

  • callback (callable, optional) – A custom callback to run after every sweep, it should take the TEBD2D object as its only argument. If it returns any value that boolean evaluates to True then terminal the evolution.

  • progbar (boolean, optional) – Whether to show a live progress bar during the evolution.

  • gauge_renorm (bool, optional) – Whether to actively renormalize the singular value gauges.

  • gauge_smudge (float, optional) – A small offset to use when applying the guage and its inverse to avoid numerical problems.

  • condition_tensors (bool, optional) – Whether to actively equalize tensor norms for numerical stability.

  • condition_balance_bonds (bool, optional) – If and when equalizing tensor norms, whether to also balance bonds as an additional conditioning.

  • long_range_use_swaps (bool, optional) – If there are long range terms, whether to use swap gates to apply the terms. If False, a long range blob tensor (which won’t scale well for long distances) is formed instead.

  • long_range_path_sequence (str or callable, optional) – If there are long range terms how to generate the path between the two coordinates. If callable, should take the two coordinates and return a sequence of coordinates that links them, else passed to gen_long_range_swap_path.

state

The current state.

Type:

TensorNetwork2DVector

ham

The Hamiltonian being used to evolve.

Type:

LocalHam2D

energy

The current of the current state, this will trigger a computation if the energy at this iteration hasn’t been computed yet.

Type:

float

energies

The energies that have been computed, if any.

Type:

list[float]

its

The corresponding sequence of iteration numbers that energies have been computed at.

Type:

list[int]

taus

The corresponding sequence of time steps that energies have been computed at.

Type:

list[float]

best

If keep_best was set then the best recorded energy and the corresponding state that was computed - keys 'energy' and 'state' respectively.

Type:

dict

gauge_renorm = True
gauge_smudge = 1e-06
condition_tensors = True
condition_balance_bonds = True
long_range_path_sequence = 'random'
_initialize_gauges()[source]

Create unit singular values, stored as tensors.

property gauges

The dictionary of bond pair coordinates to Tensors describing the weights (t = gauges[pair]; t.data) and index (t = gauges[pair]; t.inds[0]) of all the gauges.

property long_range_use_swaps
gate(U, where)[source]

Like TEBD2D.gate but absorb and extract the relevant gauges before and after each gate application.

get_state(absorb_gauges=True)[source]

Return the state, with the diagonal bond gauges either absorbed equally into the tensors on either side of them (absorb_gauges=True, the default), or left lazily represented in the tensor network with hyperedges (absorb_gauges=False).

set_state(psi)[source]

Set the wavefunction state, this resets the environment gauges to unity.

quimb.tensor.tensor_2d_tebd.gate_full_update_als(ket, env, bra, G, where, tags_plq, steps, tol, max_bond, optimize='auto-hq', solver='solve', dense=True, enforce_pos=False, pos_smudge=1e-06, init_simple_guess=True, condition_tensors=True, condition_maintain_norms=True, condition_balance_bonds=True)[source]
quimb.tensor.tensor_2d_tebd.gate_full_update_autodiff_fidelity(ket, env, bra, G, where, tags_plq, steps, tol, max_bond, optimize='auto-hq', autodiff_backend='autograd', autodiff_optimizer='L-BFGS-B', init_simple_guess=True, condition_tensors=True, condition_maintain_norms=True, condition_balance_bonds=True, **kwargs)[source]
quimb.tensor.tensor_2d_tebd.get_default_full_update_fit_opts()[source]

The default options for the full update gate fitting procedure.

quimb.tensor.tensor_2d_tebd.parse_specific_gate_opts(strategy, fit_opts)[source]

Parse the options from fit_opts which are relevant for strategy.

class quimb.tensor.tensor_2d_tebd.FullUpdate(psi0, ham, tau=0.01, D=None, chi=None, fit_strategy='als', fit_opts=None, compute_envs_every=1, pre_normalize=True, condition_tensors=True, condition_balance_bonds=True, contract_optimize='auto-hq', imag=True, gate_opts=None, ordering=None, second_order_reflect=False, compute_energy_every=None, compute_energy_final=True, compute_energy_opts=None, compute_energy_fn=None, compute_energy_per_site=False, callback=None, keep_best=False, progbar=True)[source]

Bases: TEBD2D

Implements the ‘Full Update’ version of 2D imaginary time evolution, where each application of a gate is fitted to the current tensors using a boundary contracted environment.

Parameters:
  • psi0 (TensorNetwork2DVector) – The initial state.

  • ham (LocalHam2D) – The Hamtiltonian consisting of local terms.

  • tau (float, optional) – The default local exponent, if considered as time real values here imply imaginary time.

  • max_bond ({'psi0', int, None}, optional) – The maximum bond dimension to keep when applying each gate.

  • gate_opts (dict, optional) – Supplied to quimb.tensor.tensor_2d.TensorNetwork2DVector.gate(), in addition to max_bond. By default contract is set to ‘reduce-split’ and cutoff is set to 0.0.

  • ordering (str, tuple[tuple[int]], callable, optional) – How to order the terms, if a string is given then use this as the strategy given to get_auto_ordering(). An explicit list of coordinate pairs can also be given. The default is to greedily form an ‘edge coloring’ based on the sorted list of Hamiltonian pair coordinates. If a callable is supplied it will be used to generate the ordering before each sweep.

  • second_order_reflect (bool, optional) – If True, then apply each layer of gates in ordering forward with half the time step, then the same with reverse order.

  • compute_energy_every (None or int, optional) – How often to compute and record the energy. If a positive integer ‘n’, the energy is computed before every nth sweep (i.e. including before the zeroth).

  • compute_energy_final (bool, optional) – Whether to compute and record the energy at the end of the sweeps regardless of the value of compute_energy_every. If you start sweeping again then this final energy is the same as the zeroth of the next set of sweeps and won’t be recomputed.

  • compute_energy_opts (dict, optional) – Supplied to compute_local_expectation(). By default max_bond is set to max(8, D**2) where D is the maximum bond to use for applying the gate, cutoff is set to 0.0 and normalized is set to True.

  • compute_energy_fn (callable, optional) – Supply your own function to compute the energy, it should take the TEBD2D object as its only argument.

  • callback (callable, optional) – A custom callback to run after every sweep, it should take the TEBD2D object as its only argument. If it returns any value that boolean evaluates to True then terminal the evolution.

  • progbar (boolean, optional) – Whether to show a live progress bar during the evolution.

  • fit_strategy ({'als', 'autodiff-fidelity'}, optional) –

    Core method used to fit the gate application.

    • 'als': alternating least squares

    • 'autodiff-fidelity': local fidelity using autodiff

  • fit_opts (dict, optional) – Advanced options for the gate application fitting functions. Defaults are inserted and can be accessed via the .fit_opts attribute.

  • compute_envs_every ({'term', 'group', 'sweep', int}, optional) –

    How often to recompute the environments used to the fit the gate application:

    • 'term': every gate

    • 'group': every set of commuting gates (the default)

    • 'sweep': every total sweep

    • int: every x number of total sweeps

  • pre_normalize (bool, optional) – Actively renormalize the state using the computed environments.

  • condition_tensors (bool, optional) – Whether to actively equalize tensor norms for numerical stability.

  • condition_balance_bonds (bool, optional) – If and when equalizing tensor norms, whether to also balance bonds as an additional conditioning.

  • contract_optimize (str, optional) – Contraction path optimizer to use for gate + env + sites contractions.

state

The current state.

Type:

TensorNetwork2DVector

ham

The Hamiltonian being used to evolve.

Type:

LocalHam2D

energy

The current of the current state, this will trigger a computation if the energy at this iteration hasn’t been computed yet.

Type:

float

energies

The energies that have been computed, if any.

Type:

list[float]

its

The corresponding sequence of iteration numbers that energies have been computed at.

Type:

list[int]

taus

The corresponding sequence of time steps that energies have been computed at.

Type:

list[float]

best

If keep_best was set then the best recorded energy and the corresponding state that was computed - keys 'energy' and 'state' respectively.

Type:

dict

fit_opts

Detailed options for fitting the applied gate.

Type:

dict

property fit_strategy
fit_opts
pre_normalize = True
contract_optimize = ''
condition_tensors = True
condition_balance_bonds = True
property compute_envs_every
set_state(psi)[source]

The default method for setting the current state - simply a copy. Subclasses can override this to perform additional transformations.

_maybe_compute_plaquette_envs(force=False)[source]

Compute and store the plaquette environments for all local terms.

presweep(i)[source]

Full update presweep - compute envs and inject gate options.

compute_energy()[source]

Full update compute energy - use the (likely) already calculated plaquette environments.

gate(G, where)[source]

Apply the gate G at sites where, using a fitting method that takes into account the current environment.