Verace V1: rotation memory experiments
Constant-size associative memories whose per-head state is an orthogonal or unitary matrix, updated by one closed-form rotation per token.
- Orthogonal or unitary state: Rotation keeps the norm, so the state cannot blow up
- Rank-2 Rodrigues rotation: One closed-form rotation per token
- Skew-symmetric generator: Rotation plane spanned by the key and value
- Per-head memory state: Recalled with a single product against the query
Overview
The rotation memory experiments are the part of Verace V1 that studies a replacement for the growing key-value cache. They test a recurrent associative memory whose state is a fixed orthogonal or unitary matrix per head, turned by one rotation per token. The question is whether an unbounded stream of key-value bindings can be folded into this constant-size state and recalled with a single product . The design specifications want this in memory and time per token, without the superposition interference that degrades additive linear attention once the sequence length far exceeds .
Each token writes by rotation, not addition. Because a rotation preserves norm, the state keeps Frobenius norm and does not saturate or blow up. In the real variants, SLH-MEM and OS-MEM, each token produces a rank-2 skew-symmetric generator . Its exponential is computed in closed form by the Rodrigues formula. A non-commutative parallel prefix scan composes the rotations onto for training, and a sequential Triton kernel does the same for inference. The readout passes through a gated MLP residual that the code calls Hopfield attractor sharpening. CHAM is a complex-valued variant built from near-unitary updates with Newton-Schulz retraction. Five design specifications, SLH-MEM, NDG-MEM, OS-MEM, DHR-MEM and HSC-MEM, extend the design with differential noise cancellation, multi-harmonic inscription and Householder overwrites.
The memory modules, Triton kernels, a 10K byte-level BPE tokenizer, training scripts and several benchmarks are implemented. The benchmarks are a 100-question paper benchmark, a 10-item paper QA suite, MQAR and needle recall. The tokenizer compressed 1.53M characters to 405,616 subwords (3.78x). The NDG-MEM specification records 4,158,464 parameters across 3 layers, 140MB of VRAM and more than 70k tokens per second. The specifications also record under 0.4 ms for the fused scan at on an RTX 4050. The code records three lessons. Feeding the retracted CHAM state back into the recurrence diverged. A half-angle scaling bug was corrected. One training script computes the differential gate but never uses it.
Implemented: SO(d) and complex unitary memory layers with eager and Triton paths, the tokenizer, memorization and train-until-perplexity scripts, and the evaluation harnesses. Design only: Householder overwrite, streaming Gram-Schmidt whitening, the 16x16 Tensor Core register tile, the dual-scale Grassmannian hierarchy, and the 10M-token orthogonality and needle tests. The records report the tokenizer ratio, parameter count, memory use, throughput and latency. They record no perplexity, recall or QA accuracy figure. The perplexity target of 5 is checked on training batches, not held-out data, so whether the memory generalises remains open.
Status
Experiments. The memory layers, kernels, training scripts and benchmarks are implemented, and the lab's records give tokenizer compression, parameter count, VRAM, throughput and latency figures, but no perplexity, recall or accuracy result is recorded.
Simulator
A state of length 1 is updated again and again by the same small step, in two ways. Switch between rotating it and adding to it, and watch its length.
- the circle: every state of length 1
- Length of the state at the end
- 1.000
- Drift from length 1
- 0.0%
- Turned in all
- 248°
- Updates
- 24
Switch between the two methods with the same step size. Adding the step leaves the circle; rotating cannot.
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
SLH-MEM rotation memory layer
SymplecticLieHouseholderMemoryis a real per-head SO(d) recurrent memory. It turns its state by one rank-2 Rodrigues rotation per token and reads out with followed by an MLP refinement.OS-MEM multi-harmonic layer
OmniSpectralMemoryand its fast formFastOSMEMLayerare the rotation memory layers used in the language model experiments. Following the OS-MEM specification, they inscribe each token across several harmonic frequencies.CHAM complex holographic memory
ContinuousHolographicMemorycomposes complex near-unitary per-token updates by prefix scan. It retracts a separate copy of the state onto the unitary group for readout only.Triton serving kernels
Sequential per batch and head kernels cover the SLH Rodrigues scan, the CHAM holographic scan, a Cayley scan for SSSD attention and a sparse Top-K M-CMoE projection. Each is required to match its eager reference.
10K byte-level BPE tokenizer
A tokenizer trained on the research papers and the memory database replaces character-level input. It uses NFKC normalisation, a ByteLevel pre-tokenizer and pad, bos, eos and unk specials.
Deterministic memorization scripts
These scripts train 3- and 4-layer OS-MEM language models on 15 PDF papers plus the memory database. They process contiguous shards in fixed order and hold out a tail split for validation.
Train-until-target-perplexity scripts
These scripts train character-level rotation memory models on random 1024-token windows until training perplexity falls below 5. They then save a checkpoint and run generation and latency benchmarks.
Synthetic recall harness
train_and_test_memory.pytrains memory-only models on MQAR, needle-in-a-haystack or random-token tasks. It then benchmarks recall, latency, the Triton scan and norm conservation.Paper QA benchmarks
QUESTIONS_100 and PAPER_QA_BENCHMARK score multiple-choice answers about published papers and the lab's memory work by model likelihood.
chat_memory_cli.pyexposes the same QA bank interactively.Memory design specifications
The SLH-MEM, NDG-MEM, OS-MEM, DHR-MEM and HSC-MEM documents give the derivations, theorems, capacity arguments and proposed tests for successive versions of the memory.
Implementation
Mechanisms as they are implemented in the source code, with the constants the code uses.
- Rank-2 Rodrigues SO(d) exponential
- With and ,
rodrigues_skew_exp()returns , computed in fp32. Below the coefficients switch to the Taylor series and . The result satisfies without matrix inversion or complex numbers. - SO(d) rotation memory recurrence
- Per head the state follows with , and the readout is . The rotation plane is spanned by and , with gate . Halted tokens have their scale set to 0, so they leave the state unchanged.
- Non-commutative associative prefix scan
parallel_so_prefix_scan()and the CHAM scan compute ordered products in depth. An up-sweep runs at strides 1, 2, 4 and so on, then a down-sweep starts from a quarter of the padded length. The sequence is padded with identities to a power of two, and strict left multiplication preserves token order.- Sequential kernel and parallel scan split
- Inference runs one Triton program that holds the dense state tile and loops over time, as in
launch_slh_triton_scan(). Training uses autograd-tracked prefix scans. The kernels must reproduce the eager recurrence exactly. - Differential unitary noise cancellation
- A second stream rotates with and both scaled by , so the angle, which depends on their product, is halved. The readout is with , meant to cancel cross-talk in the manner of differential attention. In
train_memory_full_gpu_ppl5.pythe gate is computed but the output ignores it. - Attractor MLP refinement
- SLH-MEM refines the readout as . OS-MEM uses with a 2x hidden width, followed by an output projection and RMSNorm. The code labels this Hopfield basin sharpening.
- Infinitesimal unitary hologram update
- CHAM forms with and L2-normalised and . This bounds , which keeps the first-order unitary approximation valid. The scanned product is applied to the state on the right.
- Complex Newton-Schulz unitary retraction
newton_schulz_unitary_retraction()iterates on , 3 steps by default. It uses and drives toward the nearest unitary matrix. The readout is .- Deferred retraction with raw state carry
- CHAM carries and exports the raw prefix product . Retraction is applied only to a separate copy used for readout. Feeding the retracted state back into the recurrence was verified to diverge.
- Cayley transform via rank-2 Woodbury
- For the SSSD Cayley scan, the kernel computes with and . It first forms , then with the 2x2 matrix inverted in closed form. No inversion is needed.
- Sparse Top-K low-rank manifold MoE
- The M-CMoE kernel computes . The router softmax and Top-K weights are computed in Python before the kernel launch.
- Frobenius norm conservation check
- During training and inference the scripts compute for one head and report . An identity-initialised orthogonal state must keep norm exactly , so this measures drift from SO(d). For CHAM,
diagnostics.pyattaches forward hooks and reports mean drift instead. - Deterministic sequential shard training
- The token stream is cut into contiguous non-overlapping windows that are processed in the same order every epoch, so each pass covers 100% of the tokens. Padded targets use ignore index -100. In the BPE variant the last 0.15 of shards is never trained on and gives a held-out perplexity each epoch.
- Train-until-target-perplexity loop
- Training stops when the exponential of the step loss falls below
target_ppl, default 5.0. The loop uses cosine warm restarts and gradient clipping at 1.0. The target is measured on the training batch, not on held-out data. - Length-normalised likelihood multiple choice
- An answer's score is the sum of over its tokens divided by its length. An item passes if the correct answer outscores the best of three distractors. The margin is reported in nats.
- Synthetic MQAR and needle tasks
- In MQAR, key-value pairs appear early in the sequence and shuffled key queries appear later. Loss is taken only at query positions, which must predict the paired value. In the needle task, a single key-value pair sits at 10% depth among random distractors, and the final token queries the key.
- Keyword retrieval with likelihood reranking
chat_memory_cli.pymatches a query to the fixed 100-question bank by lexical keyword overlap. The memory language model then ranks the correct answer against its distractors by log-likelihood and updates its recurrent state. The retrieval step itself is not neural.- Memmapped token cache
dataset.pytokenizes the corpus once, in 4MB chunks, to an on-disk int32 cache keyed by a SHA-1 hash. It reads the cache back withnp.memmap, so each item pages in only the context length plus one token.- Pretraining objective with depth and energy terms
pretrain.pyminimises next-token cross-entropy plus 0.001 times the mean adaptive depth plus 0.01 times the meanLatentEnergyCriticenergy . The extra terms penalise compute depth and implausible latent transitions. The step runs under bf16 automatic mixed precision.- GPT-4 judged TinyStories evaluation
tinystories_gpt4_eval.pyreimplements the published TinyStories protocol. It samples 10 completions at temperature 1 for each of 50 story-start prompts. GPT-4 grades each completion for grammar, creativity and consistency out of 10 and assigns an age group; scores are averaged per prompt, then across prompts.
Results
From the lab's own experiments and records. They have not been independently replicated.
10K BPE tokenizer compresses paper corpus 3.78x
The lab's records report that the 10K byte-level BPE tokenizer compressed 1.53M characters of research papers to 405,616 subwords, a 3.78x reduction. The lab adopted it to fix the entropy dilution of character-level input.
NDG-MEM size, memory and throughput
The NDG-MEM specification records 4,158,464 parameters across 3 layers, 140MB of VRAM and more than 70k tokens per second using the fused Triton scan.
Fused scan latency under 0.4 ms
The specifications record the fused Triton scan kernel at under 0.4 ms for a 1024-token sequence on an RTX 4050.
Retracted CHAM state diverges when fed back
In the lab's code audit, carrying the Newton-Schulz retracted hologram forward through the recurrence was verified to diverge. CHAM therefore carries the raw prefix product and retracts only a readout copy.
Half-angle channel originally ran at quarter angle
The lab found that scaling and by 0.5 produced rather than , because the angle depends on their product. The scale was corrected to .
Differential gate computed but unused in one script
The specifications describe a differential readout . In
train_memory_full_gpu_ppl5.pyonly is computed and the output ignores it, so runs from that script do not test noise cancellation.Perplexity target measured on training batches
The train-until-target loops stop when training-batch perplexity falls below 5. Held-out perplexity is computed only in the BPE shard variant. No held-out perplexity, recall or QA accuracy figure is recorded.
Concepts
- Rotation as a memory write
- The memory stores bindings by rotating an orthogonal state instead of adding outer products to it. Rotations preserve norm, so the state neither decays nor grows however many tokens are written.
- Unitarity without retraction
- The specifications note that a skew-symmetric gives exactly. A rotation built as therefore needs no projection back onto the group.
- Superposition interference
- In additive linear attention and SSMs, . Once the sequence length far exceeds , stored bindings overlap and corrupt one another. The HSC-MEM specification names this the capacity wall that rotation memory is designed to avoid.
- Dual-harmonic gauge cancellation
- A signal channel rotates at angle and a reference channel at , and the readout subtracts times the reference. The DHR-MEM specification claims, as its Theorem 2, that this subtraction annihilates cross-talk.
- Half-angle scaling correction
- Scaling both and by yields , because the angle depends on their product. The corrected constant gives and the intended sub-harmonic channel.
- Soft phase clamp and adaptive lambda
- The OS-MEM specification bounds each harmonic angle with to limit aliasing. It makes the cancellation weight input-dependent, , to avoid over-cancellation.
- Multi-harmonic Fourier-Lie inscription
- In OS-MEM each token is written at harmonic frequencies . The per-harmonic rotations compose into one rotation in SO(d).
- Householder overwrite
- The specifications propose replacing an outdated key with the reflection , where . This maps the old key to the new one and leaves the orthogonal complement untouched. It appears only in the design documents.
- Streaming subspace whitening
- A Gram-Schmidt step would project each new key onto the orthogonal complement of the last K written keys, so that a new rotation leaves earlier keys untouched. SLH-MEM specifies this as dual-gauge whitening.
- Tensor Core register tile
- HSC-MEM targets a 16x16 FP16 state per head, 512 bytes, held in warp registers and updated with mma.sync instructions. The aim is compute-bound decoding. The tile is a design target, not implemented code.
- Dual-scale memory hierarchy
- HSC-MEM proposes a fast 16x16 Lie micro-state, a slow Grassmannian continuous mixture-of-experts macro-state and a Hopfield critic. Together they are meant to address capacity saturation of the small tile.
- Capacity bound for the perplexity target
- The specifications set the target loss below . They argue that heads, harmonics and a 16-wide tile give 32768 real degrees of freedom per layer, which they claim suffices for perplexity under 5 on 1024 tokens.
- Dissociating experiment ladder
- The specifications order the evidence as rungs: Frobenius norm conservation, MQAR at , perplexity under 5 on a held-out split, and a held-out QA benchmark. The ladder separates numerical correctness, synthetic recall, language modelling and real recall.
- 10M-token orthogonality and needle tests
- The specifications propose checking after updates and needle cosine above 0.98 at . These tests are proposed, not recorded as run.
- Memory paradigm taxonomy
- The DHR-MEM specification compares softmax attention, linear attention, Mamba-style SSMs and Titans against its own design on recall, memory, compute and noise floor.
- QUESTIONS_100 benchmark
- QUESTIONS_100 contains 100 multiple-choice items with three distractors each. They cover published work including the Differential Transformer, Mamba, S4, LoRA, Neural Turing Machines, mixture of experts, ViT, LLaVA and the Kimi Team technical report, plus the lab's Verace Mnemos memory.
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.