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.