Skip to content
In depthExperiments

Verace Topos: v3 code

Invariant-checked Python subsystems built around a transformer KV cache with content-addressed paging and symplectic volume steering.

Verace Research
  1. Active window: Short window of recent tokens kept in the cache
  2. Bounded resident set: The LRU pager holds 16 blocks by default
  3. Chunked KV offload: Oldest chunk stored with a soliton signature
  4. Geometric-key retrieval: Top-k blocks recalled by query geometry
Figure 1. Bounded, geometrically paged KV cache in the Verace Topos v3 code. Schematic: a transformer's key-value cache in the v3 code keeps a short active window, offloads older chunks to a content-addressed store and recalls the most relevant blocks by query geometry into a bounded resident set.
Open the simulator on its own pageLooking back, or keeping a fixed memory: an interactive toy model of the principle. You can also try it below

Overview

The v3 code is the main Python implementation of Verace Topos: one package, verace_v3, with examples, pipelines and tests, built around V3Engine, V3Config and an application factory create_app(). It addresses one question. Can a transformer's key-value cache be replaced by a bounded, geometrically paged memory whose keys never collapse onto a single direction? Around that cache sit numbered conditions, I0 to I22, that subsystems check, each subsystem with its own frozen configuration, a health() report and telemetry under v3.<subsystem>.* names. Some of these checks are heuristics, and some have no effect under default settings.

The core is ToposKVCache, which joins three parts. Soliton Wave Memory (SWM) tags offloaded chunks with a 16-dimensional signature. The Holographic Tensor Store (HTFS) keeps chunks under SHA-256 addresses with zstd compression and an LRU working-set pager. Dynamic Symplectic Steering (DSS) keeps an SVD-based logic volume at or above vmin⁡=0.15v_{\min} = 0.15, which is Invariant I6. Further subsystems implement other invariants: AST-level metamorphic rewriting (I17), SU(2) Wilson-loop pointer auditing (I18), sheaf gluing for merges (I19), a loop quantum cosmology solver (I11), a Landauer erasure auditor (I21) and thermal noise damping (I22). Others cover hysteretic GPU thermal control, a quarantine controller with a two-operator quorum, and a DNA soliton model.

The test suite runs the subsystems against real tensors from GPT-2, an outside pre-trained model, and a demo streams 512 GPT-2 layer-0 key and value tensors into the cache in 32-token chunks. The lab's generalization audit ran on an RTX 4050 laptop GPU. GPT-2 was distilled on 24 problems from eight benchmark sets, and 16 held-out problems were kept apart. Static distilled weights scored 100% on training problems and 0 of 16 held out. Adding the Topos KV cache and DSS left accuracy at 0 of 16 with logic volume 0.220. Only the full hybrid engine, with Z3 (an outside SMT solver), a C++ sandbox and calculators as external oracles, scored 16 of 16, with volume 4.273. The lab's own code audit found that this oracle regime mostly returns hardcoded or expected answers, and that in the second regime the cache is only logged, so the result does not show generalisation.

The cache, the steering controller, the store and the invariant subsystems are implemented and exercised by tests and demos. The lab's own code audit shows several gaps between names and computation. SWM stores and returns raw bytes, and soliton invariance is asserted rather than simulated. The volume penalty used in distillation has no gradient path. The monodromy check is a loop-count heuristic. The cosmology shear damping is a no-op under default settings. The 8x to 30x memory savings appear in the lab's records, with no measurement found in the lab's own code audit. The 16 of 16 held-out result does not show generalisation.

Status

Experiments. The subsystems are implemented and tested against GPT-2 tensors, and the lab recorded a three-regime held-out evaluation on 16 problems.

Simulator

A row of tokens is read two ways at once: the newest token looks back at every earlier one, and every token is also written into one memory of fixed size that fades.

  • looking back: one arc for every earlier token
  • fixed memory: how much of each token it still holds
  • newest token at the right
Looking back, this token
23 comparisons
Looking back, whole sequence
276 comparisons
State kept: looking back / fixed
24 tokens / 1 state
Fixed memory: a token is half faded after
4.3 tokens

