Compact Reasoning Associative Memory

Benjamin Hoover, Hugh Blayney and James C. R. Whittington

Emerging Form of Reasoning: Looping

5 3 7 6 1 9 5 9 8 6 8 6 3 4 8 3 1 7 2 6 6 2 8 4 1 9 5 8 7 9 5 3 4 6 7 8 9 1 2 6 7 2 1 9 5 3 4 8 1 9 8 3 4 2 5 6 7 8 5 9 7 6 1 4 2 3 4 2 6 8 5 3 7 9 1 7 1 3 9 2 4 8 5 6 9 6 1 5 3 7 2 8 4 2 8 7 4 1 9 6 3 5 3 4 5 2 8 6 1 7 9 Block Slow to train Gradients through ×16+ loops Oversized Millions of weights Unstable

Looping is Slow to Train

Culprit: BackProp Through Time (BPTT)

How can energy-based models be trained?
  1. Looped models learn by backpropagation through time (BPTT). BPTT runs the inference steps, measures the error between the output and the answer, and corrects a portion of the entire path accordingly. Large energy-based reasoners ((cite)) are trained the same way, through their descent.

  2. Energy landscapes can be shaped directly. So long as we know what "real-looking" solution is and what a "fake-looking" solution is, we can shape an energy landscape: low-energy for real data, high-energy for fake data. This lets you train with no backpropagation through any path. The figure above shows how CRAM does this.

Looping Looks Like Energy Descent

x(t+1)=x(t)+fθ(x(t))\state{\boldsymbol{x}}^{(t+1)} = \state{\boldsymbol{x}}^{(t)} + \boldsymbol{f}_{\coupling{\boldsymbol{\theta}}}\big(\state{\boldsymbol{x}}^{(t)}\big)
x(t+1)=x(t)−η ∇xEθ(x(t))\state{\boldsymbol{x}}^{(t+1)} = \state{\boldsymbol{x}}^{(t)} - \eta\,\nabla_{\state{\boldsymbol{x}}} E_{\coupling{\boldsymbol{\theta}}}\big(\state{\boldsymbol{x}}^{(t)}\big)

Looping Looks Like Energy Descent

x(t+1)=x(t)+fθ(x(t))\state{\boldsymbol{x}}^{(t+1)} = \state{\boldsymbol{x}}^{(t)} + \boldsymbol{f}_{\coupling{\boldsymbol{\theta}}}\big(\state{\boldsymbol{x}}^{(t)}\big)
x(t+1)=x(t)−η ∇xEθ(x(t))\state{\boldsymbol{x}}^{(t+1)} = \state{\boldsymbol{x}}^{(t)} - \eta\,\nabla_{\state{\boldsymbol{x}}} E_{\coupling{\boldsymbol{\theta}}}\big(\state{\boldsymbol{x}}^{(t)}\big)

Explicit energy enables rapid training and efficient reasoning.

HYPOTHESIS

CRAM

Compact Reasoning Associative Memory

CRAM Beats Looped Models

  • >1,000× faster training
  • >280× fewer ops, same accuracy
  • No loss in accuracy

CRAM’s Energy Is a Sum of Costs

E(p)=β−1∑ipi⊤log⁡pi⏟negative entropy+12∑i≠jpi⊤Kij pj⏟pair costs+∑ibi⊤pi⏟input costsE(\state{\boldsymbol{p}}) = \underbrace{\beta^{-1}\sum_i \state{\boldsymbol{p}_i}^{\top}\log\state{\boldsymbol{p}_i}}_{\text{negative entropy}} + \underbrace{\frac{1}{2}\sum_{i\neq j}\state{\boldsymbol{p}_i}^{\top}\coupling{\boldsymbol{K}_{ij}}\,\state{\boldsymbol{p}_j}}_{\text{pair costs}} + \underbrace{\sum_i \coupling{\boldsymbol{b}_i}^{\top}\state{\boldsymbol{p}_i}}_{\text{input costs}}
  • pi∈RC\state{\boldsymbol{p}_i} \in \mathbb{R}^{C} the belief of cell ii
  • Kij∈RC×C\coupling{\boldsymbol{K}_{ij}} \in \mathbb{R}^{C\times C} learned cost of each pair of values
  • bi∈RC\coupling{\boldsymbol{b}_i} \in \mathbb{R}^{C} learned cost of each value

Weights memorize associations between valid cells

Train Low Energy at Correct Solutions

