Sampling algorithms and numerical details

Targets and kernel choice

Use The finite-imaginary-time measure for the binary raw/reduced target and Exact spatial logical-bit marginalization for its spatial logical-bit marginalization. The public higher-degree sampler targets the collapsed action. The vertex sampler targets the ordinary full spin field of The vertex code and its two-dimensional image. Their clocks and update families are different.

Collapsed stencil state

CollapsedStencilEngine retains:

  • uint8 spacetime p-cell bits and their orientation/time metadata;

  • int8 (p+1)-face signs and float64 reduced couplings;

  • an integer sheet-membership vector and integer sheet sums q_I;

  • PCG64 state, attempted/changed proposal counters and model information.

A face sign is reconstructed from the parity of its signed boundary. Periodic coincident incidences are combined before mod-two reduction. Construction recomputes face signs and sheet sums from bits; checkpoint loading verifies these relationships. These are caches of the defined target, not additional free state variables.

Local proposals

For a selected spacetime spin e, flipping it toggles each face with odd net incidence. If e lies outside a logical sheet, the log ratio is

\[\Delta S=-2\sum_{f\ni e}\kappa_fP_f-2h_e\sigma_e.\]

For membership in sheet I, replace the explicit single-spin sheet field by

\[\Delta S=-2\sum_{f\ni e}\kappa_fP_f +\log\cosh[h_s(q_I-2\sigma_e)]-\log\cosh(h_sq_I).\]

The implementation updates q_I only on acceptance. For a stable log-cosh difference it evaluates

\[h_s(|q'|-|q|) +\log(1+e^{-2h_s|q'|})-\log(1+e^{-2h_s|q|}),\]

using log1p. This avoids cancellation of large nearly equal log coshes. All physical sheet terms are included exactly as in the collapsed target.

Worldline proposals and fixed mixture

A worldline proposal selects a spatial p-cell uniformly and flips its bit at every time slice. The flip set is distinct and fixed by geometry. The engine counts all selected incidences per face and changes a face sign only when that count is odd. It computes outside-sheet field changes and each affected q_I before applying the simultaneous move. Summing independent single-flip deltas without updating the state would double-count shared faces.

Each attempted step selects lazy, worldline or local with fixed probabilities. The local component has positive probability and the lazy component is strictly positive. Local and worldline proposals are involutions with symmetric, state-independent selection; min(1,exp(delta S)) gives detailed balance. For a finite strictly positive target, local flips connect all configurations and laziness gives aperiodicity. This exact-arithmetic invariant-law argument does not give a useful runtime mixing bound.

A sweep is exactly the measurement-model spin count attempted mixture steps. Ordered starts use zero bits; hot starts draw independent binary bits. Initialization and updates use distinct stream purposes. Keep the definition fixed across warmup, measurement and continuation; do not stop a sweep when a state-dependent amount of change has occurred.

Rare Metropolis decisions

sparse_engine._metropolis_accept is reused by the collapsed production engine. Nonnegative log ratios accept deterministically. For negative ratios, it computes the finite represented probability and draws the smaller of the acceptance/rejection probabilities to avoid rounding the other to one. The Bernoulli helper samples a represented dyadic probability using raw bits when a 53-bit floating-uniform grid is insufficient, including subnormal probabilities.

When exp(delta S) underflows, a guarded log-comparison path concatenates raw 64-bit words and uses Decimal logarithms. The required precision grows with the magnitude of the log ratio, with a one-million-bit ceiling; requests beyond that ceiling fail explicitly. The finite-grid error statement concerns the comparison given an input log ratio. It does not make floating evaluation of the target or transcendental functions exact real arithmetic.

Count every requested raw word as well as scalar random/integer requests in the worker’s accounting. Tests must exercise the actual RNG boundary rather than a stub that omits a rare-event branch. The public SamplingPlan does not expose all internal test-only accounting controls.

Vertex single-cluster transition

VertexSampler uses a Python integer to hold all spin bits. Periodic shifts are exact bit operations; boundary masks prevent one row from leaking into the next. For each nonlazy attempt:

  1. Choose a seed site uniformly.

  2. Draw one independent Bernoulli activation for every positive-space bond and every positive-time bond, with p_axis=1-exp(-2*kappa_axis).

  3. Retain activated bonds only between equal spins.

  4. Flood-fill the seed’s connected component using bitset frontiers and the two bond masks in both directions.

  5. XOR the component into the state, flipping all its spins.

The sampled full bond field has the same law as revealing needed bonds during ordinary Wolff growth. Conditional on the bond field, cluster colors are uniform; choosing a component by its uniformly selected site depends on size but not color, so its flip preserves that conditional law. The bond resampling and flip therefore preserve the Ising marginal. Singleton-cluster probability supplies connectivity at admissible finite couplings. The explicit lazy probability supplies self-loops.

One clock tick is one attempt, including a lazy stay. Sampling after a fixed number of ticks preserves the intended stationary law. Measuring after a state-dependent number of clusters chosen to accumulate one volume of flipped spins generally changes the observed clock and is not this implementation.

The vertex method uses NumPy floating Bernoulli arrays. It does not use the general engine’s rare-dyadic/log comparison routine. Its model constructor therefore refuses bond probabilities rounded to zero or one. Do not claim the same numerical rare-event behavior for both engines.

Complexity and resource admission

The stencil stores O(spins+faces+r) arrays; local-neighborhood work is bounded by cubical incidence degree. Simultaneous-proposal scratch scales with the flip set and its affected faces, with an explicit capacity cap. The constructor also budgets measurement mappings and checkpoint copies before allocating. Current hard backend caps are eight million spins/faces, logical rank 64 and at most 65,536 simultaneously proposed spins. Its memory estimate is limited by min(2 GiB, half live available RAM), independently of the workflow’s budget.

The vertex step draws O(LM) bonds and holds O(LM) bits/bond variates; bitset connectivity proceeds in frontier rounds. It favors simplicity and integer geometry correctness over an optimized boundary-only bond generator. The public executor supports one worker; BLAS thread controls do not make these Python update loops parallel.

Reference implementations

collapsed.CollapsedBinaryEngine is the transparent sparse target reference. collapsed_stencil must match its action, proposal ratios, characters, joint estimators and checkpoints on supported small models. Internal SparseBinaryEngine and signed-orientation cluster methods target other representations and are useful controls, not plug-in collapsed kernels. No tempering, replica-exchange or cluster algorithm for the public collapsed target is selected by the current API. Such an extension requires its own stationary-law, proposal and joint-estimator review.