Lengthen the sequence: the arcs multiply, the fixed memory stays one state. Lower the decay and it forgets sooner.

This simulator is an illustration of the principle, with made-up numbers. It does not run the lab's code or show the lab's data, and nothing in it is a measurement.

Architecture

  1. ToposKVCache

    A drop-in replacement for a transformer KV cache. It keeps a short active window, offloads older chunks to the tensor store and recalls the most relevant blocks by query geometry.

  2. Soliton Wave Memory buffer

    SolitonBuffer stores float32 chunk bytes under SHA-256 content addresses together with a fitted soliton signature that is used as the chunk's retrieval key.

  3. Holographic Tensor Store and pager

    A sharded, zstd-compressed, reference-counted block store with an LRU pager. The pager faults the top-k relevant blocks into a bounded resident set.

  4. Dynamic Symplectic Steering controller

    DSSController measures the logic volume of a key or hidden-state matrix. When the volume falls below the floor, it injects a PID-scaled counter-flow along low-variance directions.

  5. Real Metamorphic Engine

    RealMetamorphicEngine rewrites a Python function's syntax tree with semantics-preserving passes. It accepts a variant whose outputs match the original on sampled inputs within tolerance and whose syntax tree differs.

  6. Invariant auditors

    Subsystems check the numbered invariants: a Wilson-loop pointer auditor (I18), a sheaf collator (I19), a monodromy translation engine (I20), a Landauer erasure auditor (I21) and a kernel integrity auditor (I16).

  7. Physics engines

    A loop quantum cosmology solver for the bounce and the Wheeler-DeWitt equation (I11), a modular-form check (I12), a five-manifold symplectic simulator and a DNA base-pair soliton model.

  8. Hardware thermal manager

    HTMManager polls each GPU and enforces the thermal limit of Invariant I9 with a hysteretic clock control loop, emitting telemetry and alerts.

  9. Quarantine and sanitization

    An epistemic quarantine controller simulates network severing, requires a two-operator signed quorum, then zeroizes keys and runs a verified three-pass overwrite.

  10. Reasoning distillation pipeline

    distill_reasoning_math.py fine-tunes GPT-2 on reasoning problems. It is the training side of the generalization audit.

Implementation

Mechanisms as they are implemented in the source code, with the constants the code uses.

