Skip to main content

Draw samples from a spin model, then hold them to the exact law.

Draw samples from a small spin model at a chosen temperature, and hold them to the exact distribution.

A spin model gives every configuration an energy; at inverse temperature β, a configuration turns up with probability proportional to e−βE. The engine draws configurations one spin flip at a time, in fixed point with seeded draws, so the same request gives the same samples on every machine; up to 20 spins it also enumerates every configuration and says how far the samples fall from the exact law.

Pick a model

The engine is the browser build of commit 9888b97d5229; this page checks its file's SHA-256 before it runs. Nothing you draw here is sent anywhere.

Pick a model and a temperature, and draw.

Each model couples pairs of spins: a positive coupling pulls the two the same way, a negative one pushes them apart. Raise β and the samples crowd into the lowest-energy configurations; lower it and they spread out. A model of your own is {"n", "couplings": [[i, j, J], …], "fields": [h, …]}.

How a draw is made, named and checked.

  1. One spin at a time. Each spin is set to +1 or −1 by comparing tanh(β I) with a random number, I the pull of its neighbours and its field: the update a probabilistic bit makes. In fixed point, with each draw keyed by the seed, the chain, the sweep and the spin, the samples are the same on every machine.
  2. Error bars from the chain itself. Successive samples are not independent, so each estimator's error bar is widened by its integrated autocorrelation time τ, and the effective number of samples is the count over 2τ.
  3. The exact law, where it can be enumerated. Up to 20 spins every configuration is enumerated: the total variation and the Kullback–Leibler distance of the histogram from the law, and how many error bars each estimator falls from its exact value.
  4. Named by content. The law's address covers the model and β; the draw's adds the sweep order, the seed and the sizes; a digest covers every sample kept. The verifier makes all three again from the request, and the engine's check draws again.

Draw the same samples on your own machine.

The command line at the same commit takes the same request and gives the same samples and the same addresses. With Rust installed through rustup, this draws the frustrated square above:

git clone https://git.transaction.science/Transaction-Science/open-standards
cd open-standards
git checkout 9888b97d5229674f5038bad6da9d1fa7fb3d251c
cd wai/wai-quantum-cli
echo '{"ising":{"n":4,"couplings":[[0,1,1],[1,2,1],[2,3,1],[3,0,-1]],"fields":[0.5,0,0,0]},"beta":0.7,"seed":7,"schedule":"coloured","sweeps":2000,"chains":2,"pairs":[[0,2]]}' > square.json
cargo run --release --bin wai-quantum -- lab sample --request square.json --demo-key --json

The draw's address is 8772a510831ecd15d25947d6303340ccb5a82c233ccc2d7bf369fa7381e75d26 there too. Every member of the request is in the guide to Ising and sampling jobs. This page's engine was built with rustc 1.100.0 and wasm-pack 0.15.0; its file's SHA-256 is 12808555bc0d5084941e56acfba3a97efa0afd20cbb6a6c29d57403ed63bdd74.

Where to go from here