JNLL=Ey[−log⁡P(y)],P∝e−E\mathcal{J}_{\mathrm{NLL}} = \mathbb{E}_{\truth{\boldsymbol{y}}}\big[-\log P(\truth{\boldsymbol{y}})\big], \qquad P \propto e^{-E}∇θJNLL=Ey[∇θE(y)]−Ep−∼P[∇θE(p−)]\nabla_{\coupling{\boldsymbol{\theta}}}\mathcal{J}_{\mathrm{NLL}} = \mathbb{E}_{\truth{\boldsymbol{y}}}\big[\nabla_{\coupling{\boldsymbol{\theta}}} E(\truth{\boldsymbol{y}})\big] - \mathbb{E}_{\negative{\boldsymbol{p}^-}\sim P}\big[\nabla_{\coupling{\boldsymbol{\theta}}} E(\negative{\boldsymbol{p}^-})\big]
  • y\truth{\boldsymbol{y}} real solution: lower its energy
  • p−\negative{\boldsymbol{p}^-} negative samples from the model: raise their energy
  • θ\coupling{\boldsymbol{\theta}} learnable parameters

No gradient goes through inference

But sampling is expensive

Train Low Energy at Correct Solutions

training step 0
Energy Ereal solution yfake solutions p−
Training shapes the energy of every board. Along the horizontal axis lie the possible Sudoku boards; one is the real solution (green), and every other board is a fake solution (grey). The blue curve is the energy of each board. Each training step lowers the energy of the real solution and raises the energy of each fake one in proportion to its probability under the model, until the real solution sits at the bottom of a well.
JNLL=−log⁡P(y)\mathcal{J}_{\mathrm{NLL}} = -\log P(\truth{\boldsymbol{y}})

Fast Contrastive Training: Pseudolikelihood

JPL=Eθ(y)⏟lower energy on data+1∣F∣∑i∈Flog⁡∑aexp⁡[−Eθ(pi←a−)]⏟raise energy on one-cell changes\mathcal{J}_{\mathrm{PL}} = \underbrace{E_{\coupling{\boldsymbol{\theta}}}(\truth{\boldsymbol{y}})}_{\text{lower energy on data}} + \underbrace{\frac{1}{|\mathcal{F}|}\sum_{i\in\mathcal{F}}\log\sum_{a}\exp\big[-E_{\coupling{\boldsymbol{\theta}}}(\negative{\boldsymbol{p}^-_{i\leftarrow a}})\big]}_{\text{raise energy on one-cell changes}}
  • pi←a−\negative{\boldsymbol{p}^-_{i\leftarrow a}} generated negative sample: cell ii set to value aa
  • F\mathcal{F} set of free cells

Reasoning Minimizes This Energy

xi←xi−η ∇piE(p),pi=softmax⁡(xi/T)\state{\boldsymbol{x}_i} \leftarrow \state{\boldsymbol{x}_i} - \eta\,\nabla_{\state{\boldsymbol{p}_i}} E(\state{\boldsymbol{p}}), \quad \state{\boldsymbol{p}_i} = \operatorname{softmax}\big(\state{\boldsymbol{x}_i} / T\big)
  • xi\state{\boldsymbol{x}_i} the state of cell ii, and pi\state{\boldsymbol{p}_i} its belief
  • TT temperature, η\eta step size

Noisily sampled with Focused Gibbs

xi←−∑jKˉij pj−bi\state{\boldsymbol{x}_i} \leftarrow -\sum\nolimits_{j} \coupling{\bar{\boldsymbol{K}}_{ij}}\,\state{\boldsymbol{p}_j} - \coupling{\boldsymbol{b}_i}

Step size η=1\eta = 1, one cell at a time

Kˉij=12(Kij+Kji⊤)\coupling{\bar{\boldsymbol{K}}_{ij}} = \tfrac{1}{2}\big(\coupling{\boldsymbol{K}_{ij}} + \coupling{\boldsymbol{K}_{ji}}^{\top}\big)

Cells with high local energy change first

Four Reasoning Benchmarks

A still: one search per task, run with this figure’s code. Enable JavaScript to run the models here.

Sudoku-Extreme
739216485451837296682945371896423157524761938173589642245698713367154829918372564
Solved after 9,303 updates
per chain, 4 chains
Maze-Unique
Solved after 290 updates
N-Queens 8×8
Solved after 218 updates
first of 4 chains to stop
Graph colouring 10
1222322223
Solved after 63 updates
first of 4 chains to stop
Energy of active searchIt stops when a chain’s energy reaches the fitted threshold.020406002000400060008000update stepenergystopping thresholdEnergy of active search020406005000update stepenergystopping threshold
See Maze-Hard ↓

