Learning State-Tracking from Code: REPL Traces and Probabilistic Automata
Abstract
Over the last years, state-tracking tasks, particularly permutation composition, have become a testbed to understand the limits of sequence models architectures like Transformers and RNNs (linear and non-linear). However, current experiments use a sequence-to-sequence setup: learning to map actions (permutations) to states, that does not translate to the next-token prediction setting commonly used to train language models. We address this gap by converting permutation composition into code via REPL traces that interleave state-reveals through prints and variable transformations. We show that linear RNNs capable of state-tracking excel also in this setting, while Transformers still fail. Motivated by this representation, we investigate why tracking states in code is generally difficult: actions are not always fully observable. We frame this as tracking the state of a probabilistic finite-state automaton with deterministic state reveals and show that adversarial sequences exist where linear RNNs cannot guarantee stable probabilistic state-tracking.
BibTeX
@inproceedings{siems2026learning,
author = {Julien Siems and Riccardo Grazzi and Kirill Kalinin and Hitesh Ballani and Babak Rahmani},
title = {{Learning State-Tracking from Code: REPL Traces and Probabilistic Automata}},
booktitle = {LIT @ ICLR},
year = {2026},
url = {https://openreview.net/forum?id=FqvePVmsKJ},
}Ask Althea to put this paper to the test.
Loading related content...