Reproducing Memory on Real Physics Simulations

Three independent systems, no sensor stream involved: a quantum error-correction decoder, a lattice field theory Monte Carlo simulation, and a transverse-field Ising model. Below is how to reproduce all three results end to end -- including the one that didn't work the way we hoped, and the fix we tried that legitimately didn't help.

Requirements: a VAAS-X API key, pip install vaas-x numpy.

1. Quantum error correction: learning one recurring fault

A 64-bit random linear code (n=64, k=32) cannot algebraically correct an arbitrary weight-6 error -- it exceeds the code's guaranteed correction distance. Real hardware often produces the same high-weight fault repeatedly, though: a stuck sensor line, a recurring burst on the same physical bits. This queries a specific weight-6 syndrome before memory has ever seen it, ingests one episode describing that exact syndrome and its correction, then queries the identical syndrome again -- checking the recalled fix against the code's own math, not just "a hit came back".

import numpy as np
from vaasx import Bootstrap

class RandomLinearCode:
    def __init__(self, n=64, k=32, seed=42):
        self.n, self.k = n, k
        self.m = n - k
        rng = np.random.default_rng(seed)
        self.H = (rng.random((self.m, n)) < 0.15).astype(int)

    def get_syndrome(self, e):
        return (self.H @ e) % 2

    def check_correction(self, actual_error, correction):
        residual = (actual_error + correction) % 2
        return not np.any((self.H @ residual) % 2)

    def vec_to_str(self, v):
        return "".join(map(str, v))

code = RandomLinearCode()
burst = np.zeros(code.n, dtype=int)
burst[[10, 11, 12, 13, 14, 15]] = 1  # a recurring weight-6 hardware fault
syndrome = code.vec_to_str(code.get_syndrome(burst))

brain = Bootstrap(api_key="YOUR_API_KEY", device_id="physics_qec")

# 1. Before: no match -- the code genuinely cannot solve this algebraically
before = brain.query(f"Syndrome: {syndrome}", k=1)

# 2. Ingest exactly one episode: this exact syndrome -> its correction
brain.ingest([{
    "description": f"Syndrome: {syndrome} correction={code.vec_to_str(burst)}",
    "state": {"text": f"Syndrome: {syndrome}"},
    "action": {"text": f"correction={code.vec_to_str(burst)}"},
    "outcome": {"text": "learned recurring burst fault pattern", "success": True},
}])

# 3. After: recall, verified independently against the code's own math
hits = brain.query(f"Syndrome: {syndrome}", k=1)
recovered = np.array([int(c) for c in hits[0]["text"].split("correction=", 1)[1].split()[0]])
print("recall correct:", code.check_correction(burst, recovered))

This is a recall test, not a generalization test -- it shows memory remembers one specific pattern it has been shown once, not that it predicts corrections for syndromes it has never seen. On our run: no match before ingestion (expected), correct recall after, independently verified.

2. Lattice phi4: phase classification from a real Monte Carlo simulation

A real Metropolis Monte Carlo simulation of a scalar phi4 field on a 16×16 lattice, sweeping the coupling kappa across the model's continuous order-disorder phase transition. A single MC chain is genuinely noisy near a continuous transition -- averaging 3 independent chains per kappa value is the standard fix, not a way of hiding the noise.

import numpy as np
from vaasx import Bootstrap

class Phi4Lattice:
    def __init__(self, L=16, kappa=0.2, lam=0.1, seed=1337):
        self.L, self.kappa, self.lam = L, kappa, lam
        self.rng = np.random.default_rng(seed)
        self.field = self.rng.normal(0.0, 1.0, size=(L, L))

    def sweep(self, beta=1.0, step=0.75):
        L = self.L
        for x in range(L):
            for y in range(L):
                phi = self.field[x, y]
                nbr = (self.field[(x+1)%L,y] + self.field[(x-1)%L,y]
                       + self.field[x,(y+1)%L] + self.field[x,(y-1)%L])
                def action(p): return (1-2*self.kappa)*p*p + self.lam*(p*p-1)**2 - 2*self.kappa*p*nbr
                proposal = phi + self.rng.normal(0.0, step)
                dS = (action(proposal) - action(phi)) * beta
                if dS <= 0 or self.rng.random() < np.exp(-dS):
                    self.field[x, y] = proposal

def run_phi4(kappa, seed, L=16, beta=1.0, lam=0.1, thermal=300, measure=100):
    sim = Phi4Lattice(L=L, kappa=kappa, lam=lam, seed=seed)
    for _ in range(thermal): sim.sweep(beta=beta)
    ms = []
    for _ in range(measure):
        sim.sweep(beta=beta)
        ms.append(abs(float(np.mean(sim.field))))
    avg = float(np.mean(ms))
    return "ordered" if avg > 0.2 else "disordered", avg

brain = Bootstrap(api_key="YOUR_API_KEY", device_id="physics_lattice_phi4")