SVD logic volume
volume.py normalises each row of a matrix to unit norm, mean-centres the rows, takes the SVD and reports the mean singular value as the volume VV. VV approaches 0 when representations collapse onto one direction, and Invariant I6 requires V≥vmin⁡V \ge v_{\min} with vmin⁡=0.15v_{\min} = 0.15.
PID symplectic counter-flow injection
steering.py computes e=vmin⁡−Ve = v_{\min} - V, accumulates the integral of ee, and sets the gain g=max⁡(kpe+ki∑e,0.05)g = \max(k_p e + k_i \sum e, 0.05). It adds Δ=gnˉ CU\Delta = g \bar{n} \, C U to the hidden states, where nˉ\bar{n} is the mean row norm, Cim=cos⁡(πm(i+0.5)/b)C_{im} = \cos(\pi m (i + 0.5)/b) for m=1..km = 1..k, and UU holds the kk smallest-variance right singular vectors. Defaults are kp=0.6k_p = 0.6, ki=0.1k_i = 0.1, 12 substeps and k=32k = 32, and the strict preset raises vmin⁡v_{\min} to 0.20.
DSS volume floor in the cache
The cache measures the volume of the flattened key matrix. If the volume is below vmin⁡v_{\min}, times a margin of 1.2 during updates, the keys are replaced with the output of steer_hidden. The design intent is to prevent softmax flattening.
Chunked KV offload with geometric paging
cache.py keeps the active window at most chunk_size plus recent_tokens_pinned tokens, 16 plus 16 by default. It offloads the oldest chunk as raw float32 bytes tagged with a 16-dimensional soliton signature, then recalls the top-k blocks by query geometry and prepends them. The long_context_1m preset doubles these sizes.
Geometric-key cosine retrieval
The pager scores each block by q⋅k∥q∥∥k∥+10−12\frac{q \cdot k}{\|q\| \|k\| + 10^{-12}} against its geometric_key. Prefixes are compared on a dimension mismatch, and blocks without a key score 0.
Content-addressed store with reference-count GC
A block address is the SHA-256 of its raw bytes, and a duplicate put increments a reference count. Payloads are zstd-compressed at level 3 by default, and the shard is int(hex[:8],16) modulo the shard count (4, or 8 in production). Garbage collection drops zero-reference blocks older than the retention time of 1 hour, or 24 hours in production.
LRU working-set pager
pager.py bounds an OrderedDict by resident_budget_blocks (16 by default, 32 in production). Hits are moved to the end, misses fault in from compressed storage, and popitem(last=False) evicts the least recently used block.
Pseudo-spectral split-step KdV integrator
kdv.py solves ut+6uux+uxxx=0u_t + 6 u u_x + u_{xxx} = 0 with wavenumbers k=2π⋅fftfreq(n,dx)k = 2\pi \cdot \mathrm{fftfreq}(n, dx). The dispersion half-step is applied exactly as eik3Δt/2e^{i k^3 \Delta t / 2} in Fourier space, and the nonlinear term is a first-order Euler step using a spectral derivative. The position invariance claimed for context chunks is asserted by identity, not simulated.
Metamorphic invariant I17
Five AST transformers apply algebraic identities, parameter renaming, dead XOR assignments, an always-true opaque predicate and state-machine control-flow flattening. A variant passes if sampled outputs match the original within rtol and atol of 1e-5, the SHA-256 AST hash differs, and token Jaccard divergence is at least 0.20.
Answer-only distillation with volume barrier
Only answer tokens carry labels, and the prompt prefix is set to -100. The learning rate follows ηe=η0⋅0.5(1+cos⁡(πe/E))\eta_e = \eta_0 \cdot 0.5 (1 + \cos(\pi e / E)). The loss is L=CE+0.01max⁡(0,0.15−sˉ)\mathcal{L} = \mathrm{CE} + 0.01 \max(0, 0.15 - \bar{s}) with sˉ\bar{s} the geometric mean of singular values, but sˉ\bar{s} is computed in numpy, so the penalty has no gradient path.
Hidden-norm regularizer labelled symplectic
train_gpt2_gsm8k_symplectic.py describes its extra term as Hamiltonian conservation. It actually computes 0.001(∥h6∥‾−1)20.001 (\overline{\|h_6\|} - 1)^2 over layer-6 hidden states, and the imported leapfrog_step is never called.
SU(2) Wilson loop pointer safety
gauge.py forms U=∏kexp⁡(i ak⋅σ)U = \prod_k \exp(i \, a_k \cdot \sigma) over pointer events, where allocation and free cancel as ±π4σ3\pm \frac{\pi}{4} \sigma_3. Use-after-free multiplies by exp⁡(iπ2σ1)\exp(i \frac{\pi}{2} \sigma_1) and double free by exp⁡(−iπ4σ3)\exp(-i \frac{\pi}{4} \sigma_3). I18 requires W=12Re Tr U≈1W = \frac{1}{2} \mathrm{Re} \, \mathrm{Tr} \, U \approx 1 within 1e-4, a value hardcoded even though WLSConfig defines its own tolerance.
Sheaf gluing merge
Local sections are dictionaries over key covers, and an overlap is the set of shared keys. If every pairwise overlap agrees within an absolute tolerance of 1e-6, the union is returned as the unique global section. Otherwise the merge raises SheafMergeConflictError.
Loop quantum cosmology bounce
solver.py integrates a˙=−4πG3apa(1−ρ/ρc)\dot{a} = -\frac{4\pi G}{3a} p_a (1 - \rho/\rho_c) and ϕ˙=pϕ/a3\dot{\phi} = p_\phi / a^3 with ρc=0.41\rho_c = 0.41, using a fourth-order Ruth-Yoshida scheme with θ=1/(2−21/3)\theta = 1/(2 - 2^{1/3}). Gravitational entropy Sgrav=48(σ/(ρa6))2(1−ρ/ρc)2(ρ/ρc)S_{grav} = 48 (\sigma / (\rho a^6))^2 (1 - \rho/\rho_c)^2 (\rho/\rho_c) vanishes at the bounce. The stiff-matter shear damping factor equals 1 under the default settings, so it has no effect.
Polymer Wheeler-DeWitt difference operator
dewitt.py builds a tridiagonal matrix with coefficients πG12∣v±2∣ ∣∣v±1∣−∣v±3∣∣\frac{\pi G}{12} |v \pm 2| \, \big| |v \pm 1| - |v \pm 3| \big| and solves it by dense eigendecomposition. It selects the eigenvalue nearest zero, although a code comment says lowest positive.
Landauer bound via rank deficiency
thermodynamics.py counts erased bits as max⁡(m,n)−rank\max(m, n) - \mathrm{rank}, with an SVD tolerance of 1e-7, and the minimum heat as Q=kBTln⁡2⋅bitsQ = k_B T \ln 2 \cdot \mathrm{bits} at T=300T = 300 K. An operator counts as reversible only if it is square and full rank.
Symplecticity and reversibility test
benchmarks.py requires ∣det⁡J−1∣≤10−7|\det J - 1| \le 10^{-7} for the forward-difference Jacobian of one phase-space step, which is I1. It also requires a forward-then-reverse error of at most 1e-10 (I2) and a manifold departure of at most 1e-6, on Euclidean, Poincaré-ball, sphere, torus and projective geometries.
Peyrard-Bishop-Dauxois DNA model with telomere halting
Base-pair opening yny_n follows a Morse potential Dn(e−ayn−1)2D_n (e^{-a y_n} - 1)^2 with D=0.075D = 0.075 eV for G/C, D=0.050D = 0.050 eV for A/T, and a=4.45a = 4.45, plus nonlinear stacking with k=0.04k = 0.04, ρ=0.5\rho = 0.5 and α=0.35\alpha = 0.35. Each leapfrog step consumes at least one telomere unit from a budget of 5000, and more under relative energy drift, so the code stops a run within 5000 steps (I13).
Hysteretic thermal DVFS control
A GPU enters RED at T≥0.95Tmax⁡T \ge 0.95 T_{\max} and YELLOW at T≥0.85Tmax⁡T \ge 0.85 T_{\max}, with Tmax⁡=83T_{\max} = 83 C. It leaves each zone only after cooling a further 0.03Tmax⁡0.03 T_{\max}. Clocks are cut by 100 MHz in yellow and 300 MHz in red, with a floor of 300 MHz.
Two-man quorum for irreversible actions
A nonce is sha256(node_id:timestamp:reason)\mathrm{sha256}(\mathrm{node\_id} : \mathrm{timestamp} : \mathrm{reason}), valid for 300 s in production. Both trusted operators must sign it as sha256(key:nonce)\mathrm{sha256}(\mathrm{key} : \mathrm{nonce}) before keys are zeroized and memory is overwritten in three passes: a pattern, its inverse, then zeros.
Well-founded descent recursion guard
Each pushed frame must satisfy Φ(xk+1)<Φ(xk)\Phi(x_{k+1}) < \Phi(x_k) and a depth of at most 64. A violation raises UncheckedRecursionError, and the kernel integrity auditor uses this guard for Invariant I16.

