Skip to content
Projets

À propos

[ICML 2026] Code for Equilibrium Reasoners: learning attractor dynamics for scalable reasoning

IA et apprentissage automatique

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
+1
in 15 days
+1
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

Equilibrium Reasoners icon Equilibrium Reasoners

Learning Attractors Enables Scalable Reasoning

Benhao Huang · Zhengyang Geng · Zico Kolter
CMU

arXiv HF Model HF Data

Code for reproducing EqR experiments on Sudoku-Extreme and Maze-Unique.

EqR recurrent inference EqR recurrent inference

Setup

uv venv
source .venv/bin/activate
uv pip install -r requirements.txt

adam-atan2 must install its CUDA backend (adam_atan2_backend); a Python-only install is not sufficient for training. Build it in an environment where CUDA and Python headers are available:

# If CUDA is not already configured, point CUDA_HOME at the active CUDA
# toolkit. For example:
# export CUDA_HOME="$(dirname "$(dirname "$(which nvcc)")")"
# export PATH="$CUDA_HOME/bin:$PATH"

# Optional: set this when building without visible GPUs or when cross-compiling.
# Examples: H100=9.0, A100=8.0, RTX 4090/L40=8.9.
# export TORCH_CUDA_ARCH_LIST=9.0

python -m pip install --no-build-isolation --no-cache-dir --force-reinstall \
  adam-atan2==0.0.3
python - <<'PY'
from adam_atan2 import AdamATan2
import adam_atan2_backend
print(AdamATan2, adam_atan2_backend.__file__)
PY

Maze training also requires FlashAttention on CUDA.

FlashAttention install notes

EqR follows the HRM attention import pattern: prefer FlashAttention-3 via flash_attn_interface when available, and fall back to FlashAttention-2 via flash_attn. On NVIDIA Hopper GPUs, FlashAttention-3 is recommended. If a local wheel is available:

python -m pip install --no-deps <path-to-flash-attn-3-wheel.whl>
python - <<'PY'
import flash_attn_interface
print(flash_attn_interface.__file__)
PY

If FlashAttention-3 is unavailable, install FlashAttention-2:

python -m pip install flash-attn --no-build-isolation
python - <<'PY'
from flash_attn import flash_attn_func
print(flash_attn_func)
PY

For W&B defaults, copy config/secrets.example.yaml to config/secrets.yaml and fill in your entity/project. config/secrets.yaml is ignored by git.

Data

Default dataset paths:

Dataset Path
Sudoku-Extreme data/sudoku-extreme-1k-aug-1000
Maze-Unique data/maze-30x30-unique-1k

Download datasets:

bash scripts/download_artifacts.sh

Download datasets and pretrained checkpoints:

bash scripts/download_artifacts.sh --with-ckpts

The helper downloads Hugging Face snapshots under downloads/eqr-artifacts, copies datasets into data/, and copies checkpoints into downloaded_checkpoints/.

Checkpoint paths:

downloaded_checkpoints/sudoku-extreme/eqr.pth
downloaded_checkpoints/maze-unique/eqr.pth

Optional: rebuild datasets

Dataset rebuild commands

Use these commands only if you want to regenerate the datasets instead of downloading locuslab/EqR-data.

Sudoku-Extreme follows the sapientinc/HRM setup. The builder downloads train.csv and test.csv from sapientinc/sudoku-extreme, converts them to HRM/EqR-compatible NumPy arrays, and augments only the training split with Sudoku-preserving digit, row, column, and transpose transformations.

Default EqR/HRM small-sample dataset:

python -m dataset.build_sudoku_dataset \
  --output-dir data/sudoku-extreme-1k-aug-1000 \
  --subsample-size 1000 \
  --num-aug 1000 \
  --seed 42

Full Sudoku-Extreme dataset:

python -m dataset.build_sudoku_dataset \
  --output-dir data/sudoku-extreme-full \
  --seed 42

The generated directory should contain train/, test/, and identifiers.json. Each split contains dataset.json plus all__inputs.npy, all__labels.npy, all__puzzle_identifiers.npy, all__puzzle_indices.npy, and all__group_indices.npy.

Additional Sudoku-Extreme options:

python -m dataset.build_sudoku_dataset --help

Build Maze-Unique:

python dataset/build_maze_unique_dataset.py \
  --output-dir data/maze-30x30-unique-1k \
  --grid-size 30 \
  --train-samples 1000 \
  --test-samples 1000 \
  --maze-mode perfect \
  --length-distribution uniform \
  --min-path-length 100 \
  --max-path-length 140 \
  --require-unique \
  --dedupe

Training

scripts/train.sh launches torchrun --standalone with one local process by default. Override NPROC_PER_NODE only when you want multi-GPU training:

bash scripts/train.sh eqr_sudoku
bash scripts/train.sh trm_sudoku
bash scripts/train.sh eqr_maze_unique
bash scripts/train.sh trm_maze_unique
bash scripts/train.sh hrm_maze_unique

NPROC_PER_NODE=2 bash scripts/train.sh eqr_maze_unique
Dataset Config Training budget
Sudoku-Extreme config/train/eqr_sudoku.yaml 50k
Sudoku-Extreme TRM baseline config/train/trm_sudoku.yaml 50k
Maze-Unique config/train/eqr_maze_unique.yaml 150k
Maze-Unique TRM baseline config/train/trm_maze_unique.yaml 150k
Maze-Unique HRM baseline config/train/hrm_maze_unique.yaml 150k

Maze-Unique: Tuning and Small Models

Our Maze-Unique experiments in the EqR paper used a limited hyperparameter search because of compute constraints. Broader tuning lets EqR reach 100% validation exact accuracy with substantially smaller models on the released 30x30 task, motivating a search for the minimum model size.

The width sweep points to a capacity boundary around d=42 (39.9K core parameters): EqR reaches 98.6% peak exact accuracy, while the equally sized TRM reaches 89.4% after 24 LR/weight-decay trials within 150K updates. A separate HRM control at a nearby parameter budget (d=24, 41.8K core parameters) records 0% peak exact accuracy across nine LR/WD trials with a 150K training budget. Full curves, search ranges, and reproduction scripts are in the Maze-Unique supplement.

Evaluation

scripts/eval.sh uses config/eval/depth_breadth.yaml. By default it runs depth 16 with breadth 1.

bash scripts/eval.sh /path/to/checkpoint.pth
bash scripts/eval.sh /path/to/checkpoint.pth halt_max_steps=64
bash scripts/eval.sh /path/to/checkpoint.pth \
  halt_max_steps=64 different_init=128 convergence_top_k=1 global_batch_size=16

After downloading checkpoints, evaluate the pretrained EqR models:

bash scripts/eval.sh downloaded_checkpoints/sudoku-extreme/eqr.pth
bash scripts/eval.sh downloaded_checkpoints/maze-unique/eqr.pth

Evaluation config:

config/eval/depth_breadth.yaml

Reproduce Sudoku results

The Sudoku results in the paper use depth 64, breadth 128, convergence-based top-4 selection, Langevin noise scale 0.5, and latent reset scale 1.0. Use the dedicated configs below for the released Sudoku checkpoint.

Quick 2048-sample smoke eval:

python evaluate.py \
  eval_yaml=config/eval/sudoku_lite_noise05.yaml \
  checkpoint=downloaded_checkpoints/sudoku-extreme/eqr.pth

This runs global_batch_size=128 for max_eval_steps=16 and is intended as a fast sanity check before launching the full evaluation. Over 5 seeds, this took about 40 minutes on 2 80GB GPUs and gave:

Metric Mean +/- std
convergence_top_k/cumulative_exact_acc_top1 99.19 +/- 0.12
convergence_top_k/exact_accuracy 98.60 +/- 0.04
majority_vote/exact_accuracy 98.67 +/- 0.05
different_init/any_correct 99.20 +/- 0.10

To reproduce the smoke-eval standard deviation, repeat the same command with seed=<n> and a unique suffix=... for each run.

Full paper-scale eval (400k+ eval samples):

python -m torch.distributed.run --standalone --nproc-per-node 8 evaluate.py \
  eval_yaml=config/eval/sudoku_full_noise05.yaml \
  checkpoint=downloaded_checkpoints/sudoku-extreme/eqr.pth

For the full paper-scale run, keep global_batch_size=768 and breadth 128. With 8 GPUs, this is 96 examples per GPU per eval step. For multi-node Slurm launches, pass the same evaluate.py arguments to your distributed launcher. Our 8-GPU reference run used about 55 GiB per GPU and took about 33.6 hours; a 16-GPU run took about 17 hours. The 8-GPU run produced:

Metric Value
convergence_top_k/cumulative_exact_acc_top1 99.7902
convergence_top_k/exact_accuracy 99.5570
majority_vote/exact_accuracy 99.5973
different_init/any_correct 99.7984

The metrics are percentages. The smoke-eval standard deviation is the sample standard deviation across seeds over 2048 examples per run. The full result above was evaluated over 423,168 total examples from the released Sudoku-Extreme checkpoint.

Acknowledgements

This codebase builds on the HRM and TRM repositories.

License

This project is released under the Apache License 2.0. See LICENSE for details.

Citation

@article{huang2026equilibrium,
  title={Equilibrium Reasoners: Learning Attractors Enables Scalable Reasoning},
  author={Huang, Benhao and Geng, Zhengyang and Kolter, Zico},
  journal={arXiv preprint arXiv:2605.21488},
  year={2026}
}

Explorer des projets similaires

Chargement…