# Ingest 13 kappa values, each averaged over 3 independent MC chains
items = []
for kappa in np.linspace(0.12, 0.32, 13):
    phases = [run_phi4(kappa, seed) for seed in (1337, 2024, 7)]
    phase = "ordered" if np.mean([p[1] for p in phases]) > 0.2 else "disordered"
    items.append({
        "description": f"Phi4 Lattice L=16 beta=1.00 kappa={kappa:.3f} lambda=0.10 phase={phase}",
        "state": {"text": f"Phi4 Lattice L=16 beta=1.00 kappa={kappa:.3f} lambda=0.10"},
        "action": {"text": "metropolis_sample thermal_sweeps=300 measure_sweeps=100"},
        "outcome": {"text": f"phase={phase}", "success": True},
    })
brain.ingest(items)

# Query a held-out kappa memory has never seen
hits = brain.query("Phi4 Lattice L=16 beta=1.00 kappa=0.245 lambda=0.10", k=7)
print(hits[0]["text"])

On our run: 5 of 8 held-out kappa values correctly classified. See the honesty note below before drawing conclusions from that number alone.

3. Transverse-field Ising model: quantum criticality via exact diagonalization

Exact diagonalization of the TFIM Hamiltonian for an 8-site chain -- deterministic, no sampling noise, a clean ground truth across the model's h/J≈1 quantum phase transition.

import numpy as np
from vaasx import Bootstrap

def characterize_phase(n=8, J=1.0, h=1.0):
    dim = 1 << n
    H = np.zeros((dim, dim))
    for s in range(dim):
        H[s, s] = sum(-J * (1 if (s>>i)&1==0 else -1) * (1 if (s>>((i+1)%n))&1==0 else -1) for i in range(n))
        for i in range(n):
            H[s, s ^ (1 << i)] += -h
    evals = np.linalg.eigvalsh(H)
    gap = float(evals[1] - evals[0])
    ratio = h / J
    phase = "critical"
    if ratio < 0.7: phase = "ordered_ferromagnet"
    elif ratio > 1.3: phase = "paramagnet"
    return phase, gap

brain = Bootstrap(api_key="YOUR_API_KEY", device_id="physics_tfim")

items = []
for ratio in np.linspace(0.1, 2.0, 20):
    phase, gap = characterize_phase(h=ratio)
    items.append({
        "description": f"TFIM 1D N=8 h/J={ratio:.3f} phase={phase} gap={gap:.4f}",
        "state": {"text": f"TFIM 1D N=8 h/J={ratio:.3f}"},
        "action": {"text": "exact_diagonalization"},
        "outcome": {"text": f"phase={phase} gap={gap:.4f}", "success": True},
    })
brain.ingest(items)

hits = brain.query("TFIM 1D N=8 h/J=1.050", k=7)
print(hits[0]["text"])

On our run: 4 of 10 held-out h/J ratios correctly classified.

A real finding worth knowing about before you rely on this for continuous parameters

In both the phi4 and TFIM tests, every miss had the same shape: memory defaulted toward whichever phase had more representation in what was ingested (7 of 13 phi4 episodes were "ordered"; 7 of 20 TFIM episodes were "critical"), rather than discriminating finely near the actual phase boundary. Before writing this up, we tried a legitimate fix: querying k=7 instead of the top-1 hit and taking a score-weighted majority vote across the retrieved neighbourhood -- standard practice for a retrieval-based classifier, not a way of engineering the answer. It changed nothing. The TFIM run predicted "critical" for every single query, identical before and after the fix, which rules out top-1 noise as the explanation: the retrieved neighbourhood itself is dominated by the majority class regardless of the query value.

Our read: short, numerically-dense query strings like "h/J=0.350" differ from a training example by only a few characters in an otherwise near-identical string -- a general-purpose sentence embedding model has little reason to weight that span heavily, and it shows. Retrieval does coarse region classification correctly (every miss landed on the wrong side of a real, close decision boundary, not a wildly wrong one), but it is not a substitute for a numerical model when the question is exactly where the line falls. Categorical or recurring-pattern memory -- the QEC result above, or industrial/wearable channel classification, where the signal dominates the description -- is where this is validated to work well. Fine interpolation across a continuous parameter from a bare numeric label in the query text is not, at least not without more deliberate encoding work than a raw f-string.

Scope

What this reproduces: the ingest/query/outcome path working unmodified against purely computational domains with no sensor stream, and memory reliably learning and recalling a specific recurring pattern once shown it. What it does not show: that this SDK is a substitute for a real numerical or ML model when the task is fine-grained interpolation across a continuous parameter space from short text alone. Match the shape of your problem to what's proven here -- recurring or categorical pattern memory, not curve-fitting.

More guides: Reproduction Guides. Full reference: Developer Guide. Technical writeup: Scientific Computing whitepaper.