This repository contains the Dedicated Heads checkpoint for the 2D deterministic V=2, K=5 cellular-automaton task introduced in Spatial Induction Heads: In-Context Learning of Multidimensional Cellular Automata.
The model performs in-context learning of cellular-automaton rules. It receives the first frames of a trajectory generated by an unknown rule and predicts the rest of the trajectory. The rule table is never given to the model, and test trajectories are generated by rules that were not seen during training.
| Property | Value |
|---|---|
| Model key | 2d-det-v2k5-dedicated |
| Task | 2D deterministic cellular automata |
| Number of cell states V | 2 |
| Neighborhood size K | 5 (von Neumann) |
| Grid | 6×6 (torus, periodic boundaries) |
| Trajectory length T | 12 |
| Context length M | 8 |
| Architecture | Dedicated Heads |
| Transformer layers | 2 |
| Attention heads per layer | [8, 1] |
| MLP per layer (1 = yes, 0 = no) | [0, 1] |
| Hidden dimension | 1024 |
| MLP dimension | 4096 |
| Positional encoding | learned absolute |
| Checkpoint file | checkpoint.pt |
T is the total number of frames in a trajectory and M is the number of initial frames given as context. The model predicts frames M to T-1.
The Dedicated-heads architecture has two layers. The first layer is attention-only with 8 heads (one head per neighbor); the second layer has one attention head and one MLP.
The paper's construction implements a two-stage spatial induction head:
See the paper for the full construction and mechanistic analysis.
Cell states are token IDs 0, 1. The time-separator token has ID 2 and the row-separator token has ID 3.
A trajectory is serialized frame by frame. Each frame is flattened row by row with a row separator between rows, and a time separator is placed between consecutive frames. The model produces next-token logits over this sequence.
The inference utilities in the code repository convert between trajectories and token sequences, so you normally do not need to handle tokens yourself.
Each trajectory starts from an initial frame whose cells are sampled independently and uniformly over the V states. A single rule is applied at every step, with periodic boundary conditions.
There are 2^32 possible rules on the 5-cell von Neumann neighborhood (north, west, center, east, south). Each rule is grouped with its 0/1 complement, and rules are stratified by fold-k, the smaller of the number of 1s and the number of 0s in the rule table. The train, validation and test pools are disjoint at the class level, and validation and test rules are drawn balanced across fold-k.
Validation and test trajectories are kept only if all 32 neighborhood configurations appear in the context frames, so every entry of the rule table can be inferred from the context. Training trajectories are not filtered.
The original training set contained 50 million trajectories. The training script in the code repository generates fresh trajectories from the same distribution on the fly, and the released rule pools ship with the code.
| Hyperparameter | Value |
|---|---|
| Optimizer | AdamW |
| Learning rate | 0.001 |
| Weight decay | 0.2 |
| Adam betas | (0.9, 0.95) |
| Schedule | cosine with linear warmup |
| Warmup ratio | 0.004 |
| Global batch size | 1024 |
| Dropout | 0.0 |
| Epochs (maximum) | 5 |
| Checkpoint selection | best held-out-rule validation teacher-forced sequence accuracy |
| Precision | bfloat16 autocast |
| Random seed | 42 |
One epoch is 50 million training trajectories. Validation runs every 5000 optimizer steps.
The model is evaluated on test trajectories generated by held-out rules. Only cell tokens in frames M to T-1 are scored.
| Metric | Value |
|---|---|
| Teacher-forced sequence accuracy | 0.9989 |
| Teacher-forced cell accuracy | 1.0000 |
| Autoregressive cell accuracy | 0.9999 |
The paper-reported results for all released models are in configs/paper_results.json.
Clone and install the accompanying code. Install a PyTorch build that matches your hardware first.
git clone https://github.com/sdean-group/ICL-CA.git
cd ICL-CA
pip install -e .
Load the checkpoint and run inference:
from src import load_pretrained, generate_example, predict, plot_prediction
bundle = load_pretrained("2d-det-v2k5-dedicated")
# A rule drawn from the held-out test split.
example = generate_example(bundle.spec, seed=0)
result = predict(bundle, example)
print(result.metrics)
plot_prediction(example, result)
load_pretrained downloads checkpoint.pt from the Hugging Face Hub and caches it locally. A complete interactive example is in quickstart.ipynb.
bash scripts/eval.sh 2d-det-v2k5-dedicated # full evaluation
N=2000 bash scripts/eval.sh 2d-det-v2k5-dedicated # quicker, fewer trajectories
Results are written to results/. To retrain this model from scratch:
bash scripts/train.sh 2d-det-v2k5-dedicated
This checkpoint is intended for:
This checkpoint is one of 12 models in the Spatial Induction Heads collection. The collection covers 1D V=2, K=3; 1D V=3, K=3; and 2D V=2, K=5 (von Neumann) tasks, each with deterministic and stochastic rules and with Shared-head and Dedicated-heads architectures.
This model is released under the MIT License.
@misc{Kazemian2026:spatial,
title = {Spatial Induction Heads: In-Context Learning of Multidimensional Cellular Automata},
author = {Kimia Kazemian and Menghan Xu and John Thickstun and Sarah Dean},
year = {2026},
eprint = {2610.09124},
archiveprefix = {arXiv},
primaryclass = {cs.LG},
url = {https://arxiv.org/abs/2610.09124}
}