quimb.experimental.tnvmc

Tools for generic VMC optimization of tensor networks.

Attributes

Classes

NoContext

A convenience context manager that does nothing.

MovingStatistics

Keep track of the windowed mean and estimated variance of a stream of

DenseSampler

Sampler that explicitly constructs the full probability distribution.

DirectTNSampler

ClusterSampler

ExchangeSampler

HamiltonianSampler

MetropolisHastingsSampler

ComposePartial

AmplitudeFactory

GradientAccumulator

SGD

SignDescent

RandomSign

Adam

StochasticReconfigureGradients

SR

SRADAM

TNVMC

Functions

sample_bitstring_from_prob_ndarray(p, rng)

shuffled(it)

Return a copy of it in random order.

compute_amplitude(tn, config, chi, optimize)

compute_amplitudes(tn, configs, chi, optimize)

compute_local_energy(ham, tn, config, chi, optimize)

draw_config(edges, config)

auto_share_multicall(func, arrays, configs)

Call the function func, which should be an array

get_compose_partial(f, f_args, f_kwargs, g)

fuse_unary_ops_(Z)

Module Contents

quimb.experimental.tnvmc.sample_bitstring_from_prob_ndarray(p, rng)
quimb.experimental.tnvmc.shuffled(it)

Return a copy of it in random order.

class quimb.experimental.tnvmc.NoContext

A convenience context manager that does nothing.

__enter__()
__exit__(*_, **__)
class quimb.experimental.tnvmc.MovingStatistics(window_size)

Keep track of the windowed mean and estimated variance of a stream of values on the fly.

window_size
xs = []
vs = []
_xsum = 0.0
_vsum = 0.0
update(x)
property mean
property var
property std
property err
class quimb.experimental.tnvmc.DenseSampler(psi=None, seed=None, **contract_opts)

Sampler that explicitly constructs the full probability distribution. Useful for debugging small problems.

contract_opts
rng
_set_psi(psi)
sample()
update(**kwargs)
class quimb.experimental.tnvmc.DirectTNSampler(tn, sweeps=1, max_group_size=8, chi=None, optimize=None, optimize_share_path=False, seed=None, track=False)
Parameters:
  • tn (TensorNetwork) – The tensor network to sample from.

  • sweeps (int, optional) – The number of sweeps to perform.

  • max_group_size (int, optional) – The maximum number of sites to include in a single marginal.

  • chi (int, optional) – The maximum bond dimension to use for compressed contraction.

  • optimize (PathOptimizer, optional) – The path optimizer to use.

  • optimize_share_path (bool, optional) – If True, a single path will be used for all contractions regardless of which marginal (i.e. which indices are open) is begin computed.

tn
ind2site
tid2ind
chi = None
sweeps = 1
max_group_size = 8
optimize = None
optimize_share_path = False
groups = None
tree = None
path = None
rng
track = False
plot()
calc_groups(**kwargs)

Calculate how to group the sites into marginals.

get_groups()
calc_path()
get_path()
get_optimize()
contract(tn, output_inds)
sample()
quimb.experimental.tnvmc.compute_amplitude(tn, config, chi, optimize)
quimb.experimental.tnvmc.compute_amplitudes(tn, configs, chi, optimize)
quimb.experimental.tnvmc.compute_local_energy(ham, tn, config, chi, optimize)
quimb.experimental.tnvmc.draw_config(edges, config)
class quimb.experimental.tnvmc.ClusterSampler(psi=None, max_distance=1, use_gauges=True, seed=None, contract_opts=None)
rng
use_gauges = True
max_distance = 1
contract_opts
_set_psi(psi)
sample()
candidate
accept(config)
update(**kwargs)
class quimb.experimental.tnvmc.ExchangeSampler(edges, seed=None)
edges
Ne
sites
N
rng
config
candidate()
accept(config)
sample()
update(**_)
class quimb.experimental.tnvmc.HamiltonianSampler(ham, seed=None)
ham
rng
N
config
candidate()
accept(config)
sample()
update(**_)
class quimb.experimental.tnvmc.MetropolisHastingsSampler(sub_sampler, amplitude_factory=None, initial=None, burn_in=0, seed=None, track=False)
sub_sampler
seed = None
rng
accepted = 0
total = 0
burn_in = 0
track = False
property acceptance_ratio
sample()
update(**kwargs)
plot()
quimb.experimental.tnvmc.auto_share_multicall(func, arrays, configs)

