netket.vqs.mc.kernels_packed.local_value_kernel_jax_packed#
- netket.vqs.mc.kernels_packed.local_value_kernel_jax_packed(logpsi, pars, σ, O, *, chunk_size=None, min_chunk_size=None, conn_chunk_size=None)[source]#
local_value kernel for MCState and jax-compatible operators that evaluates \(\log\psi\) only on the connected configurations \(x' \neq x\).
Warning
This function is experimental: it is public, but it can change in a minor release of NetKet, with a note in the changelog.
MCStateuses it inexpectandexpect_and_gradif the experimental flagNETKET_EXPERIMENTAL_PACKED_KERNELis set (off by default), for instance withnk.config.netket_experimental_packed_kernel = True. It can also be called explicitly, with the same arguments aslocal_value_kernel_jax(), for example>>> import netket as nk >>> from netket.vqs.mc.kernels_packed import local_value_kernel_jax_packed >>> hi = nk.hilbert.Spin(0.5, 8) >>> H = nk.operator.IsingJax(hi, nk.graph.Chain(8), h=1.0) >>> sampler = nk.sampler.MetropolisLocal(hi) >>> vstate = nk.vqs.MCState(sampler, nk.models.RBM(), n_samples=64) >>> σ = vstate.samples.reshape(-1, hi.size) >>> eloc = local_value_kernel_jax_packed( ... vstate._apply_fun, vstate.variables, σ, H, chunk_size=4096 ... ) >>> eloc.shape (64,)
local_value_kernel_jax()evaluates the network on all the configurations returned byget_conn_padded(), including the diagonal \(x' = x\) and the padding. This kernel skips them, and evaluates the other ones withnetket.jax.apply_packed(), which never recompiles when their number changes. This is faster for operators with many zero matrix elements, such as the Heisenberg and Hubbard models. The result agrees withlocal_value_kernel_jax()up to rounding, and is deterministic.The kernel is differentiable.
- Parameters:
logpsi (
Callable) – the log-amplitude function.pars (
Any) – the variables of the model.σ (
Union[ndarray,Array]) – the samples, of shape(n_samples, hilbert.size).O (
DiscreteJaxOperator) – the operator.chunk_size (
int|None) – the number of configurations on which the network is evaluated at once: every call oflogpsihas this batch, except the smaller chunks of the remainder (n_local_samples × max_conn_size / 16if None).MCStatepasses itschunk_size, whereas the padded kernellocal_value_kernel_jax_chunked()evaluates themax_conn_sizeconnected configurations ofchunk_size // max_conn_sizesamples at once.min_chunk_size (
int|None) – the size of the smallest chunk (chunk_size // 8if None).conn_chunk_size (
int|None) – the number of connected configurations computed at once (as many as take 256 MiB if None), or themax_conn_sizepadded connected configurations of a single sample if they are more.
- Returns:
The local values, of shape
(n_samples,).