netket.sampler#

Inheritance diagram of netket.sampler, netket.sampler.rules

Abstract Classes#

Below you find a list of all abstract classes defined in this module, from which you can inherit if you want to define new hilbert spaces.

Sampler

Abstract base class for all samplers.

SamplerState

Base class holding the state of a sampler.

MetropolisSamplerState

State for a Metropolis sampler.

MetropolisRule

Base class for transition rules of Metropolis, such as Local, Exchange, Hamiltonian and several others.

List of Samplers#

This is a list of all available samplers. Please note that samplers with Numpy in their name are implemented in Numpy and not in pure jax, and they will convert from numpy<->jax at every sampling step the state. If you are using GPUs, this conversion can be very costly. On CPUs, while the conversion is cheap, the dispatch cost of jax is considerate for small systems.

In general those samplers, while they have the same asymptotic cost of Jax samplers, have a much higher overhead for small to moderate (for GPUs) system sizes.

This is because it is not possible to implement all transition rules in Jax.

ExactSampler

This sampler generates i.i.d.

MetropolisSampler

Metropolis-Hastings sampler for a Hilbert space according to a specific transition rule.

MetropolisSamplerNumpy

Metropolis-Hastings sampler for an Hilbert space according to a specific transition rule executed on CPU through Numpy.

ARDirectSampler

Direct sampler for autoregressive neural networks.

experimental.sampler.MetropolisPtSampler

Metropolis-Hastings with Parallel Tempering sampler.

This is a list of shorthands that allow to construct a MetropolisSampler with a corresponding rule.

MetropolisLocal(hilbert, **kwargs)

Sampler acting on one local degree of freedom.

MetropolisExchange(hilbert, *[, clusters, ...])

This sampler acts locally only on two local degree of freedom \(s_i\) and \(s_j\), and proposes a new state: \(s_1 \dots s^\prime_i \dots s^\prime_j \dots s_N\), where in general \(s^\prime_i \neq s_i\) and \(s^\prime_j \neq s_j\).

MetropolisHamiltonian(hilbert, hamiltonian, ...)

Sampling based on the off-diagonal elements of a Hamiltonian (or a generic Operator).

MetropolisGaussian(hilbert[, sigma])

This sampler acts on all particle positions simultaneously and proposes a new state according to a Gaussian distribution with width sigma.

MetropolisAdjustedLangevin(hilbert[, dt, ...])

This sampler acts on all particle positions simultaneously and takes a Langevin step [1]:

experimental.sampler.MetropolisLocalPt

Sampler acting on one local degree of freedom.

experimental.sampler.MetropolisExchangePt

This sampler acts locally only on two local degree of freedom \(s_i\) and \(s_j\), and proposes a new state: \(s_1 \dots s^\prime_i \dots s^\prime_j \dots s_N\), where in general \(s^\prime_i \neq s_i\) and \(s^\prime_j \neq s_j\).

Transition Rules#

Those are the transition rules that can be used with the Metropolis Sampler. Rules with Numpy in their name can only be used with netket.sampler.MetropolisSamplerNumpy.

rules.MetropolisRule

Base class for transition rules of Metropolis, such as Local, Exchange, Hamiltonian and several others.

rules.LocalRule

A transition rule acting on the local degree of freedom.

rules.CustomRuleNumpy

rules.ExchangeRule

A Rule exchanging the state on a random couple of sites, chosen from a list of possible couples (clusters).

rules.FixedRule

A transition rule relaxing and doing nothing.

rules.HamiltonianRule(operator)

Rule proposing moves according to the terms in an operator.

rules.HamiltonianRuleNumpy

Rule for Numpy sampler backend proposing moves according to the terms in an operator.

rules.GaussianRule

A transition rule acting on all particle positions at once.

rules.LangevinRule

A transition rule that uses Langevin dynamics [1] to update samples.

There are also a few additional rules that can be used to compose other rules together.

rules.TensorRule

A Metropolis sampling rule that can be used to combine different rules acting on different subspaces of the same tensor-hilbert space.

rules.MultipleRules

A Metropolis sampling rule that can be used to pick a rule from a list of rules with a given probability.

Internal State#

Those structure hold the state of the sampler.

SamplerState

Base class holding the state of a sampler.

MetropolisSamplerState

State for a Metropolis sampler.

Experimental#

They are experimental, meaning that we could change them at some point, and we actively seeking for feedback and opinions on their usage and APIs.

Particle-specific samplers#

The following samplers are for 2nd-quantisation fermionic hilbert spaces (netket.experimental.hilbert.SpinOrbitalFermions).

MetropolisParticleExchange

This sampler moves (or hops) a random particle to a different but random empty mode.

And the corresponding rules

rules.ParticleExchangeRule

Exchange rule for particles on a lattice.