quimb.experimental.belief_propagation.d2bp

Classes

D2BP

Dense (as in one tensor per site) 2-norm (as in for wavefunctions and

Functions

contract_d2bp(tn[, messages, output_inds, optimize, ...])

Estimate the norm squared of tn using dense 2-norm belief

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

Compress the tensor network tn using dense 2-norm belief

sample_d2bp(tn[, output_inds, messages, ...])

Sample a configuration from tn using dense 2-norm belief

Module Contents

class quimb.experimental.belief_propagation.d2bp.D2BP(tn, messages=None, output_inds=None, optimize='auto-hq', damping=0.0, update='sequential', local_convergence=True, **contract_opts)

Bases: quimb.experimental.belief_propagation.bp_common.BeliefPropagationCommon

Dense (as in one tensor per site) 2-norm (as in for wavefunctions and operators) belief propagation. Allows messages reuse. This version assumes no hyper indices (i.e. a standard PEPS like tensor network).

Potential use cases for D2BP and a PEPS like tensor network are:

  • globally compressing it from bond dimension D to D'

  • eagerly applying gates and locally compressing back to D

  • sampling configurations

  • estimating the norm of the tensor network

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

  • messages (dict[(str, int), array_like], optional) – The initial messages to use, effectively defaults to all ones if not specified.

  • output_inds (set[str], optional) – The indices to consider as output (dangling) indices of the tn. Computed automatically if not specified.

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

  • damping (float, optional) – The damping factor to use, 0.0 means 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.

  • contract_opts – Other options supplied to cotengra.array_contract.

tn
contract_opts
damping
local_convergence
update
backend
_abs
_sum
_normalize
_distance
touch_map
touched
exprs
update_touched_from_tids(*tids)

Specify that the messages for the given tids have changed.

update_touched_from_tags(tags, which='any')

Specify that the messages for the messages touching tags have changed.

update_touched_from_inds(inds, which='any')

Specify that the messages for the messages touching inds have changed.

iterate(tol=5e-06)

Perform a single iteration of dense 2-norm belief propagation.

compute_marginal(ind)

Compute the marginal for the index ind.

contract(strip_exponent=False)

Estimate the total contraction, i.e. the 2-norm.

Parameters:

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

Return type:

scalar or (scalar, float)

compress(max_bond, cutoff=0.0, cutoff_mode=4, renorm=0, inplace=False)

Compress the initial tensor network using the current messages.

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

Estimate the norm squared of tn using dense 2-norm belief propagation.

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

  • messages (dict[(str, int), array_like], optional) – The initial messages to use, effectively defaults to all ones if not specified.

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

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

  • output_inds (set[str], optional) – The indices to consider as output (dangling) indices of the tn. Computed automatically if not specified.

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

  • 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.

  • 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.

Return type:

scalar or (scalar, float)

quimb.experimental.belief_propagation.d2bp.compress_d2bp(tn, max_bond, cutoff=0.0, cutoff_mode='rsum2', renorm=0, messages=None, output_inds=None, optimize='auto-hq', damping=0.0, update='sequential', local_convergence=True, max_iterations=1000, tol=5e-06, inplace=False, info=None, progbar=False, **contract_opts)

Compress the tensor network tn using dense 2-norm belief propagation.

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.

  • messages (dict[(str, int), array_like], optional) – The initial messages to use, effectively defaults to all ones if not specified.

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

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

  • output_inds (set[str], optional) – The indices to consider as output (dangling) indices of the tn. Computed automatically if not specified.

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

  • 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.

  • 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

quimb.experimental.belief_propagation.d2bp.sample_d2bp(tn, output_inds=None, messages=None, max_iterations=100, tol=0.01, bias=None, seed=None, local_convergence=True, progbar=False, **contract_opts)

Sample a configuration from tn using dense 2-norm belief propagation.

Parameters:
  • tn (TensorNetwork) – The tensor network to sample from.

  • output_inds (set[str], optional) – Which indices to sample.

  • messages (dict[(str, int), array_like], optional) – The initial messages to use, effectively defaults to all ones if not specified.

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

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

  • bias (float, optional) – Bias the sampling towards more locally likely bit-strings. This is done by raising the probability of each bit-string to this power.

  • seed (int, optional) – A random seed for reproducibility.

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

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

  • contract_opts – Other options supplied to cotengra.array_contract.

Returns:

  • config (dict[str, int]) – The sampled configuration, a mapping of output indices to values.

  • tn_config (TensorNetwork) – The tensor network with the sampled configuration applied.

  • omega (float) – The BP probability of the sampled configuration.