Skip to content

Boundary Energy#

Incremental energy-delta computation for Ising models. After a block update, ΔE depends only on the edges incident to that block, so the swap energies in nrpt can be advanced by a delta instead of recomputed in full — pass the factory's result as nrpt's energy_delta_fn.

hamon.make_ising_delta_fn(nodes: list[AbstractNode], edges: list[tuple[AbstractNode, AbstractNode]], free_blocks: Iterable[Iterable[AbstractNode]], biases: jax.Array, weights: jax.Array) #

Build a vmapped base-energy delta function for use with nrpt().

Returns delta_fn(old_stacked_states, new_stacked_states) -> (n_chains,), where delta_fn[c] = E_base(new_c) - E_base(old_c).

Pass the result as the energy_delta_fn keyword argument to nrpt():

delta_fn = make_ising_delta_fn(ebm.nodes, ebm.edges,
                               free_blocks, ebm.biases, ebm.weights)
nrpt(..., energy_delta_fn=delta_fn)
FLOPS note

For checkerboard (2-block) partitions every edge is incident to at least one block, so incident_mask = all-ones — same arithmetic as a full recompute but without the equinox dispatch overhead. The strict FLOPS savings appear with rectangular blocks (4-coloring) where the incident fraction is O(1/m) for m×m blocks.

Parameters:

Name Type Description Default
nodes list[AbstractNode]

all nodes in global order (IsingEBM.nodes)

required
edges list[tuple[AbstractNode, AbstractNode]]

all edges (IsingEBM.edges)

required
free_blocks Iterable[Iterable[AbstractNode]]

the free blocks used in the sampling program; any iterable of node-iterables (Block objects work directly)

required
biases Array

(n_nodes,) bias array (IsingEBM.biases)

required
weights Array

(n_edges,) weight array (IsingEBM.weights)

required