Call the function func, which should be an array function making use of autoray dispatched calls, multiple times, automatically reusing shared intermediates.

class quimb.experimental.tnvmc.ComposePartial(f, f_args, f_kwargs, g)
__slots__ = ('f', 'f_args', 'f_kwargs', 'g')
f
f_args
f_kwargs
g
__call__(*args, **kwargs)
quimb.experimental.tnvmc._partial_compose_cache
quimb.experimental.tnvmc.get_compose_partial(f, f_args, f_kwargs, g)
quimb.experimental.tnvmc.fuse_unary_ops_(Z)
class quimb.experimental.tnvmc.AmplitudeFactory(psi=None, contract_fn=None, maxsize=2**20, autojit_opts=(), **contract_opts)
contract_fn = None
contract_opts
autojit_opts
store
hits = 0
queries = 0
_set_psi(psi)
compute_single(config)

Compute the amplitude of config, making use of autojit.

compute_multi(configs)

Compute the amplitudes corresponding to the sequence configs, making use of shared intermediates.

amplitude(config)

Get the amplitude of config, either from the cache or by computing it.

amplitudes(configs)
prob(config)

Calculate the probability of a configuration.

clear()
__contains__(config)
__setitem__(config, c)
__getitem__(config)
__repr__()
class quimb.experimental.tnvmc.GradientAccumulator
_grads_logpsi = None
_grads_energy = None
_batch_energy = None
_num_samples = 0
_init_storage(grads)
update(grads_logpsi_sample, local_energy)
extract_grads_energy()
class quimb.experimental.tnvmc.SGD(learning_rate=0.01)

Bases: GradientAccumulator

learning_rate = 0.01
transform_gradients()
class quimb.experimental.tnvmc.SignDescent(learning_rate=0.01)

Bases: GradientAccumulator

learning_rate = 0.01
transform_gradients()
class quimb.experimental.tnvmc.RandomSign(learning_rate=0.01)

Bases: GradientAccumulator

learning_rate = 0.01
transform_gradients()
class quimb.experimental.tnvmc.Adam(learning_rate=0.01, beta1=0.9, beta2=0.999, eps=1e-08)

Bases: GradientAccumulator

learning_rate = 0.01
beta1 = 0.9
beta2 = 0.999
eps = 1e-08
_num_its = 0
_ms = None
_vs = None
transform_gradients()
class quimb.experimental.tnvmc.StochasticReconfigureGradients(delta=1e-05)
delta = 1e-05
vectorizer = None
gs = []
update(grads_logpsi_sample, local_energy)
extract_grads_energy()
class quimb.experimental.tnvmc.SR(learning_rate=0.05, delta=1e-05)

Bases: SGD, StochasticReconfigureGradients

class quimb.experimental.tnvmc.SRADAM(learning_rate=0.01, beta1=0.9, beta2=0.999, eps=1e-08, delta=1e-05)

Bases: Adam, StochasticReconfigureGradients

class quimb.experimental.tnvmc.TNVMC(psi, ham, sampler, conditioner='auto', learning_rate=0.01, optimizer='adam', optimizer_opts=None, track_window_size=1000, **contract_opts)
psi
ham
sampler
optimizer
contract_opts
amplitude_factory
moving_stats
local_energies
energies
energy_errors
num_tensors
nsites
_progbar = None
_compute_log_gradients_torch(config)
_compute_local_energy(config)
_run(steps, batchsize)
run(total=10000, batchsize=100, progbar=True)
measure(max_samples=10000, rtol=0.0001, progbar=True)
plot(figsize=(12, 6), yrange_quantile=(0.01, 0.99), zoom='auto', hlines=())