Results

From the lab's own experiments and records. They have not been independently replicated.

  1. Distilled GPT-2 memorised but did not generalise

    In the lab's audit, GPT-2 trained to a loss below 0.0002 scored 100% on its 24 distilled problems and 0 of 16 on held-out problems.

  2. Topos KV cache and DSS alone did not recover accuracy

    With the Topos cache and the I6 volume floor active, the evaluation records report a logic volume of 0.220 and I6 satisfied, but held-out accuracy stayed at 0 of 16. The lab's own code audit found that in this regime the cache is only logged.

  3. Hybrid engine's 16 of 16 does not show generalisation

    The lab recorded 100% on the 16 held-out problems, with logic volume 4.273 and Invariants I6 and I17 passed, when steering, metamorphic verification and external solvers were all active. The lab's own code audit found that the oracle regime mostly returns hardcoded or expected answers, so the result does not show generalisation.

  4. Memory savings stated but not measured

    The lab's records give 8x to 30x RAM savings for the Topos cache. The lab's own code audit found no measurement of that range.

  5. Soliton memory stores raw bytes

    The lab's own code audit shows that SolitonBuffer returns the exact stored bytes rather than decoding from the soliton signature, and that soliton position invariance is asserted by identity rather than simulated.

  6. Volume penalty in distillation has no gradient

    The 0.01-weighted volume barrier is computed in numpy, so it cannot influence training. A second regulariser labelled symplectic is a hidden-norm penalty, and its imported integrator is unused.

  7. Several checks are weaker than their names

    The monodromy isomorphism reduces to equal loop counts, the LQC I1 check perturbs one Jacobian entry, and the default shear damping factor is exactly 1. MinHash deduplication has no LSH banding despite its docstring, and the Dirac clock is lock-based although described as lock-free.