Trained CRAM models running live in your browser. CRAM energy, trained separately from observed puzzle solutions for each task, solves all four kinds of puzzles by minimizing its energy one cell at a time. Feel free to shuffle different puzzle examples. The playback is not in real time: it is slowed down about 10× for Sudoku, about 5,000× for Maze-Unique, and more than 10,000× for N-Queens and graph colouring.

Seven Looped Baselines

  • HRM Hierarchical Reasoning Model 2025
  • TRM Tiny Recursive Model 2025
  • GRAM Generative Recursive Reasoning 2026
  • EqR Equilibrium Reasoners 2026
  • FRM Flow Reasoning Models 2026
  • TRMP Tiny Recursive Message Passing 2026
  • EBR Energy-Based Reasoners 2026

Each retrained with its authors’ code and recipe

More Accurate, 1000× Faster to Train

ModelSudoku-ExtremeMaze-Unique
Solved (%) Params flop / puzzle Fit timeSolved (%) Params flop / puzzle Fit time
HRM54.62±4.18 27.0M 2.20 × 1011 1.2 h39.97±33.90 27.0M 3.01 × 1012 7.1 h
TRM85.73±0.74 5.0M 4.11 × 1011 2.5 h92.23±13.37 6.8M 3.84 × 1012 15.6 h
GRAM96.10† 9.1M 8.51 × 1012 3.2 h98.63±1.31 10.9M 8.00 × 1013 23.2 h
EqR99.49±0.14 5.0M 2.11 × 1014 2.0 h93.00† 263.8K 1.16 × 1014 7.2 h
FRM99.13±0.29 7.0M 3.91 × 1012 2.9 h97.27±2.80 8.0M 4.70 × 1012 9.7 h
TRMP99.87±0.08 32.8K 4.57 × 1012 9.0 h99.23±0.31 60.7K 1.80 × 1013 7.6 h
EBR99.85±0.05 1.8M 3.37 × 1011 2.8 h89.80±6.35 1.8M 1.93 × 1013 2.0 h
CRAM100.00±0.00 7.7K 2.02 × 109 0.04 s100.00±0.00 18 8.37 × 105 0.13 s
(hand-set)‡100.00±0.00 1 1.08 × 108 —100.00±0.00 3 8.37 × 105 —

Solved: mean ± SD over three training runs. Params: nonzero parameters. flop / puzzle: mean inference operations per puzzle, every search chain and failed search included. Fit time: one run on one H200. † Published accuracy, shown where our reproduction scored lower. ‡ Weights set by hand from the task's rules; Params counts unique nonzero values.

N-Queens and Graph Colouring: Seconds, Not Hours

ModelNN-Queens 8×8N-Queens 10×10Graph colouring 8Graph colouring 10ParamsFit time
Solved (%)Cov@20Solved (%)Cov@20ConflictsCov@20ConflictsCov@20
HRM—84.4158.837.80†10.7139.720.6182.76.227.3M≥ 41 min
TRM—67.3951.417.50†3.3118.021.8169.06.96.8M≥ 54 min
GRAM199.44—88.91—3.3—52.7—10.9M≥ 53 min
20100.0097.999.9892.93.387.952.737.8
EBR1100.00—99.31—0.0—0.3—7.1M≥ 3.2 h
2099.9598.199.9992.52.788.90.754.8
CRAM199.95—99.45—0.0—0.3—≤ 869≤ 6.8 s
20100.0097.999.9993.60.088.90.052.6
(hand-set)1100.00—99.99—0.0—0.0—≤ 2—
20100.0098.4100.0095.50.090.60.055.2

Same Accuracy With 282× Fewer Operations

stops early fixed compute
top 2%9899100CRAMEBRTRMPFRMEqR020406080100CRAMEBRTRMFRMHRMGRAMTRMPEqR282×fewer operations0.010.11101001,00010,000100,0001,000,000Gflop per puzzle (mean, log scale)puzzles solved (%)
Each looped model's best, and what CRAM needs for the same accuracy
ModelBest solvedGflop per puzzleCRAM's Gflop at same accuracy
EBR99.86%5421.92 (282× fewer)
TRM89.72%8231.14 (722× fewer)
HRM57.10%4410.46 (958× fewer)
TRMP99.87%4,7341.92 (2,467× fewer)
FRM99.42%7,8101.59 (4,900× fewer)
GRAM94.74%17,0201.32 (12,894× fewer)
EqR99.49%210,6001.65 (127,869× fewer)

Energy Enables Adaptable Compute

CRAMEBRFRM
10710910111013FLOPs per puzzle96979899100solved (%)012–34–78–1516–3132–6364+difficulty rating of the puzzle (dataset)

CRAM Never Stops at a Wrong Answer

