Correspondence: a.wasi@surrey.ac.uk
Chain-of-thought (CoT) constructions that make transformers Turing complete typically simulate a counter machine, one transition per generated token, making autoregressive length proportional to the simulated runtime. Since serial generation is a key computational cost, we ask whether this length can be reduced while preserving the recognized language and the generalization properties of the simulation.
We introduce two machine rewrites with exact recognition guarantees. First, order k macro transitions combine k reachable base transitions into one token. We prove that the resulting guards retain the per-counter threshold structure, determinism is preserved, and a run of length T is compressed to about T/k steps for fixed k, a constant factor reduction that leaves the asymptotic serial complexity unchanged, with a vocabulary bounded by the base vocabulary raised to k. Second, base b counting compresses monotone decrement bursts by processing b counter units per token. Both rewrites remain within the same CoT counter programming class, allowing the base construction's length generalization result to transfer under its assumptions.
Experiments on six synthetic counter machine tasks, including equal-count and three-sum arithmetic verification, show that transformers trained on compressed traces retain length generalization under moderate compression while achieving the predicted reductions in trace length, and that this retention degrades once compression becomes large relative to the counting range. We observe corresponding reductions in generation latency, attention operations, and key value cache size. We further characterize reachable vocabulary growth and quantify the associated data scaling cost.
The CoT construction writes one token per counter-machine transition, so the trace is as long as the run. We rewrite the simulated machine so it takes fewer, larger steps, and we prove the rewritten machine stays inside the CoT counter programming class. The transformer architecture and the compilation result are unchanged.
Every reachable block of k consecutive base transitions becomes one macro token.
A monotone decrement burst that removes V units one at a time is rewritten to remove b units per token.
The rewrites are exact. Each result below holds for any deterministic guarded-update counter machine.
A macro guard is equivalent to a per-counter interval constraint ℓi ≤ xi ≤ hi, so composing transitions stays within the threshold guards of the base construction.
If the base machine is deterministic, so is the order-k macro machine: exactly one macro token is enabled at each reachable configuration.
On an input where the base machine halts after T steps, the macro machine halts after exactly ⌈T/k⌉ steps in the same halting state, and it recognizes the same language.
The macro vocabulary satisfies |Δ(k)| ≤ ∑r=1..k |Δ|r. For single-successor loops the reachable vocabulary grows linearly in k (Proposition 3).
The macro machine is a CoT counter program, so the same construction compiles it into a transformer, and length generalization guarantees for the base machine transfer under the same assumptions.
A burst of mass V takes ⌈V/b⌉ tokens instead of V. Combined with macro order k, counting-dominated runs shrink by about a factor of bk.
A four-layer transformer (width 128, about 5.3×105 parameters, no positional encoding) is trained on 5,000 compressed traces with inputs up to length 64, then tested on in-range inputs (EM0) and on longer inputs up to length 96 (EM1) and 128 (EM2).
Compression removes serial positions, not information. For the generated trace, decode steps and key-value cache scale as 1/c and attention operations as about 1/c2, where c is the compression factor. The fixed input prefix is not compressed, so end-to-end savings are smaller when the prefix dominates.
| Task | Setting | Mean trace | Latency (ms) | Attention FLOPs | KV bytes | Vocabulary |
|---|---|---|---|---|---|---|
| comparison | k = 1 | 17.21 | 16.40 | 8.02×104 | 17,621 | 9 |
| comparison | k = 2 | 8.79 | 7.95 | 2.20×104 | 9,002 | 12 |
| comparison | k = 3 | 6.00 | 5.38 | 1.08×104 | 6,144 | 15 |
| mod 3 | b = 1 | 32.83 | 33.09 | 2.84×105 | 33,621 | 11 |
| mod 3 | b = 2 | 17.17 | 15.74 | 7.98×104 | 17,578 | 14 |
| mod 3 | b = 4 | 9.42 | 8.33 | 2.51×104 | 9,642 | 20 |
Forced-length greedy generation on one CPU core; attention FLOPs and KV bytes count the generated trace portion. From k = 1 to k = 3 on comparison, latency falls 3.0× and attention operations 7.5×.
Each macro token is a new symbol the model must learn. The worst-case vocabulary grows exponentially in k, but the reachable vocabulary in the studied machines grows about linearly. A wider alphabet still needs more training data.
@article{wasi2026shorter,
title = {Shorter Chains via Macro Transitions: Constant-Factor
Compression for Chain-of-Thought Counter Simulation},
author = {Wasi, Azmine Toushik and Islam, MD Shafikul and
Ahsan, Md Manjurul},
journal = {Transactions on Machine Learning Research},
year = {2026},
url = {https://openreview.net/forum?id=HGmCGa0Q3O}
}