Concepts

Key-value cache
The store of attention keys and values a transformer keeps for past tokens so they are not recomputed. Its memory grows with context length, which is the cost the Topos cache targets.
Logic volume
The lab's scalar measure of how spread out a set of representations is: the mean singular value of the row-normalised, centred matrix. It falls toward zero when vectors collapse onto one direction.
Invariant I6
The condition V(t)≥vmin⁡V(t) \ge v_{\min} with vmin⁡=0.15v_{\min} = 0.15. The lab ties it to preventing attention softmax flattening and mid-context collapse.
Symplectic map
A phase-space transformation whose Jacobian has determinant 1, so it preserves volume and is reversible. DSS describes its counter-flow in these terms, and the test suite checks the property on integrators.
KdV soliton
A solitary wave of the Korteweg-de Vries equation that keeps its shape, energy and speed as it travels. SWM uses it as a model for position-invariant chunk signatures.
Lost-in-the-middle
The tendency of long-context models to neglect information placed in the middle of the context. The lab presents soliton memory as its remedy.
Content addressing
Naming a block by a cryptographic hash of its bytes, so identical content is stored once and any change gives a new address. HTFS and SWM both use SHA-256 for this.
Working-set pager
A bounded resident cache of blocks drawn from larger compressed storage, with misses faulted in and the least recently used block evicted, as in operating-system paging.
Invariants I0 to I22
Numbered conditions that subsystems check, from a constitutional floor at I0 through volume, thermal, purge and physics checks to the later safety and code conditions I15 to I22. Some of the checks are heuristics, and some have no effect under default settings.
Held-out evaluation
Testing on problems that received no gradient updates or steering projections during distillation. In the lab's audit these were the last 2 rows of each of eight datasets.
External formal oracles
Deterministic checkers that verify a deduction before it is emitted. In the lab's full hybrid engine these were a Z3 SMT solver, a C++ sandbox and scientific calculators.
Metamorphic verification
Producing program variants that differ in form but must agree in behaviour, then checking that agreement on sampled inputs. This is the basis of Invariant I17.
Wilson loop holonomy
The product of group elements accumulated around a closed path. The pointer auditor encodes memory events as SU(2) elements so that a correct allocate-free history multiplies back to the identity.
Sheaf gluing
The rule that local data agreeing on every overlap combine into exactly one global object. The collator uses it to merge partial dictionaries, and it is Invariant I19.
Loop quantum cosmology bounce
A model in which quantum geometry corrections halt collapse at a critical density and reverse it, replacing the Big Bang singularity. Invariant I11 checks that gravitational entropy vanishes there.
Landauer bound
The minimum heat kBTln⁡2k_B T \ln 2 dissipated per erased bit. The erasure auditor counts erased bits from the rank deficiency of a linear operator.
Telomeric halting
A countdown budget of which each cycle consumes at least one unit, and more under numerical instability, so the code stops a simulation within the initial budget. Invariant I13 is the condition tied to this budget.
Three evaluation regimes
The lab's comparison of static distilled weights, static weights with the Topos KV cache and DSS, and the full hybrid engine with steering, metamorphic verification and oracles.

About this page

Written from the lab's own documents and source code. Figures and results are the lab's measurements as it recorded them at the time, and have not been independently replicated.

Published under the PolyForm Noncommercial License 1.0.0: free for noncommercial use.