Chain of Thought in Order: Discovering Learning-Friendly Orders for Arithmetic

Yuta Sato, Kazuhiko Kawamoto, Hiroshi Kera · Submission to ICLR 2026 · Withdrawn

TL;DR

Autoregressive Transformers are exquisitely sensitive to the order in which reasoning steps are decoded, yet finding the optimal sequence typically relies on human heuristics. This paper introduces an automated framework that discovers "learning-friendly" token orders by profiling early training-loss dynamics across candidate permutations. Using a two-stage hierarchical search, the method navigates search spaces with billions of permutations to recover optimal token orders—including rediscovering the reverse-digit order known to unlock multi-digit multiplication.

What Problem Does This Paper Address?

When Transformers perform step-by-step reasoning (such as chain-of-thought or multi-digit arithmetic), autoregressive decoding generates each token conditioned only on preceding tokens. If intermediate operations involve non-injective or non-invertible steps (like modular squaring, ReLU thresholding, or carrying digits), reversing or shuffling the sequence forces the network to infer ambiguous latent states.

Prior work demonstrated that simple changes—such as outputting integer multiplication results from least-to-most significant digit—drastically boost accuracy and generalization. However, selecting optimal generation orders has remained a manual trial-and-error process. Optimizing permutations directly is challenging: continuous relaxations ("soft" permutation matrices) cause information leakage across time steps, while discrete search over a sequence of length $L$ confronts a combinatorial explosion of $L!$ candidates.

Methods

The authors introduce loss profiling coupled with a hierarchical search:

  1. Loss Profiling via Early Learning Dynamics: Leveraging the phenomenon that deep networks fit "easy" examples before memorizing "hard" ones, the authors train a lightweight Transformer (a 1-layer, 1-head GPT-2) for just 1–2 epochs (800–1,600 steps) on a mixture of target sequences permuted under different candidate orders. Candidates that yield the steepest loss drops in early training reliably identify learning-friendly orders.
  2. Two-Stage Hierarchical Exploration:
  3. Global Stage: Splits length-$L$ sequences into $k$ coarse blocks and tests macro-level block permutations using loss profiling down to depth $K$.
  4. Local Stage: Freezes the discovered coarse block structure and performs intra-block token reordering for block sizes $l \in \{2, \dots, \lfloor L/2 \rfloor\}$, followed by inter-block swapping.
  5. Search Space Initialization: Evaluated under uniform random initializations ($P_r$) as well as structured, block-restricted initializations ($P_b$, grouping tokens into blocks of size $b=5$).

Datasets

The authors evaluate their method on synthetic arithmetic benchmarks constructed via non-injective recurrences $y_i = f(X, y_1, \dots, y_{i-1})$:

  • RELU: $y_1 = x_1$; $y_i = \max(x_i + y_{i-1}, 0)$.
  • SQUARE-19: $y_1 = x_1$; $y_i = (x_i^2 + y_{i-1}^2) \pmod{19} \in \{-9, \dots, 9\}$. Squaring destroys sign information, making reverse-order prediction severely ambiguous.
  • INDEX: Dynamic element lookup $y_i = x_p$ with pointer $p = \sum_{j=1}^d y_{i-j} \pmod L$ across window sizes $d \in \{2, 4, 8\}$.
  • PROD (Integer Multiplication): Predicting the product of two multi-digit integers, comparing canonical most-to-least vs. least-to-most (carry-friendly) digit order.

Datasets consist of 100,000 training sequences and 1,000 evaluation sequences, with lengths $L$ ranging from 5 to 100.

Key Insights and Ideas

  • Early-stage loss mirrors long-term learnability: The relative validation loss after only 1–2 epochs on a mixed-order dataset correlates strongly with final downstream task accuracy, allowing unpromising permutations to be eliminated without full training runs.
  • Sparsity alone is insufficient: While learning-friendly orders naturally yield sparser attention distributions (lower Shannon entropy across attention weights), directly optimizing for attention sparsity fails because static attention mass decreases regardless of sequence coherence.
  • Small exploration models generalize to large ones: The ranking of learning-friendly orders is architecture-universal. A tiny, single-layer model efficiently sifts through candidates, and the discovered permutation can then be transferred to train a 6-layer Transformer to high accuracy.

Key Results

  • Forward vs. Reverse Performance: On RELU, SQUARE-19, and INDEX, forward orders reach 99.4%–100% accuracy, whereas training in reverse order causes accuracy to plummet below 10% (and down to 0.0% for longer sequences).
  • Combinatorial Recovery: Starting from purely random permutations ($P_r$), the hierarchical search successfully recovers the optimal forward order for sequences up to $L = 13$—pinpointing the single correct permutation out of $13! \approx 6.2 \times 10^9$ possibilities.
  • Scaling with Block Constraints: Using block-structured initialization ($P_b$), the method scales up to $L = 30$ on SQUARE-19 and $L = 40$ on RELU (a search space containing $\sim 10^{47}$ theoretical permutations).
  • Rediscovering Multi-Digit Arithmetic Orders: On PROD ($L = 10$), the algorithm automatically discovers the reverse-digit (least-to-most significant) order previously identified by human researchers to handle addition carries.
  • Exploration Speed: The entire search runs in 1 to 7 hours on a single NVIDIA A6000 Ada GPU.

Limitations and Future Work

  • Fixed-Length Sequences: The current formulation assumes fixed target sequence lengths $L$; extending the search to variable-length outputs remains an open challenge.
  • Domain Scope: Experiments are focused on synthetic recurrences and integer arithmetic where causal dependencies are deterministic and local. Extending the approach to open-ended natural language reasoning and general symbolic reasoning remains for future work.

Summary updated

Abstract

The chain of thought, i.e., step-by-step reasoning, is one of the fundamental mechanisms of Transformers. While the design of intermediate reasoning steps has been extensively studied and shown to critically influence performance, the ordering of these steps has received little attention, despite its significant effect on the difficulty of reasoning. This study addresses a novel task of unraveling the chain of thought—reordering decoder input tokens into a learning-friendly sequence for Transformers, for learning arithmetic tasks. The proposed pipeline first trains a Transformer on a mixture of target sequences arranged in different orders and then identifies benign orders as those with fast loss drops in the early stage. As the search space grows factorially in sequence length, we propose a two-stage hierarchical approach for inter- and intra-block reordering. Experiments on four order-sensitive arithmetic tasks show that our method identifies a learning-friendly order out of a few billion candidates. Notably, on the multiplication task, it recovered the reverse-digit order reported in prior studies.
BibTeX
@inproceedings{sato2025chain,
  author = {Yuta Sato and Kazuhiko Kawamoto and Hiroshi Kera},
  title = {{Chain of Thought in Order: Discovering Learning-Friendly Orders for Arithmetic}},
  booktitle = {AI4MATH @ ICML},
  year = {2025},
  url = {https://openreview.net/forum?id=2H0rA0gaxX},
}
Figure