Autoregressive Transformers generally fail on out-of-distribution reasoning due to two primary reasons: positional corruption over long sequences and structural state drift across deep execution steps. We introduce ORION, a framework that supervises exact canonical execution states via auxiliary heads to anchor latent trajectories to valid computational manifolds. Across Folding, GridShift, and CLRS-30, a pre-registered 2 x 2 factorial shows that RoPE and ORION address orthogonal axes. RoPE recovers length extrapolation (59.8%), while ORION recovers depth extrapolation (66.7%). Moreover, their combination complementarily achieves strict additive gain in joint length-depth extrapolation, while either method alone offers near satisfactory results. Negative controls confirm that the gain depends strictly on exact canonical alignment; hashed state statistics fail to constrain depth extrapolation.
Figures & tables
Task Domain
Canonical State Φ
Train Dataset Split
Joint OOD Test Split
Folding
Quadrant layer map μ(S)
S∈{4,6},D∈[1,4]
S=8,D∈[5,8]
GridShift
Origin-per-cell permutation
S∈{4,6},D∈[1,4]
S=8,D∈[5,8]
CLRS (8 Tasks)
Algorithmic Hints
N=16 Nodes
N=64 Nodes
Table 1: Structural properties and evaluation parameters for the algorithmic reasoning task splits.
Benchmark & Regime
Baseline ↑
RoPE Only ↑
ORION Only ↑
ORION + RoPE ↑
FOLDING
In-Domain ( S,D )
0.970 ± 0.003
0.978 ± 0.002
0.978 ± 0.004
0.985 ± 0.003
Size Only ( S=8 )
0.171 ± 0.009
0.191 ± 0.008
0.171 ± 0.008
0.196 ± 0.010
Depth Only ( 2×D )
0.021 ± 0.008
0.651 ± 0.016
0.026 ± 0.008
0.667 ± 0.018
Joint OOD ( S=8,2×D )
0.004 ± 0.004
0.018 ± 0.008
0.004 ± 0.004
0.022 ± 0.009
GRIDSHIFT
Table 2: Out-of-distribution exact-match (EM) accuracy across algorithmic benchmarks. Folding and GridShift models are trained on state size Strain≤6 and execution depth Dtrain≤4 ; the joint split tests S=8 at depth 5 – 8 . In-domain, size-only, and depth-only results are averaged over three random seeds and reported as mean ± standard deviation. The joint split uses seed-0 checkpoints and reports the half-width of a 95% bootstrap interval over 1,000 test instances. CLRS is a single-seed pilot over eight algorithms. ↑ indicates higher is better.
Figure 1: ORION + RoPE keeps computing the canonical state beyond the training depth. Exact accuracy of the canonical-state read-outs by execution depth (seed 0; shaded region: training depths). (a, b) The answer set read directly from the latent at the decision position, without autoregressive decoding, on Folding and GridShift . (c) The occupancy map on Folding . With absolute positions the read-outs collapse at the first unseen depth ( 0.04 , 0.19 , 0.06 ); with RoPE they remain at 0.63 , 0.67 and 0.85 at depth 5 and decay gradually, so the state is still being tracked where it was never supervised.
Figure 2: ORION composes with RoPE on depth extrapolation. (a,b) Exact match at execution depths 5 – 8 , after training at depths 1 – 4 , for RoPE alone and ORION + RoPE on Folding and GridShift . Bands show ± one standard deviation over three seeds. Printed values give the paired-by-example difference at each depth; stars indicate p<0.05 . Across all held-out depths, ORION + RoPE improves over RoPE by +0.016 on Folding ( p=0.036 ) and +0.024 on GridShift ( p=0.002 ). (c) The corresponding difference across model widths in the five-seed scaling ladder. The gains are +0.000 , +0.004 , and +0.082 at 3.5 M, 11 M, and 26 M parameters, respectively; the largest model favors the combined condition in all five seeds.
Control Condition
Loss Target Laux
FOLDING Joint EM ↑
GRIDSHIFT Joint EM ↑
Baseline + RoPE
None
0.018 ± 0.008
0.224 ± 0.025
N1: Compute-matched
None ( 1.5× steps)
0.004 ± 0.004
0.050 ± 0.014
N2: Random Targets
Φrand(S)
0.002 ± 0.003
0.043 ± 0.013
N3: Inconsistent State
Φ(S)+ϵ,ϵ=0.25
0.005 ± 0.005
0.037 ± 0.012
N4: Shuffled Targets
Φ(Sπ(t))
0.002 ± 0.003
0.052 ± 0.014
N5: Hashed Statistics
hash(Φ(S))
0.001 ± 0.002
0.034 ± 0.011
Table 3: Ablation against negative controls on Folding and GridShift under joint OOD extrapolation ( S=8 , 2×D ). Results use seed-0 checkpoints; ± denotes the half-width of a 95% bootstrap interval over 1,000 test instances. The controls retain the auxiliary-head architecture while changing the supervision target.
Supervised Fraction
In-Domain EM (%) ↑
OOD EM (%) ↑
Train Hours ↓
1.00 (All steps)
95.4
9.9
0.13
0.50 of steps
95.3
9.6
0.12
0.25 of steps
95.1
10.1
0.12
0.10 of steps
95.1
10.1
0.12
One step per program
95.1
10.1
0.12
0.00 (No canonical loss)
95.2
9.5
0.06
Table 4: Sensitivity to the availability of canonical supervision on Folding using an exploratory seed. The auxiliary loss weight ( λ ) was fixed at its preregistered value. The experiment varies the fraction of supervised execution steps and the fraction of corrupted labels.
Model Scale
RoPE Only Depth OOD
ORION + RoPE Depth OOD
Absolute Delta
Small (3.5M)
41.9 ± 3.1
41.9 ± 2.7
+0.0 pp
Medium (11.2M)
54.0 ± 1.6
54.5 ± 2.3
+0.4 pp
Large (26M)
54.6 ± 3.6
62.8 ± 1.9
+8.2 pp
Table 5: Scaling laws for RoPE versus ORION + RoPE on depth extrapolation in Folding . Values are EM percentages, reported as mean ± standard deviation over five seeds. The ladder uses a reduced training budget; therefore, its absolute values are lower than those in Table 2 .
Figure 3: Canonical-state pretraining transfers across domains. Exact match during adaptation to the other domain under an equal 800 -step budget, using five seeds. Models are initialized from scratch, from a Transformer pretrained on the source domain, or from an ORION model pretrained on the source domain. The ORION initialization improves target-domain held-out performance over Transformer pretraining by +0.085±0.041 for Folding → GridShift and +0.035±0.013 for GridShift → Folding . The improvement is positive in every seed in both directions.
Figure 4: Canonical supervision confines the latent trajectory. The final-layer hidden state at each executed operation is one point per step, projected on the two leading principal components of the in-distribution states and expressed in units of their spread. Arrows: mean step-to-step displacement of 800 paths through each cell; bold path: mean position from step 1 (square) to step 8 . The baseline moves 1.18 spreads per step with no coherent direction; ORION + RoPE moves 0.44 along a coherent field. The effect comes from the supervision, not the positional encoding ( 0.45 for ORION without RoPE, 1.36 for RoPE alone).
Appendix figures & tables16 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 5: An execution trace in the Folding domain. Each operation reflects part of the sheet onto the rest and concatenates the stacks, so layer count grows with depth while the footprint shrinks. The canonical state Φ(St) is the stack-valued geometry at each step; the query is a punch through the final stack, scored by exact set match over the original cells it perforates.
Figure 6: An execution trace in the GridShift domain. Cyclic row and column shifts permute origin labels over a grid whose extent never changes, so unlike Folding the state size is independent of program length. The canonical state is the origin-per-cell permutation and the query asks which positions hold marked origins after execution.
Figure 7: The ORION architecture on both domains. An exact simulator emits the canonical state Φ(S)=(μ,ν,ω,T,ans) at every execution step; five read-out heads decode it from one shared latent, and their losses are added to the language-modelling objective. The answer head is one probe among several rather than the privileged output. The identical wiring runs on Folding and GridShift , which is what lets the contrastive term act across domains.
Figure 8: The preregistered hypothesis, retained here as the prediction it was. Left: execution and decoding share overlapping directions in the residual stream, which is the state we expected to make extrapolation fragile. Right: the predicted effect of canonical-state supervision, separating them into distinct subspaces. Our diagnostics refute this specific mechanism — effective dimensionality rises rather than falls (Table 9 ) and the probe subspace is no more causally necessary than a random one (Appendix C.8 ) — while supporting the weaker claim that supervision confines the latent trajectory (Figure 4 ).
Evaluation axis
Baseline (APE)
RoPE only
ORION only
ORION + RoPE
FOLDING
Held-out operation type
0.151 ± 0.012
0.150 ± 0.018
0.175 ± 0.023
0.160 ± 0.016
Held-out query type
0.001 ± 0.001
0.002 ± 0.002
0.000 ± 0.001
0.001 ± 0.001
Equivalent programs (Thm. 3 )
0.962 ± 0.004
0.966 ± 0.002
0.966 ± 0.004
0.973 ± 0.006
GRIDSHIFT
Held-out operation type
0.079 ± 0.002
0.081 ± 0.003
0.081 ± 0.001
0.085 ± 0.006
Appendix
Table 6: Three further preregistered evaluation axes on the seed set of Table 2 (mean ± s.d. over 3 seeds, exact match). Held-out operation type withholds diagonal folds ( Folding ) and the transpose ( GridShift ) from training. Held-out query type withholds the multi-cell punch. Equivalent programs scores agreement on pairs of syntactically different programs that Theorem 3 certifies to have the same answer; it is an in-distribution consistency check, not an extrapolation split.
Backbone
In-domain
Depth ( 2×D )
Size ( S=8 )
FOLDING
SSM (S4-style)
0.349 ± 0.021
0.004 ± 0.002
0.098 ± 0.009
Hyena
0.902 ± 0.003
0.022 ± 0.004
0.157 ± 0.008
RWKV
0.963 ± 0.005
0.099 ± 0.012
0.160 ± 0.004
Transformer (APE)
0.970 ± 0.003
0.021 ± 0.008
0.171 ± 0.009
ORION + RoPE
0.985 ± 0.003
0.667 ± 0.018
0.196 ± 0.010
Appendix
Table 7: Alternative sequence backbones at a matched training budget (6,000 steps, 3 seeds, mean ± s.d.). The recurrent and long-convolution models were run because they carry sequence priors of their own and are therefore confounds for any claim about positional structure. The state-space model does not fit the training distribution in either domain and Hyena fits only Folding ; RWKV fits both and is the strongest non-rotary backbone on the depth axis ( 0.099 and 0.175 ), but none of the three comes near what rotary embeddings reach ( 0.651 and 0.575 ).
Baseline
ORION
Corruption
EM ↑
F1 ↑
EM ↑
F1 ↑
p=0.00
0.975
0.981
0.980
0.985
p=0.02
0.853
0.880
0.868
0.892
p=0.05
0.718
0.782
0.740
0.790
p=0.10
0.562
0.645
0.575
0.666
Dropped operation ( n=319 )
0.994
0.994
0.994
0.994
Appendix
Table 8: Robustness to input corruption on Folding (seed 0, in-distribution test set). Token noise replaces a fraction p of program tokens at random. Dropped operation removes one operation from the program and scores against the answer for the shortened program. Canonical supervision leaves both curves essentially unchanged, so the robustness it confers is not visible at the level of the decoded answer.
Measure
Baseline
ORION
Participation ratio (of 384 dims)
10.4 [9.8, 10.6]
14.3 [13.3, 14.6]
TwoNN intrinsic dimension
12.2
10.1
Spectral entropy (nats)
2.97
3.31
Dimensions for 90% variance
19
26
Dimensions for 95% variance
31
39
Cross-model CKA, Folding
0.96–0.99 across layers
Appendix
Table 9: Representation geometry of the final layer on Folding (seed 0, n=600 in-distribution prompts). The preregistered hypothesis was that canonical supervision compresses the execution subspace. It does not: the participation ratio, the spectral entropy and the number of dimensions needed for 90 – 95% of the variance all rise under supervision. The TwoNN estimator is the one measure that moves the other way, so we report the evidence as mixed in direction but uniform in conclusion — no measure supports compression. Layer-wise linear CKA between the supervised and unsupervised models stays high throughout, so the supervised representation is a nearby one rather than a different one.
Figure 9: Layer-to-layer linear CKA within each model on Folding (seed 0, 384 in-distribution prompts). Both models show the same smooth block structure, with adjacent layers above 0.97 and the embedding layer the most distinct. Canonical supervision does not reorganise the layer hierarchy. Note the colour scale starts at 0.90 ; on an absolute scale the two panels are nearly identical, which is the point.
Figure 10: Degradation on Folding , from the reduced-budget surface sweep. (a) Exact match against execution depth at the training state sizes; the shaded band is the trained range and the printed values are the endpoints at 2× . The rotary conditions degrade gradually while the two absolute-position conditions fall off a cliff at the first unseen depth. (b) The joint surface for ORION + RoPE over both axes, every cell labelled with exact match; red lines mark the edges of the training region and n/a marks a combination the generator cannot produce. Reading up the left columns shows depth costing accuracy gradually; reading across to the right column shows the size axis costing all of it at once, at every depth. The size axis is not drawn as a separate curve because all four conditions coincide on it ( 0.195 , 0.190 , 0.169 and 0.170 at S/Strain=1.33 ).
Figure 11: Per-algorithm exact match on the CLRS pilot (single seed). (a) In-distribution ( n=16 ). (b) The preregistered out-of-distribution endpoint, the mean of the length and structural axes. Only kmp_matcher separates the conditions; activity_selector and graham_scan are at zero for every condition.
Baseline
ORION
Failure mode
in-domain
depth 2×D
in-domain
depth 2×D
Final operation not applied
9
92
3
107
First operation not applied
0
3
0
5
Query reflected
2
4
2
5
Answer misses cells
5
369
4
352
Answer adds cells
3
14
1
14
Appendix
Table 10: Error taxonomy on Folding (seed 0): counts of each failure mode among incorrect predictions. Beyond the training depth the model almost never emits a malformed or reflected answer: the failures are well-formed answer sets that miss cells or are disjoint from the truth, which is the signature of a state that has drifted rather than of a decoder that has broken.
Parameter
Baseline
RoPE Only
ORION Only
ORION + RoPE
Layers ( L )
6
6
6
6
Hidden dim ( dmodel )
384
384
384
384
Attention heads
6
6
6
6
Parameters
11.2M
11.2M
11.4M
11.4M
Optimizer
AdamW
AdamW
AdamW
AdamW
Learning rate
0.0003
0.0003
0.0003
0.0003
Appendix
Table 11: Hyperparameter settings across model configurations. The scaling ladder of Table 13 varies dmodel∈{256,384,512} at a reduced step budget with five seeds; all other experiments use the configuration below.
Benchmark
Baseline (N1)
N2
N3
N4
N5
ORION + RoPE
FOLDING
0.021 ± 0.008
0.021 ± 0.006
0.024 ± 0.008
0.027 ± 0.008
0.031 ± 0.005
0.667 ± 0.018
GRIDSHIFT
0.093 ± 0.012
0.081 ± 0.020
0.068 ± 0.018
0.077 ± 0.034
0.073 ± 0.020
0.598 ± 0.038
Mean
0.057
0.051
0.046
0.052
0.052
0.633
Appendix
Table 12: OOD exact match on the depth-extrapolation split ( 2×D at the training state size) across negative controls, mean ± s.d. over 3 seeds. CLRS controls were not trained. The controls lie within the seed spread of the APE baseline and of ORION with APE ( 0.026 on Folding , 0.063 on GridShift ); the separation in this table is between the rotary column and everything else.
Model Scale
RoPE Only Depth OOD
ORION + RoPE Depth OOD
Absolute Delta
Small (3.5M)
41.9 ± 3.1
41.9 ± 2.7
+0.0 pp
Medium (11.2M)
54.0 ± 1.6
54.5 ± 2.3
+0.4 pp
Large (26M)
54.6 ± 3.6
62.8 ± 1.9
+8.2 pp
Appendix
Table 13: RoPE versus ORION + RoPE on depth extrapolation in Folding across model width. Values are EM percentages, mean ± standard deviation over five seeds. The ladder uses a reduced training budget, so its absolute values are lower than those in Table 2 .
Positional Scheme
State Supervision
Size Extrap.
Depth Extrap.
Joint
APE
None
17.1
2.1
0.4
APE
ORION
17.1
2.6
0.4
RoPE
None
19.1
65.1
1.8
RoPE
ORION
19.6
66.7
2.2
Appendix
Table 14: Positional-bias interoperability across the size and depth axes on Folding . Values are EM percentages. ALiBi and other relative-bias schemes were not trained in this study and are therefore not listed; we make no claim about their interaction with ORION.
Length generalization is the ability of sequential models to perform well on context lengths unseen during training. In this work, we show that the challenge of achieving length generalization is related not only to architectural choices such as positional encoding and the attention mechanism but also to the training procedure itself. We study how regularization affects length generalization and find that weight decay can hinder extrapolation. In contrast, dropout improves extrapolation when its placement within the architecture is reconsidered. In that regard, we show that the standard placement of dropout before layer normalization introduces a systematic distributional mismatch, and that applying dropout just before the linear projection resolves this issue. For example, a modified SmolLM3 with sliding window attention, continually pre-trained with dropout, can extrapolate perfectly to 64× on Needle-in-a-Haystack and far beyond the pre-training context size on RULER and HELMET. Mamba2 also benefits from dropout, suggesting an architecture-agnostic nature of the problem. We further propose Variance-Preserving Affine Dropout (VPAD), a new dropout strategy that substantially reduces the resulting pre-activation variance mismatch, leading to further extrapolation improvements in transformers.
Pavlo Vasylenko, Matthias Lindemann, André F. T. Martins +1
Instituto Superior Técnico, Universidade de Lisboa · Instituto de Telecomunicações · ELLIS Unit Lisbon +1
We study implicit reasoning, i.e. the ability to combine knowledge or rules within a single forward pass. While transformer-based large language models store substantial factual knowledge and rules, they often fail to compose this knowledge for implicit multi-hop reasoning, suggesting a lack of compositional generalization over their parametric knowledge. To address this limitation, we study recurrent-depth transformers, which enables iterative computation over the same transformer layers. We investigate two compositional generalization challenges under the implicit reasoning scenario: systematic generalization, i.e. combining knowledge that is never used for compositions during training, and depth extrapolation, i.e. generalizing from limited reasoning depth (e.g. training on up to 5-hop) to deeper compositions (e.g. 10-hop). Through controlled studies with models trained from scratch, we show that while vanilla transformers struggle with both generalization challenges, recurrent-depth transformers can effectively make such generalization. For systematic generalization, we find that this ability emerges through a three-stage grokking process, transitioning from memorization to in-distribution generalization and finally to systematic generalization, supported by mechanistic analysis. For depth extrapolation, we show that generalization beyond training depth can be unlocked by scaling inference-time recurrence, with more iterations enabling deeper reasoning. We further study how training strategies affect extrapolation, providing guidance on training recurrent-depth transformers, and identify a key limitation, overthinking, where excessive recurrence degrades predictions and limits generalization to very deep compositions.
Harsh Kohli, Srinivasan Parthasarathy, Huan Sun +1
Despite the remarkable practical success of transformer-based language models, recent work has raised concerns about their ability to perform state tracking. In particular, a growing body of literature has shown this limitation primarily through failures in out-of-distribution (OOD) generalization, such as length extrapolation. In this work, we shift attention to the in-distribution implications of these limitations. We conduct a large-scale experimental study of the data efficiency of transformers and recurrent neural networks (RNNs) across multiple supervision regimes. We find that the amount of training data required by transformers grows much more rapidly with state-space size and sequence length than for RNNs. Furthermore, we analyze the extent to which learned state-tracking mechanisms are shared across different sequence lengths. We show that transformers exhibit negligible or even detrimental weight sharing across lengths, indicating that they learn length-specific solutions in isolation. In contrast, recurrent models exhibit effective amortized learning by sharing weights across lengths, allowing data from one sequence length to improve performance on others. Together, these results demonstrate that state tracking remains a fundamental challenge for transformers, even when training and evaluation distributions match.
M. Reza Ebrahimi, Michaël Defferrard, Sunny Panchal +1
Qualcomm AI Research is an initiative of Qualcomm Technologies, Inc.