Wrong stops (%)
Stopping ruleSudokuMaze
HRM halting head0.620.16
TRM halting head2.373.54
EqR halting head1.611.06
TRMP halting head0.050.73
EBR gradient-norm stop0.21–*
CRAM energy threshold0.000.00

* EBR's gradient-norm stop does not work on Maze-Unique: its gradient norm stays near 2 even at correct mazes, so EBR's published maze protocol runs a fixed number of segments.

Local Training Is Fastest

PseudolikelihoodMin. probability flowOne-step BPTTContrastive divergenceFull BPTT
025507510099%Dev Puzzles Solved (%)10 ms100 ms1 s10 s100 sTraining Time on One H200

512 Sudoku-Extreme dev puzzles. Line: mean of 20 runs. Shading: 25th–75th percentile (thin where runs agree). Dot: mean first reaches 99%.

CRAM has Data Efficient Training

CRAMEBRFRMTRM
025507510098%Test Puzzles Solved (%)1101001k10k100kUnique Training Puzzles (+99 augmentations each)

10,000 Sudoku-Extreme test puzzles. Line: median of 6 training runs per method. Small dots: single runs.

Hand-Set Weights Solve Every Benchmark

  • Sudoku-Extreme: 1 weight
  • Maze-Unique: 3 weights
  • N-Queens: 2 weights
  • Graph colouring: 1 weight

A high score shows only that a model learned a few pairwise rules

Weights Learn Rules of Puzzle

Left: the learned Sudoku costs between one cell and every other cell, nonzero only between equal digits in the same row, column or box. Right: the 3 by 3 window of Maze-Unique weights.

What’s Next?

Maze-Hard Has Loops

A Maze-Unique maze, with one path from S to G, beside a Maze-Hard maze, which has loops and is labeled with one shortest path
  • Maze-Unique: one unique path

  • Maze-Hard: many paths

    • We need the shortest that obeys preferences

Add a Layer of Hidden Neurons

1. Hidden neurons settle, one per open cell

Ez(z)=∑i[m2 zi2−12∑j∈N(i)zi zj]−zGE_z(\state{\boldsymbol{z}}) = \sum\nolimits_i \Big[\tfrac{\coupling{m}}{2}\,\state{z_i}^2 - \tfrac{1}{2}\sum\nolimits_{j \in \mathcal{N}(i)} \state{z_i}\,\state{z_j}\Big] - \state{z_{\mathrm{G}}}

2. Answers relax, linked through the settled z⋆\state{\boldsymbol{z}}^\star

xi←−∑j(Kˉij−Lij(z⋆)diag⁡(0,1)) pj−bi\state{\boldsymbol{x}_i} \leftarrow -\sum\nolimits_j \big(\coupling{\bar{\boldsymbol{K}}_{ij}} - \coupling{L_{ij}}(\state{\boldsymbol{z}}^\star)\operatorname{diag}(0,1)\big)\,\state{\boldsymbol{p}_j} - \coupling{\boldsymbol{b}_i}

+11 learned parameters: 29 total

One Hidden Layer Solves Maze-Hard

A still: one search, run with this figure’s code. Enable JavaScript to run the model here.

Maze-Hard
SG
Solved: phase 1 took 128 steps,
phase 2 took 112 steps
Phase 1: hidden relaxation02004000255075100125hidden update stepneurons not settledPhase 1: hidden relaxation0200400050100hidden update stepneurons not settled
Phase 2: visible relaxation−6000−4000−2000020406080100visible update stepenergyPhase 2: visible relaxation−6000−4000−2000050100visible update stepenergy

hidden neurons z (phase 1), darker nearer G visible cells on (phase 2) path at the stop

CRAM, with an added hidden layer of neurons, can solve Maze-Hard. The objective of Maze-Hard is to find the shortest path from start to goal, and if there are multiple shortest paths, to find the one that follows a preferred configuration of turns. The 29 trained weights run in your browser on test mazes. Feel free to shuffle the test maze.

Learning Latent Variables is an Open Problem

ARC: new hidden rule for every task

General reasoning needs to learn meaningful latents

Energies Learn to Reason, 1000× Faster

Training CRAM: the energy of a Sudoku solution is pulled down and the energies of the solution with one cell changed are pushed up
  • >1,000× faster training than looped models
  • 282× fewer operations at the same accuracy
  • Never stops at a wrong answer
  • Rules you can read from the weights
  • ⚠️Sudoku and Maze benchmarks are too easy⚠️

Explicit energy is an extremely promising direction for reasoning

QR code for bhoov.com/research/cram

bhoov.com/research/cram