quimb.experimental.belief_propagation.l2bp

Classes

oset

An ordered set which stores elements as the keys of dict (ordered as of

BeliefPropagationCommon

Common interfaces for belief propagation algorithms.

L2BP

Lazy (as in multiple uncontracted tensors per site) 2-norm (as in for

Functions

combine_local_contractions(tvals, mvals, backend[, ...])

create_lazy_community_edge_map(tn[, site_tags, ...])

For lazy BP algorithms, create the data structures describing the

contract_l2bp(tn[, site_tags, damping, update, ...])

Estimate the norm squared of tn using lazy belief propagation.

compress_l2bp(tn, max_bond[, cutoff, cutoff_mode, ...])

Compress tn using lazy belief propagation, producing a tensor

Module Contents

class quimb.experimental.belief_propagation.l2bp.oset(it=())

An ordered set which stores elements as the keys of dict (ordered as of python 3.6). ‘A few times’ slower than using a set directly for small sizes, but makes everything deterministic.

__slots__ = ('_d',)
classmethod _from_dict(d)
classmethod from_dict(d)

Public method makes sure to copy incoming dictionary.

copy()
__deepcopy__(memo)
add(k)
discard(k)
remove(k)
clear()
update(*others)
union(*others)
intersection_update(*others)
intersection(*others)
difference_update(*others)
difference(*others)
popleft()
popright()
pop
__eq__(other)

Return self==value.

__or__(other)
__ior__(other)
__and__(other)
__iand__(other)
__sub__(other)
__isub__(other)
__len__()
__iter__()
__contains__(x)
__repr__()

Return repr(self).

class quimb.experimental.belief_propagation.l2bp.BeliefPropagationCommon

Common interfaces for belief propagation algorithms.

Parameters:
  • max_iterations (int, optional) – The maximum number of iterations to perform.

  • tol (float, optional) – The convergence tolerance for messages.

  • progbar (bool, optional) – Whether to show a progress bar.

run(max_iterations=1000, tol=5e-06, info=None, progbar=False)
quimb.experimental.belief_propagation.l2bp.combine_local_contractions(tvals, mvals, backend, strip_exponent=False, check_for_zero=True)
quimb.experimental.belief_propagation.l2bp.create_lazy_community_edge_map(tn, site_tags=None, rank_simplify=True)

For lazy BP algorithms, create the data structures describing the effective graph of the lazily grouped ‘sites’ given by site_tags.

class quimb.experimental.belief_propagation.l2bp.L2BP(tn, site_tags=None, damping=0.0, update='sequential', local_convergence=True, optimize='auto-hq', **contract_opts)

Bases: quimb.experimental.belief_propagation.bp_common.BeliefPropagationCommon

Lazy (as in multiple uncontracted tensors per site) 2-norm (as in for wavefunctions and operators) belief propagation.

Parameters:
  • tn (TensorNetwork) – The tensor network to form the 2-norm of and run BP on.

  • site_tags (sequence of str, optional) – The tags identifying the sites in tn, each tag forms a region, which should not overlap. If the tensor network is structured, then these are inferred automatically.

  • damping (float, optional) – The damping parameter to use, defaults to no damping.

  • update ({'parallel', 'sequential'}, optional) – Whether to update all messages in parallel or sequentially.

  • local_convergence (bool, optional) – Whether to allow messages to locally converge - i.e. if all their input messages have converged then stop updating them.

  • optimize (str or PathOptimizer, optional) – The path optimizer to use when contracting the messages.

  • contract_opts – Other options supplied to cotengra.array_contract.

iterate(tol=5e-06)
normalize_messages()

Normalize all messages such that for each bond <m_i|m_j> = 1 and <m_i|m_i> = <m_j|m_j> (but in general != 1).

contract(strip_exponent=False)

Estimate the contraction of the norm squared using the current messages.

partial_trace(site, normalized=True, optimize='auto-hq')
compress(tn, max_bond=None, cutoff=5e-06, cutoff_mode='rsum2', renorm=0, lazy=False)

Compress the state tn, assumed to matched this L2BP instance, using the messages stored.

quimb.experimental.belief_propagation.l2bp.contract_l2bp(tn, site_tags=None, damping=0.0, update='sequential', local_convergence=True, optimize='auto-hq', max_iterations=1000, tol=5e-06, strip_exponent=False, info=None, progbar=False, **contract_opts)

Estimate the norm squared of tn using lazy belief propagation.

Parameters:
  • tn (TensorNetwork) – The tensor network to estimate the norm squared of.

  • site_tags (sequence of str, optional) – The tags identifying the sites in tn, each tag forms a region.

  • damping (float, optional) – The damping parameter to use, defaults to no damping.

  • update ({'parallel', 'sequential'}, optional) – Whether to update all messages in parallel or sequentially.

  • local_convergence (bool, optional) – Whether to allow messages to locally converge - i.e. if all their input messages have converged then stop updating them.

  • optimize (str or PathOptimizer, optional) – The contraction strategy to use.

  • max_iterations (int, optional) – The maximum number of iterations to perform.

  • tol (float, optional) – The convergence tolerance for messages.

  • strip_exponent (bool, optional) – Whether to strip the exponent from the final result. If True then the returned result is (mantissa, exponent).

  • info (dict, optional) – If specified, update this dictionary with information about the belief propagation run.

  • progbar (bool, optional) – Whether to show a progress bar.

  • contract_opts – Other options supplied to cotengra.array_contract.

quimb.experimental.belief_propagation.l2bp.compress_l2bp(tn, max_bond, cutoff=0.0, cutoff_mode='rsum2', max_iterations=1000, tol=5e-06, site_tags=None, damping=0.0, update='sequential', local_convergence=True, optimize='auto-hq', lazy=False, inplace=False, info=None, progbar=False, **contract_opts)

Compress tn using lazy belief propagation, producing a tensor network with a single tensor per site.

Parameters:
  • tn (TensorNetwork) – The tensor network to form the 2-norm of, run BP on and then compress.

  • max_bond (int) – The maximum bond dimension to compress to.

  • cutoff (float, optional) – The cutoff to use when compressing.

  • cutoff_mode (int, optional) – The cutoff mode to use when compressing.

  • max_iterations (int, optional) – The maximum number of iterations to perform.

  • tol (float, optional) – The convergence tolerance for messages.

  • site_tags (sequence of str, optional) – The tags identifying the sites in tn, each tag forms a region. If the tensor network is structured, then these are inferred automatically.

  • damping (float, optional) – The damping parameter to use, defaults to no damping.

  • update ({'parallel', 'sequential'}, optional) – Whether to update all messages in parallel or sequentially.

  • local_convergence (bool, optional) – Whether to allow messages to locally converge - i.e. if all their input messages have converged then stop updating them.

  • optimize (str or PathOptimizer, optional) – The path optimizer to use when contracting the messages.

  • lazy (bool, optional) – Whether to perform the compression lazily, i.e. to leave the computed compression projectors uncontracted.

  • inplace (bool, optional) – Whether to perform the compression inplace.

  • info (dict, optional) – If specified, update this dictionary with information about the belief propagation run.

  • progbar (bool, optional) – Whether to show a progress bar.

  • contract_opts – Other options supplied to cotengra.array_contract.

Return type:

TensorNetwork