Manuscript Offprint
arXiv:2610.37524GTFormer: A Syntax-Free Graph Network Alternative to Transformers for 8192 Length Extrapolation in Linear Time
Abstract
Self-attention mechanisms have established the Transformer as the dominant backbone across natural language processing, source code intelligence, and automated theorem proving. However, all-to-all pairwise token comparison enforces a quadratic compute and memory barrier alongside severe softmax attention dilution as sequence length scales beyond the training horizon. Inspired by recent advances in algebraic graph learning (WPNet), this work introduces GTFormer, a syntax-free hierarchical Graph Neural Network (GNN) that replaces flat self-attention for general long-context sequence modeling. GTFormer organizes raw token streams into a bounded-degree hierarchy combining a balanced binary reduction tree ( depth), horizontal boundary-bridging shift edges, random expander shortcuts, multi-channel convex highway gating, and a top-down broadcast pass. Across eight long-context code, log, and multi-hop retrieval benchmarks trained exclusively on sequences of length , GTFormer extrapolates zero-shot to ( ) on a single commodity GPU in linear memory, maintaining near-perfect accuracy where standard and RoPE Transformers suffer from out-of-distribution attention collapse and out-of-memory exhaustion.
1 Introduction
The introduction of the Transformer architecture [1] fundamentally reshaped modern computing, transforming the internet from an index of static documents into an interactive ecosystem of generative reasoning engines. By replacing sequential recurrence with parallelizable self-attention, Transformers unlocked unprecedented scaling laws across natural language understanding [2], automated software synthesis, biomolecular structure prediction [3], and formal mathematical discovery. Most notably, recent systems have demonstrated that sequence models can discover novel combinatorial algorithms [4] and solve Olympiad-level Euclidean geometry problems [5], cementing the paradigm of treating diverse symbolic, programmatic, and scientific domains as token streams processed via global context aggregation.
Despite these achievements, the foundational mechanism of the Transformer—all-to-all pairwise dot-product attention—imposes a prohibitive computational and memory bottleneck with respect to sequence length . Processing ultra-long contexts such as entire software repositories, multi-day system audit logs, or genomic sequences requires storing and computing billions of pairwise attention weights, rapidly exhausting the High-Bandwidth Memory (HBM) of modern GPUs and driving unsustainable energy consumption and carbon footprints at data-center scale [6, 7]. Furthermore, this hardware barrier is compounded by an intrinsic algorithmic bottleneck: as context length expands well beyond the training distribution, softmax normalization disperses attention mass across tokens ( ), causing severe signal-to-noise dilution [8], while sinusoidal and rotary positional encodings (RoPE) drift into unseen frequency regimes [9, 10]. Consequently, flat Transformers trained on short windows ( ) fail catastrophically both in accuracy and memory footprint when deployed zero-shot on extreme context lengths ( ).
Numerous architectural alternatives have been proposed to mitigate the quadratic barrier of self-attention, yet each exhibits structural limitations when confronted with multi-hop reasoning and extreme out-of-distribution (OOD) length extrapolation [11]. Sparse attention patterns combining local sliding windows with global or random tokens—such as Longformer [12], BigBird [13], and Exphormer [14]—reduce per-layer complexity to , but rely on a fixed number of stacked layers ; when the graph diameter of the sparse topology exceeds , long-range multi-hop dependencies cannot propagate. Hierarchical attention variants such as BP-Transformer [15] and H-Transformer-1D [16] partition sequences into binary trees, yet retain flat softmax aggregation across multi-scale spans and fixed network depth. Conversely, classical Tree-LSTMs [17, 18] require external syntactic parsers and suffer from continuous activation drift past depths of 8 to 10 levels. Meanwhile, modern linear State Space Models (SSMs) and recurrent architectures such as S4 [19] and Mamba [20] achieve scaling via associative parallel scans, but are mathematically restricted to linear or diagonal state recurrences, limiting their capacity to execute non-linear relational compositions or track complex state-machine transitions across arbitrary length scales [21].
The architectural solution developed in this work originates from a empirical phenomenon recently observed in computational group theory and algebraic cryptanalysis with WPNet [22]. In [22], unreduced algebraic words over infinite non-abelian groups (such as the Baumslag-Solitar group BS(1,2) and Artin groups) were transformed from flat symbol sequences into sparse shortcut graphs and processed via message-passing Graph Neural Networks [23, 24]. Remarkably, models trained exclusively on short algebraic words of length generalized zero-shot to words of length without degradation, heuristically solving the Word Problem, predicting geodesic lengths, and breaking the Wagner-Magyarik public-key cryptosystem. Crucially, topological ablations revealed that the exact syntactic alignment of the graph edges mattered far less than the structural presence of shortcuts: by converting a chain of diameter into a bounded-degree graph of logarithmic diameter , every node processes a small, constant fan-in neighborhood regardless of total sequence length, rendering the learned local reduction rules strictly scale-invariant.
This paper demonstrates that the shortcut-graph principle of WPNet can be generalized beyond pure mathematics to serve as a fast, low-memory, drop-in replacement for Transformers across general long-context sequence modeling tasks. The proposed architecture, GTFormer (GraphTreeFormer), eliminates pairwise self-attention entirely, converting any unparsed token stream into a syntax-free multi-level graph composed of a balanced binary contraction tree of dynamic depth , horizontal boundary-bridging shift edges, and random expander shortcuts. To prevent activation drift across 16+ hierarchical levels ( to 4,194,304) and support indirect multi-hop lookups, GTFormer introduces a scale-invariant multi-channel convex highway gate coupled with a bidirectional top-down broadcast pass. Evaluated across an extensive suite of eight non-mathematical benchmarks—spanning chronological variable overrides, unaligned multi-token key-value bindings, 2-hop pointer dereferencing, security intrusion logs, lexical code scope shadowing, multi-needle retrieval-augmented generation (RAG), hierarchical XML tag verification, and adversarial syntactic decoys—GTFormer models trained exclusively on extrapolate zero-shot to ( extrapolation), achieving accuracy in 796.62 ms per sequence using under 22.1 GB of VRAM on a single Linux GPU. Figure 1 visualizes the proposed GTFormer architecture compared to a classical Transformer.
(a)

(b)

Figure 1: Structural comparison of information routing over a sequence of length containing an odd-split key-value binding at indices and a pointer at indices . (a) GTFormer: Local 1-hop horizontal shift edges (orange) bind adjacent tokens across odd binary boundaries before hierarchical reduction. At each tree level, shared-salience convex highway gates suppress filler nodes (dashed gray) and route active variable and pointer channels (solid blue) to the root in steps and memory. (b) Flat Transformer: All-to-all self-attention connects every filler token to every other token, causing severe softmax attention dilution on out-of-distribution lengths and quadratic VRAM exhaustion.
2.1 Long-Context Benchmark Suite
To evaluate whether a syntax-free graph hierarchy can replace flat self-attention without relying on an external parser, an eight-task benchmark suite is constructed to mirror the core structural challenges of source code analysis, system log auditing, and multi-hop document retrieval. Rather than training over a static, finite corpus across repeated epochs—which would permit memorization of specific token positions or document templates—the training pipeline employs an online procedural generator that synthesizes fresh document batches dynamically at every optimization step. Across gradient steps per run, the generator cycles deterministically through six short in-distribution sequence lengths according to , pairing shorter sequences ( ) with batch size and longer sequences ( ) with batch size . This schedule exposes each model to 117,344 unique documents per training run with close to zero chance of sample reuse.
Each document is synthesized from a vocabulary of size , partitioned into background filler tokens and structured operational signal tokens . Generation begins by initializing a sequence of background tokens drawn uniformly at random from to simulate uninformative prose or code boilerplate. The sequence is then divided into contiguous segments of length . Within each segment, task-specific signal tokens—such as register assignments, two-token key-value pairs, pointer references, scope delimiters, or syntactic decoys—are injected by overwriting filler tokens at uniformly sampled random offsets. Critically, both the intra-segment injection indices and the permutation of target registers are randomized independently for every sequence in a batch, preventing models from exploiting fixed positional heuristics or segment-to-register correlations.
The model must correctly predict the final state of every document which is governed by three latent state slots , which map bijectively to a single 64-class exact-match target label:
yielding a uniform random-guessing baseline of . The eight tasks consist of:
Task 1: Chronological Multi-Register Override (override_qa): This task evaluates a model's ability to track chronological state evolution and perform order-sensitive updates across three independent registers:
• Register 0 Updates: Encoded as integer tokens 201, 202, and 203, representing values 0, 1, and 2.
• Register 1 Updates: Encoded as integer tokens 204, 205, and 206, representing values 0, 1, and 2.
• Register 2 Updates: Encoded as integer tokens 207, 208, and 209, representing values 0, 1, and 2.
Three independent state registers , representing logical variables such as ROLE, CLEARANCE, and OP) are updated across multiple temporal waves in randomized register order. Because chronologically later assignments override earlier ones, the architecture must correctly track the final override state across sequence lengths up to 524,288 tokens without falling victim to recency bias or memory dilution. This is equivalent to tracking state variables in command-and-control logs where later status updates override older operational clearances.
Task 2: Unaligned Multi-Token Associative Recall (unaligned_kv): This task tests cross-boundary token binding and associative recall by deliberately unaligning key-value pairs relative to binary tree segmentation boundaries:
• Keys : Encoded as integer tokens 200, 201, and 202.
• Values : Encoded as integer tokens 203, 204, and 205.
Key-value bindings are expressed as contiguous two-token phrases placed specifically at odd sequence index pairs amid background standalone value distractors. In a standard binary tree hierarchy, these odd-offset positions sever the phrase—placing into the left subtree node and into the right subtree node . This structural mismatch explicitly tests whether an architecture's local shortcut edges can preserve cross-boundary pairings that would otherwise be isolated by rigid partitioning. This mirrors recovering key-value metadata pairings that span across chunk boundaries in streaming data parsers where token splits disrupt standard fixed-window alignments.
Task 3: Two-Hop Pointer Dereferencing (pointer_hop): The token vocabulary is structured into distinct functional ranges:
• Background Fillers: Indices 0 to 199 serve as random background noise tokens.
• Variables (VAR -VAR ): Encoded as integer tokens 200 through 207.
• Values (0–3): Encoded as integer tokens 208 through 211.
• Pointers (PTR₀–PTR₂): Encoded as integer tokens 212 through 235 (spanning 3 pointers × 8 target variables).
The sequence is partitioned into eight equal segments. Five active variables are randomly sampled from the eight candidates, assigned discrete values in , and injected into segments 0,1,3,5, and 6. Simultaneously, three pointers (PTR , PTR , PTR ) are placed into segments 2,4, and 7. The model is tasks with finding the values of the variables that the pointers refer to.
Crucially, because pointers are placed in segments that precede their corresponding variable definitions (e.g., appearing in segment 2 while is defined later in segment 3), standard causal (left-to-right) models fail. Resolving this requires bidirectional or global routing to look ahead across the sequence. This corresponds to resolving out-of-order pointer dereferences and variable references in compilers where variable usage precedes its declaration in a scope.
Task 4: Stateful Intrusion & Reset Automaton (intrusion_fsm): To test an architecture's capability to maintain state variables subject to intermittent global resets and subsequent updates across discrete timeline intervals, the intrusion_fsm task simulates a finite state machine register tracking system across seven segments. The token representation consists of:
• Background Fillers: Indices 0 to 199 serve as background noise.
• Register Updates: Encoded as , where registers (reg) range from 0 to 2 and values (v) range from 0 to 3.
• Global Reset Token: A dedicated control token fixed at integer 250 (reset_tok).
The sequence is split into seven equal segments:
(a) Segments 0–2: Three registers are initialized in a randomized order, with each assigned a value in at a random offset within its respective segment.
(b) Segment 3 (Reset Check): A 50% chance determines whether a GLOBAL_RESET token (250) is injected. If triggered, all internal register states are wiped to 0. Otherwise, a random fallback filler token is placed.
(c) Segments 4–5: Two additional registers are randomly chosen and updated with new values in subsequent to the potential reset event.
This mirrors tracking protocol state machines and security session registers in firewalls that must instantly reset and re-initialize upon receiving a global TCP reset or abort command.
Task 5: Lexical Code Scope Shadowing (code_scope_shadow): This task assesses lexical scoping and variable shadowing in a simulated code execution stream. Specifically, it tests whether an architecture can maintain global variable states while temporarily processing an inner local code block, and whether it correctly executes branching memory operations—either entirely discarding local overrides (scope exit) or permanently updating global state with those inner assignments (scope commit).
• Global/Local Variable Assignments: Encoded as for variables 0 through 2 and values 0 through 3.
• Scope Control Tokens:
– SCOPE_ENTER: Integer 260.
– SCOPE_EXIT (Revert): Integer 261.
– SCOPE_COMMIT: Integer 262.
The sequence is divided into eight segments:
• Segments 0–2: Global variables are assigned initial baseline values.
• Segment 3: A SCOPE_ENTER token (260) is placed.
• Segments 4–6: Inner-block local assignments temporarily shadow the global variables.
• Segment 7: A branching decision occurs with equal probability: either a SCOPE_EXIT token (261) reverts all variables back to their pre-block global values, or a SCOPE_COMMIT token (262) preserves the inner-block local overrides.
This is equivalent to tracking lexical variable scoping and block-level variable shadowing in interpreters where inner scopes temporarily override global variables before committing or reverting changes.
Task 6: Dynamic Multi-Needle RAG (multi_needle_rag): Designed to stress-test selective retrieval from a large pool of multi-entity facts based on a dynamic query token embedded midway through the text:
• Entities (0–5): Encoded at base 200 to 205.
• Attribute Values (0–3): Encoded at base 206 to 209.
• Query Combinations combinations): Encoded via a query base starting at 210 (tokens 210 to 229), where each token maps to a specific triplet of entities .
The sequence is structured across seven segments:
• Segments 0, 1, 2, 4, 5, 6: Six entity-attribute fact pairs are scattered at random offsets.
• Segment 3: A single dynamic query token is placed right in the middle of the document, specifying a target combination of three entities to retrieve. Because the query sits in segment 3, some target facts precede the query while others follow it, requiring bidirectional access.
This simulates retrieving specific scattered facts across a massive corporate document archive based on a dynamic user query embedded midway through the text.
Task 7: Hierarchical XML/Bracket Verification (xml_bracket_check): This task evaluates hierarchical tag matching and syntax error detection across three independent subsystems:
• Opening Tags: Encoded starting at 200 across 3 subsystems × 4 tag types (200 to 211).
• Closing Tags: Encoded from 212 to 223.
The document is partitioned into six segments:
• Segments 0–2: Subsystems 0, 1, and 2 open tags of type 1 through 3.
• Segments 3–5: Corresponding close tags are placed. For each subsystem, there is a 50% chance of clean closure (yielding a subsystem error status of 0) versus a mismatched tag or noise token, which registers an unclosed/mismatched error status equal to the tag type (1 to 3).
This mirrors checking syntactic correctness and tag matching across deeply nested hierarchical markup or JSON documents.
Task 8: Adversarial Syntactic Decoys (adversarial_decoys): This benchmark increases sequence noise density by injecting syntax-mimicking distractor tokens around genuine key-value bindings:
Building directly upon the unaligned key-value base structure, this task introduces:
• Decoy Values: Mapped from 203 to 206.
• Decoy Keys: Mapped from 240 to 242.
Genuine key-value bindings are distributed at random odd/even offsets. Simultaneously, the background filler stream is heavily seeded with high-density syntactic decoys forcing models to distinguish functional tracking states from adversarial distractors. This corresponds to parsing complex financial contracts or legal agreements that contain syntax-mimicking distractor clauses surrounding genuine contractual obligations.
Table 1 gives an example of the input sequence and anticipated result for each task above.
2.2 Syntax-Free GTFormer Construction from Sequential Data
Given an unparsed input token sequence of power-of-two length (sequences of arbitrary length are padded to the nearest power of two or reduced via strided pairs), GTFormer constructs a directed hierarchical multi-graph without invoking any domain-specific lexer or syntactic parser.
The vertex set is partitioned into layers, where level contains nodes denoted for . Thus, corresponds to the leaf tokens, and is the global root node. Total vertex count across the entire hierarchy is strictly linear:
Four distinct edge families govern information flow across G, as illustrated in Figure 2:
Table 1: Representative token input sequences, event streams, and target output states across the eight benchmark tasks for sequence length (vocabulary size ). Filler tokens represent background noise; tokens carry structured operational semantics.
| Task Name | Input Token Sequence () | Event Progression / Semantics | Target Class |
|---|---|---|---|
| override_qa | [42, 203, 118, 207, 12, 201, 88, 206, 91, 155, 202, 33, 200, 77, 94, 18] | . Final state: | 25 |
| unaligned_kv | [42, 118, 12, 200, 205, 88, 201, 203, 91, 155, 202, 206, 33, 200, 204, 77] | Odd-boundary pairs:. Final state: | 19 |
| pointer_hop_triple | [14, 213, 83, 212, 90, 214, 111, 200, 211, 49, 201, 208, 170, 202, 210, 88] | ; Dereference , , final values = | 14 |
| intrusion_fsm | [81, 203, 45, 207, 19, 250, 99, 110, 202, 130, 14, 66, 92, 140, 50, 12] | Final state: | 32 |
| code_scope_shadow | [202, 41, 260, 12, 203, 89, 261, 73, 99, 102, 18, 45, 160, 11, 82, 39] | Global Local revert to 2 Final state: | 32 |
| multi_needle_rag | [18, 201, 207, 44, 210, 92, 200, 206, 11, 145, 202, 209, 67, 83, 104, 5] | Query retrieve ; Bindings: Retrieved slots: | 7 |
| xml_bracket_check | [33, 201, 78, 205, 12, 90, 213, 14, 217, 102, 45, 16, 88, 120, 54, 9] | Open tag (201) and (205); Close tag (213) and (217) all closed () | 0 |
| adversarial_decoys | [12, 200, 204, 88, 240, 205, 91, 201, 203, 33, 204, 77, 202, 206, 15, 60] | Real keys mixed with decoy and floating Final state: | 19 |
-
Horizontal Boundary-Bridging Shift Edges (): At leaf level , directed edges connect every adjacent token pair for . Without , any two-token syntactic construct (such as ) starting at an odd index is split between disjoint parent nodes and ; the horizontal shift edge guarantees that node binds its immediate right neighbor prior to vertical tree contraction.
-
Vertical Binary Tree Contraction Edges (): Between consecutive levels and , ordered left-child and right-child edges and recursively halve the sequence resolution, compressing the effective graph diameter between any two tokens from to .
-
Horizontal Random Expander Shortcuts (): Within each internal level where , a random permutation assigns a single long-range horizontal shortcut edge to each node, emulating a bounded-degree expander graph [14] that creates cross-subtree bypasses.
-
Top-Down Broadcast Edges (): After bottom-up reduction reaches the root , downward broadcast edges propagate global query and pointer context back to the leaf representations to resolve multi-hop indirect references.
Crucially, the maximum in-degree of any node in is bounded by a small constant (: left child, right child, one horizontal peer, and self/parent), ensuring that message aggregation never scales with sequence length .
Level D = 3 (Global Root)
Level d = 2
( only)
Level d = 1
( )
Level d = 0
(Leaves + )

Odd Split Bridged by
Figure 2: Architecture of the syntax-free GTFormer topology shown for ( ). At Level , an unaligned two-token phrase [KEY, VAL] at odd indices straddles the boundary between subtrees and , but is bound locally via the horizontal shift edge . Bottom-up tree edges and horizontal expander shortcuts compress sequence state in steps, while top-down broadcast edges resolve remote pointer queries (PTR).
2.3 The GTFormer Neural Architecture
The token embedding function maps each discrete token from the vocabulary to a continuous vector of dimension , providing the initial continuous features for the leaf nodes at the base of the graph hierarchy. These features will be learned by the model during training. GTFormer processes in three sequential stages using shared weights in the neural operators across all tree levels
Stage 1: Local Boundary-Bridging Encoding ( ). Each leaf token aggregates its right neighbor (with zero-padding at ) through a two-layer GELU Multi-Layer Perceptron with pre-layer normalization:
where denotes vector concatenation and is the GELU activation.
Stage 2: Bottom-Up Expander-Augmented Convex Tree Reduction ( ). At each level , nodes first exchange messages along horizontal random expander edges controlled by a learned sigmoid gate initialized with a conservative negative bias ( , so ):
Next, sibling pairs contract into parent node via a multi-channel convex highway gate. Specifically, a channel-wise gating vector is computed from the concatenated sibling states:
where denotes the element-wise sigmoid activation. The parent representation is then formed as a channel-wise convex combination:
where denotes the Hadamard (element-wise) product. Because the coefficients per channel are strictly non-negative and sum up to 1, the contraction stays within the convex hull of the child representations. This bounds activation magnitudes across tree levels and enables unimpeded gradient and feature routing from informative leaf tokens while suppressing background filler tokens. Rather than applying an unconstrained MLP across levels—which causes activation norms and feature manifolds to drift exponentially when unrolled to levels ()—GTFormer computes per-channel salience scores and a cross-child modulation term:
where is initialized to +0.2 to provide a chronological recency prior favoring the right (later) subtree when salience is tied. First, within level , horizontal message passing over (for ) or the expander shortcuts (for ) updates each node state , enabling direct cross-subtree communication before vertical compression. Next, horizontally enriched sibling pairs contract into parent node via a multi-channel convex highway gate. Specifically, a channel-wise gating vector is computed from the concatenated sibling states:
where denotes the element-wise sigmoid activation. The parent representation is then formed as a channel-wise convex combination:
where denotes the Hadamard (element-wise) product. While the convex gate preserves signal norm and selectively filters background noise during vertical reduction, the preceding expander shortcuts encoded in prevent the root node from becoming an information bottleneck when routing multiple concurrent variable bindings.
Proposition 1 (Manifold Boundedness Across Arbitrary Extrapolation Depth). Consider the vertical tree contraction in Equation (8) with expander gates closed ( ). For any sequence length and any feature channel , the root representation lies strictly within the convex hull of the leaf representations :
Proof. Since , each parent coordinate is a strict convex combination of and . By induction from to , with and , preventing norm explosion or out-of-manifold drift at arbitrary tree depth .
Stage 3: Top-Down Broadcast Pass and Multi-Head Readout ( ). To resolve multi-hop pointer dereferencing and dynamic RAG queries, the global root state is broadcast back down to the leaf representations via multiplicative bilinear conditioning:
At extreme context lengths (), Equation (13) is evaluated via an exact two-pass streaming max-stabilized softmax over chunks of size , bounding peak intermediate memory to . Finally, the concatenated root and top-down summary vector is passed to a shared readout MLP producing 64-class exact-match logits alongside three auxiliary 4-way slot logits (). To eliminate permutation symmetry and training saddle points on relational tasks (e.g., pointer dereferencing and multi-needle RAG), the training loss combines three distinct objectives:
where:
• : Cross-entropy over the unified 64-class exact-match target space .
• : Factored auxiliary cross-entropy across individual output slots.
• and : Direct supervision for internal variables and pointers, ensuring the model learns correct multi-hop routing without getting confused by token order.
Architecture Ablation: To isolate the contribution of each component in GTFormer, we evaluate seven distinct architectures, ranging from fully-featured variants to structural ablations and standard flat baselines as shown in Table 2.
Table 2: Architectural comparison of evaluated model variants and ablation configurations.
| Model Variant | Topology | Local Shift (use_local_shift) | Expander (use_expander) | Convex Gate (use_convex_gate) | Top-Down (use_top_down) | Primary Role / Ablation Target |
|---|---|---|---|---|---|---|
| GTFormer_Bidirectional | Hierarchical | ✓ | ✓ | ✓ | ✓ | Full proposed architecture |
| GTFormer_BottomUp | Hierarchical | ✓ | ✓ | ✓ | ✕ | Feed-forward root readout only |
| GTFormer_NoExpander | Hierarchical | ✓ | ✕ | ✓ | ✓ | Ablates horizontal peer shortcuts () |
| Pure_Binary_Tree | Hierarchical | ✕ | ✕ | ✓ | ✓ | No horizontal edges; tests odd-index splitting |
| Unbounded_Tree_MLP | Hierarchical | ✓ | ✓ | ✕ | ✓ | Unconstrained MLP merge; tests depth drift |
| Flat_Transformer_Sinusoidal | Flat (2L) | — | — | — | — | Sinusoidal PE + mean pooling |
| Flat_Transformer_RoPE | Flat (2L) | — | — | — | — | Rotary PE (RoPE) + attention pooling |
Models are optimized using AdamW [25] with a weight decay of , paired with a cosine annealing learning rate scheduler [26] where the learning rate decays over steps to a minimum floor of 5% of its initial value.
2.4 Evaluation Metrics and Complexity Comparison
At evaluation time, the auxiliary slot heads used for intermediate supervision are removed. Performance is assessed strictly on the joint 64-class exact-match objective, , across a selection of sequence lengths of using four quantitative metrics:
-
Zero-Shot Exact-Match Accuracy (Acc(N)): Percentage of test documents at context length where (random chance = 1.56%). Lengths measure in-distribution (ID) generalization, whereas measure zero-shot out-of-distribution (OOD) extrapolation up to the maximum training length.
-
Extrapolation Retention Ratio (ERR): Defined as , quantifying the fraction of in-distribution accuracy preserved at extreme OOD scale ( and ).
-
Wall-Clock Inference Latency (): Mean execution time in milliseconds per sequence (ms/seq), measured with hardware-synchronized CUDA timers across batched evaluation passes.
-
Peak GPU Memory Footprint (): Maximum allocated CUDA memory in megabytes (MB) recorded via torch.cuda.max_memory_allocated() at each context length .
Table 3 contrasts the theoretical and structural properties of GTFormer against flat Transformers and tree-structured baselines.
| Architecture | Time | Memory | Graph Diam. | Max Fan-In | Odd-Split Safe | 2-Hop Ptr Safe |
|---|---|---|---|---|---|---|
| Flat Transformer (Sin / RoPE) | Yes | Yes (ID) | ||||
| Pure Binary Tree-GNN | No | No | ||||
| Unbounded Tree-MLP | Yes | No | ||||
| GraphTree (Bottom-Up) | Yes | Partial | ||||
| GraphTree (Bidirectional) | Yes | Yes () |
Table 3: Theoretical complexity and structural comparison across sequence length . Bounded fan-in () and convex highway gating enable scalable linear extrapolation to without attention dilution.
To account for the quadratic memory complexity inherent to full self-attention, flat transformer baselines are evaluated up to a maximum sequence length threshold of . Sequence lengths exceeding this limit () exhaust standard single-GPU VRAM capacities and are systematically recorded as Out-Of-Memory (OOM) to prevent crashing the evaluation suite. Due to the quadratic scaling of full self-attention, the VRAM required to store attention score matrices increases exponentially with sequence length. Based on the evaluation batch sizes and two-layer transformer encoder setup, required memory exceeds standard single-GPU capacity at extended lengths: approximately 68.7 GB at (batch size 8), 550 GB at (batch size 4), and over 1.1 TB at (batch size 2).
3 Computational Aspects
Experiments were executed using Python 3.11.2, PyTorch 2.10.0+cu128, and CUDA 12.2 on an NVIDIA Quadro RTX 8000 GPU (48 GB VRAM), with memory usage explicitly capped at 4 GB to simulate real-world hardware constraints.
4 Results
4.1 Aggregate Performance Across Sequence Lengths, Training Duration, and Memory Usage
Models are trained exclusively on short sequence lengths () for 2,200 optimization steps and evaluated zero-shot on out-of-distribution (OOD) sequences scaling up to ( extrapolation beyond the maximum training horizon). The best performing architecture was GraphTree (Local Shift + No Expander) and achieved a striking accuracy when evaluated on sequences of length . The evaluation was stopped at that sequence length due to memory constraints. Figure 3 illustrates the exact-match accuracy trajectories across all seven sequence lengths, and Table 4.1 summarizes the cross-task average accuracy, per-sequence inference latency, and peak GPU memory consumption for all seven evaluated architectures.

GraphTree Scaling Across Sequence Lengths
GraphTree (Local Shift, No Expander)
Unbounded Tree-GNN
Pure Binary Tree-GNN
GraphTree (Bidirectional: Up + Down)
GraphTree (Bottom-Up + Shortcuts)
Flat Transformer (Sinusoidal)
Flat Transformer (RoPE + AttnPool)
Figure 3: Average performance on all tests in zero-shot extrapolation of all architectures.
| Architecture | (ID) | (ID) | (ID) | |||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | 70.8% | 72.0% | 72.1% | 72.2% | 71.8% | 71.2% |
| GraphTree (Bottom-Up + Shortcuts) | 97.3% | 97.3% | 97.3% | 97.3% | 97.3% | 95.5% |
| GraphTree (Local Shift, No Expander) | 97.8% | 97.9% | 98.0% | 97.8% | 97.9% | 97.7% |
| Pure Binary Tree-GNN (No Shortcuts) | 86.7% | 86.5% | 86.9% | 86.9% | 85.9% | 83.3% |
| Unbounded Tree-GNN (No Convex Gate) | 3.0% | 3.1% | 3.5% | 3.1% | 3.1% | 2.8% |
| Flat Transformer (Sinusoidal) | 59.5% | 54.3% | 53.9% | 32.4% | 16.0% | OOM |
| Flat Transformer (RoPE + AttnPool) | 57.9% | 54.2% | 53.3% | 25.2% | 5.5% | OOM |
| Architecture | |||||||
|---|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | 69.0% | 68.4% | 66.4% | 63.9% | 65.8% | 65.1% | 71.1% |
| GraphTree (Bottom-Up + Shortcuts) | 93.0% | 92.6% | 90.5% | 88.1% | 88.1% | 86.5% | 87.5% |
| GraphTree (Local Shift, No Expander) | 97.9% | 98.0% | 97.2% | 96.5% | 96.9% | 95.9% | 98.1% |
| Pure Binary Tree-GNN (No Shortcuts) | 81.7% | 78.1% | 75.6% | 71.1% | 68.9% | 68.5% | 67.3% |
| Unbounded Tree-GNN (No Convex Gate) | 2.7% | 3.5% | 2.6% | 2.5% | 2.0% | 3.0% | 4.2% |
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + AttnPool) | OOM | OOM | OOM | OOM | OOM | OOM | OOM |
Table 4: Aggregate summary of results over all eight tasks (OOM=Out-Of-Memory).
Table 4.1 reports accuracy averaged over all eight tasks, with in-distribution and all longer sequences out-of-distribution. Both flat Transformer baselines degrade rapidly with sequence length: accuracy drops from 57.9–59.5% at N=64 to 25.2–32.4% at N=1024 and to 5.5–16.0% at N=4096, and both run out of memory from N=16384 onward, consistent with the quadratic cost of full attention. In contrast, every tree-based model runs up to N=4,194,304, i.e., 8,192× the longest training length of N=512.
Among the tree-based models, the ablations isolate the contribution of each component. The Pure Binary Tree-GNN reaches 86.7% at N=64 but degrades steadily with length, to 67.3% at N=4M, suggesting that without shortcuts information must traverse increasingly long tree paths. Adding shortcuts (Bottom-Up + Shortcuts) raises ID accuracy to 97.3%, which remains constant through N=4096 and drops only moderately at larger lengths (95.5% at N=16384, 87.5% at N=4M). The Local Shift variant without the expander is the strongest and most stable configuration, with accuracy between 95.9% and 98.1% at every length. The Bidirectional (Up + Down) variant is substantially weaker (63.9–72.2%), indicating that the additional top-down pathway does not help on these tasks. Finally, removing the convex gate is catastrophic: the Unbounded Tree-GNN remains at 2.0–4.2% at all lengths, showing that bounded, convex aggregation is essential in our setting. Small non-monotonic fluctuations at the largest lengths (e.g., Local Shift: 95.9% → 98.1% from N=2M to 4M) are within the variation we observe across tasks and lengths.
Taken together, these results indicate that (i) hierarchical message passing with shortcuts enables reliable extrapolation over nearly four orders of magnitude in sequence length, (ii) the convex gate is indispensable, and (iii) the simple local-shift configuration matches or exceeds the more elaborate variants.
Training Duration, Inference Latency, and Memory Footprint. Because training restricts sequence lengths to with dynamic batch sizing (), all models train rapidly on a single GPU. Each 2,200-step training run completes in 19–26 seconds for Unbounded_Tree_MLP and the Flat_Transformer baselines, and 32–45 seconds for the GTFormer variants.
During inference, memory and latency scaling diverge sharply between flat self-attention and hierarchical tree reduction. Because GTFormer halves the active sequence length at each of the hierarchy levels (2N - 1 total intermediate nodes), peak activation memory scales strictly linearly as . At , GTFormer_NoExpander consumes only 1,430.0 MB of peak VRAM and GTFormer_Bidirectional consumes 1,624.2 MB (with Pure_Binary_Tree requiring 725.2 MB). Conversely, due to the quadratic scaling of full self-attention, the VRAM required to store FP32 attention score matrices across two encoder layers exceeds single-GPU capacity at extended lengths: while consuming 276.8 MB at , full attention requires approximately 68.7 GB at (), 550 GB at (), and over 1.1 TB at (), resulting in Out-Of-Memory (OOM) termination beyond . In terms of wall-clock latency, at , GTFormer_NoExpander processes documents in 0.88 ms per sequence—over faster than Flat_Transformer_RoPE (5.58 ms) and Flat_Transformer_Sinusoidal (5.18 ms). At , GTFormer_NoExpander completes inference in 24.99 ms per sequence (50.57 ms for GTFormer_Bidirectional and 51.10 ms for GTFormer_BottomUp). Table 4.1 gives the details of the memory usage of the models per test case and Table 4.1 gives details of training times.
| Architecture | N = 64 | N = 256 | N = 512 | N = 1024 | N = 4096 | N = 16384 |
|---|---|---|---|---|---|---|
| GraphTree (Local Shift, No Expander) | 31 MB | 64 MB | 108 MB | 196 MB | 373 MB | 725 MB |
| GraphTree (Bottom-Up + Shortcuts) | 32 MB | 65 MB | 109 MB | 197 MB | 373 MB | 726 MB |
| GraphTree (Bidirectional: Up + Down) | 34 MB | 66 MB | 111 MB | 199 MB | 375 MB | 728 MB |
| Pure Binary Tree-GNN | 24 MB | 36 MB | 54 MB | 88 MB | 156 MB | 292 MB |
| Unbounded Tree-GNN | 32 MB | 64 MB | 109 MB | 197 MB | 373 MB | 726 MB |
| Flat Transformer (Sinusoidal) | 27 MB | 45 MB | 69 MB | 117 MB | 213 MB | OOM |
| Flat Transformer (RoPE + AttnPool) | 27 MB | 45 MB | 69 MB | 117 MB | 213 MB | OOM |
| Architecture | N = 65536 | N = 131072 | N = 262144 | N = 524288 | N = 1048576 | N = 2097152 | N = 4194304 |
|---|---|---|---|---|---|---|---|
| GraphTree (Local Shift, No Expander) | 1.4 GB | 725 MB | 1.4 GB | 2.8 GB | 5.5 GB | 11.0 GB | 22.1 GB |
| GraphTree (Bottom-Up + Shortcuts) | 1.4 GB | 726 MB | 1.4 GB | 2.8 GB | 5.5 GB | 11.0 GB | 22.1 GB |
| GraphTree (Bidirectional: Up + Down) | 1.4 GB | 728 MB | 1.4 GB | 2.8 GB | 5.5 GB | 11.0 GB | 22.1 GB |
| Pure Binary Tree-GNN | 566 MB | 292 MB | 566 MB | 1.1 GB | 2.2 GB | 4.3 GB | 8.6 GB |
| Unbounded Tree-GNN | 1.4 GB | 726 MB | 1.4 GB | 2.8 GB | 5.5 GB | 11.0 GB | 22.1 GB |
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + AttnPool) | OOM | OOM | OOM | OOM | OOM | OOM | OOM |
Table 5: Memory usage per model and evaluation length.
4.2 In-Depth Comparison Per Task Across Architectures
As illustrated in the summary plot 4 and detailed in the appendix tables (Tables A1 to A16), the GraphTree_NoExpander model achieves near-perfect accuracy (92–100%) across all tasks, outperforming all other
| Architecture | N = 64 | N = 256 | N = 512 | N = 1024 | N = 4096 | N = 16384 |
|---|---|---|---|---|---|---|
| GraphTree (Local Shift, No Ex-pander) | 0.17 ms | 0.23 ms | 0.29 ms | 0.38 ms | 1.12 ms | 3.65 ms |
| GraphTree (Bottom-Up + Short-cuts) | 0.24 ms | 0.34 ms | 0.40 ms | 0.51 ms | 1.57 ms | 5.38 ms |
| GraphTree (Bidirectional: Up + Down) | 0.34 ms | 0.42 ms | 0.49 ms | 0.60 ms | 1.69 ms | 5.57 ms |
| Pure Binary Tree-GNN | 0.16 ms | 0.19 ms | 0.21 ms | 0.30 ms | 0.75 ms | 2.33 ms |
| Unbounded Tree-GNN | 0.12 ms | 0.17 ms | 0.21 ms | 0.29 ms | 0.89 ms | 2.79 ms |
| Flat Transformer (Sinusoidal) | 0.13 ms | 0.12 ms | 0.17 ms | 0.36 ms | 2.10 ms | OOM |
| Flat Transformer (RoPE + At-tnPool) | 0.14 ms | 0.13 ms | 0.20 ms | 0.44 ms | 2.59 ms | OOM |
| Architecture | N = 65536 | N = 131072 | N = 262144 | N = 524288 | N = 1048576 | N = 2097152 | N = 4194304 |
|---|---|---|---|---|---|---|---|
| GraphTree (Local Shift, No Ex-pander) | 11.79 ms | 29.37 ms | 47.26 ms | 85.09 ms | 149.58 ms | 295.65 ms | 796.62 ms |
| GraphTree (Bottom-Up + Short-cuts) | 19.20 ms | 43.05 ms | 77.46 ms | 136.65 ms | 259.78 ms | 508.94 ms | 1244.06 ms |
| GraphTree (Bidirectional: Up + Down) | 19.88 ms | 45.01 ms | 79.71 ms | 139.52 ms | 266.80 ms | 519.38 ms | 1226.09 ms |
| Pure Binary Tree-GNN | 8.21 ms | 19.01 ms | 33.30 ms | 57.62 ms | 104.75 ms | 197.94 ms | 381.44 ms |
| Unbounded Tree-GNN | 9.02 ms | 23.73 ms | 35.72 ms | 62.43 ms | 118.57 ms | 286.20 ms | 654.77 ms |
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + At-tnPool) | OOM | OOM | OOM | OOM | OOM | OOM | OOM |
Table 6: Average training times of all models across the eight tasks.
evaluated architectures. GraphTree_BottomUp maintains perfect scores on most tasks but drops slightly on unaligned_kv (92.6%) and more significantly on pointer_hop (70.8%). GraphTree_Bidirectional performs strongly on tasks such as unaligned_kv and intrusion_fsm, but fails almost completely on pointer_hop (6.3%) and multi_needle_rag (10.1%). Pure_Binary_Tree demonstrates perfect accuracy on tasks such as intrusion_fsm and code_scope_shadow, yet struggles heavily with unaligned_kv (80.3%), multi_needle_rag (12.2%), and pointer_hop (10.6%). The Flat_Transformer models (both RoPE and Sinusoidal variants) perform poorly overall, only managing marginal accuracy (23–34%) on xml_bracket_check, intrusion_fsm, override_qa, and code_scope_shadow, while failing completely on the remaining tasks. Finally, Unbounded_Tree_MLP fails universally, scoring below 3% on all tasks except for a minor success rate of 13.1% on xml_bracket_check.

GraphTree (Local Shift, No Expander)
Unbounded Tree-GNN
Pure Binary Tree-GNN
GraphTree (Bidirectional: Up + Down)
GraphTree (Bottom-Up + Shortcuts)
Flat Transformer (Sinusoidal)
Flat Transformer (RoPE + AttnPool)
Figure 4: Performance of the architecture variations on the eight defined tasks.
5 Discussion
The exceptional zero-shot length extrapolation demonstrated by GTFormer fundamentally challenges the prevailing consensus in long-context sequence modeling. While contemporary literature predominantly relies on hardware-aware exact attention or position embedding modifications to extend context windows, these approaches remain constrained by computational complexity and inevitably succumb to out-of-distribution statistical dilution at extreme lengths. Conversely, prior hierarchical architectures have struggled to maintain representational fidelity during deep recursive message passing, often failing at multi-hop induction due to dyadic boundary constraints and signal attenuation. By achieving accuracy on complex associative recall and pointer-variable resolution tasks at the training sequence length (), GTFormer establishes a highly effective structural prior. The integration of local shift binding and bounded convex highway gating allows the architecture to strictly maintain time and memory efficiency without sacrificing the exact retrieval capabilities traditionally monopolized by flat, fully connected Transformers.
The performance gap between GTFormer_NoExpander (98% at N = 131,072) and Unbounded_Tree_MLP (3.5%) highlights the mathematical mechanism critical for zero-shot length extrapolation in hierarchical networks. Evaluating models trained on ( tree levels) at N = 131,072 (17 levels) forces the recursive composition operator to execute almost twice as often as during optimization. In unconstrained MLP trees, any deviation from an isometric mapping compounds exponentially with depth , pushing hidden states outside the training manifold. Restricting parent nodes to a channel-wise convex combination of their children ensures representations stay strictly within the convex hull of the leaf embeddings regardless of depth. Furthermore, the network assigns an importance score, or salience, to each child node. By deriving the gate values from the raw difference between these scores ( ), the sigmoid activation functions like a hard switch, snapping cleanly to either 0 or 1. This allows crucial information to completely override irrelevant background data, preventing the signal from fading or diluting as it propagates up through deep layers of the tree.
A classic limitation of binary tree architectures is their sensitivity to dyadic partition boundaries: adjacent tokens at indices belong to separate elementary subtrees and cannot interact until their lowest common ancestor, which may lie up to levels above the leaves. The steady accuracy decline of Pure_Binary_Tree on unaligned_kv and adversarial_decoys , alongside its failure on odd-aligned 2-hop lookups, confirms that dyadic splitting degrades long-range composition as depth increases. Prepending a single 1-hop horizontal bilinear shift layer at the leaf level binds adjacent token pairs prior to tree reduction, completely eliminating boundary sensitivity while preserving complexity.
Contrary to the intuition that non-causal 2-hop dereferencing (where a pointer precedes its target definition ) requires either horizontal expander shortcuts or top-down root-to-leaf broadcasting during message passing, GTFormer_NoExpander solves both pointer_hop and multi_needle_rag at over 90% across all lengths (up to ) using a strictly bottom-up tree without expander edges. Because the hidden dimension ( ) provides sufficient capacity to partition orthogonal subspace channels across the five candidate variables and three pointer slots, the bottom-up convex gates independently route all variable bindings and pointer targets to the root vector, where the differentiable bilinear join bmm(softmax(P), softmax(V)) resolves the 2-hop lookup in a single step. Adding horizontal cyclic roll edges (GTFormer_BottomUp) or top-down coarse subtree refinement (GTFormer_Bidirectional) introduces cross-channel interference and extra recurrent gradient paths that slightly degrade multi-hop optimization stability while doubling inference latency (1226.09–1244.06 ms vs. 654.77 ms at ).
While standard Transformer encoders face dual barriers—statistical attention dilution outside the training horizon and quadratic memory growth (> 1.1 TB estimated for naive attention at )—GTFormer scales linearly in total operations , logarithmically in sequential depth , and linearly in memory (1.43 GB at and 22.1 GB at ). Processing -token sequences in 1244.06 ms on a single GPU demonstrates that scale-invariant hierarchical graph reductions offer a highly compact, memory-efficient alternative for extreme long-context reasoning.
In contemporary large language models, the quadratic memory bottleneck of naive self-attention is commonly mitigated via IO-aware tiling algorithms such as FlashAttention, which recompute attention blocks on-chip in fast SRAM to reduce memory complexity from to . Crucially, however, FlashAttention is an exact hardware optimization rather than an architectural approximation: it yields the exact same mathematical outputs and softmax probability distributions as standard full self-attention. Consequently, while FlashAttention would allow the Flat_Transformer baselines to bypass the VRAM exhaustion limit beyond , it provides no remedy for their statistical extrapolation collapse. Because the underlying attention mechanism remains identical, a FlashAttention-enabled transformer experiences the exact same out-of-distribution softmax dilution and positional degradation observed at (16.8%-22.8% accuracy) and (3.9%-9.1% accuracy), while still incurring quadratic computational FLOPs. By contrast, GTFormer addresses both the hardware and statistical bottlenecks simultaneously, achieving true computational work, memory scaling, and 98% zero-shot accuracy up to via bounded convex tree reductions.
Although the empirical evaluation focuses on controlled synthetic benchmarks with compact embedding dimensions, the underlying pointer-variable resolution task isolates the core computational primitive governing long-context Transformer performance: content-based associative recall and multi-hop induction over arbitrary distances. In large-scale language and code modeling, failures in long-range reasoning rarely stem from a lack of parameter capacity, but rather from representational dilution, attention dispersion, and positional out-of-distribution degradation as sequence length N scales. By demonstrating zero-shot length extrapolation up to the training context within a constrained parameter budget, the results confirm that the topological inductive bias of GTFormer—specifically the combination of local shift bridging and bounded convex highway contractions—resolves these routing bottlenecks structurally rather than through brute-force scale. Furthermore, because the hierarchical contraction layers operate in time and memory complexity with full level-wise parallelism, the architecture can be directly scaled to wider hidden dimensions ( ) or integrated as a drop-in global routing backbone within hybrid Transformer blocks for industrial-scale sequence modeling.
While GTFormer achieves exceptional accuracy and length extrapolation, its hierarchical routing increases runtime overhead relative to simple flat transformer architectures. This latency stems from dense tensor operations across full channel dimensions rather than any theoretical limit of the tree topology-resulting in very sparse adjacency matrices. Adopting specialized sparse graph algorithms—such as active-node pruning, masked message passing, or sparse tensor representations—will restrict computation strictly to active pointer-variable pathways, eliminating redundant operations in inactive subtrees and significantly improving wall-clock efficiency.
6 Conclusion
This work introduced GTFormer, a hierarchical graph-tree architecture designed to resolve long-range, out-of-order associative dependencies without the quadratic bottlenecks of standard self-attention. By combining local boundary-bridging shift edges ( ), multi-channel convex highway gates, horizontal expander shortcuts ( ), and top-down broadcast routing ( ), the proposed topology guarantees bounded signal propagation and logarithmic routing paths across arbitrary sequence lengths. Empirical evaluations on multi-pointer variable resolution demonstrate that while flat Transformer baselines suffer from severe attention dispersion and out-of-memory failures beyond , GTFormer achieves up to 100% zero-shot exact-match extrapolation from short training contexts ( ) to ultra-long sequences (up to ).
These findings offer a highly promising direction for the design of next-generation sequence models. Crucially, the ability to learn generalizable, scale-invariant routing rules purely on short sequences ( ) and deploy them zero-shot at larger contexts carries profound implications for computational sustainability. In contemporary foundation model pre-training and context-extension pipelines, an overwhelming share of wall-clock training time, GPU cluster allocation, and electrical power consumption is expended on long-context continual pre-training and quadratic attention computation. Replacing brute-force long-sequence training with structurally compositional, hierarchical operators enables models to master global reasoning dynamics within compact context windows. Consequently, integrating GTFormer as a drop-in backbone or hybrid routing layer holds the potential to cut training times, hardware memory footprints, and aggregate energy consumption immensely, paving the way for green, ultra-long-context AI systems.
Acknowledgements
The author gratefully acknowledges the pioneering work of the researchers who developed the Transformer architecture, as well as the open-source and research teams at Google who laid the foundational infrastructure that made this work possible in a very short amount of time. While this study investigates the limitations of standard Transformers in specific contexts and proposes GTFormer as an alternative, the achievements of the original Transformer paradigm remain a monumental milestone that fundamentally transformed the field of artificial intelligence. This research stands upon the shoulders of those breakthroughs, and the ability to design, test, and iterate on GTFormer in such a short timeframe is a direct testament to the enduring power and accessibility of that legacy.
Generative AI declaration
The author acknowledges the use of Gemini to generate code, both for the proposed model, for data analysis and plotting figures in Python as well as for drafting in this manuscript. The author fully reviewed, edited, and take ultimate responsibility for the final content.
References
[1] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, and I. Polosukhin, "Attention is all you need," in Advances in Neural Information Processing Systems (NeurIPS), vol. 30, 2017, pp. 5998–6008.
[2] T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan et al., “Language models are few-shot learners,” in Advances in Neural Information Processing Systems (NeurIPS), vol. 33, 2020, pp. 1877–1901.
[3] J. Jumper, R. Evans, A. Pritzel, T. Green, M. Figurnov, O. Ronneberger, K. Tunyasuvunakool et al., "Highly accurate protein structure prediction with AlphaFold," Nature, vol. 596, no. 7873, pp. 583–589, 2021.
[4] B. Romera-Paredes, M. Barekatain, A. Novikov, M. Balog, M. P. Kumar, E. Dupont, F. J. R. Ruiz et al., “Mathematical discoveries from program search with large language models,” Nature, vol. 625, no. 7995, pp. 468–475, 2024.
[5] T. H. Trinh, Y. Wu, Q. V. Le, H. He, and T. Luong, “Solving olympiad geometry without human demonstrations,” Nature, vol. 625, no. 7995, pp. 476–482, 2024.
[6] E. Strubell, A. Ganesh, and A. McCallum, “Energy and policy considerations for deep learning in NLP,” in Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (ACL), 2019, pp. 3645–3650.
[7] D. Patterson, J. Gonzalez, Q. Le, C. Liang, L.-M. Munguia, D. Rothchild, D. So, M. Texier, and J. Dean, "Carbon emissions and large neural network training," arXiv preprint arXiv:2104.10350, 2021.
[8] N. F. Liu, K. Lin, J. Hewitt, A. Paranjape, M. Bevilacqua, F. Petroni, and P. Liang, “Lost in the middle: How language models use long contexts,” Transactions of the Association for Computational Linguistics (TACL), vol. 12, pp. 157–173, 2024.
[9] J. Su, M. Ahmed, Y. Lu, S. Pan, W. Bo, and Y. Liu, “RoFormer: Enhanced transformer with rotary position embedding,” Neurocomputing, vol. 568, p. 127063, 2024.
[10] A. Kazemnejad, I. Padhi, K. Natesan Ramamurthy, P. Das, and S. Reddy, “The impact of positional encoding on length generalization in transformers,” in Advances in Neural Information Processing Systems (NeurIPS), vol. 36, 2023.
[11] Y. Tay, M. Dehghani, D. Bahri, and D. Metzler, “Efficient transformers: A survey,” ACM Computing Surveys, vol. 55, no. 6, pp. 1–28, 2022.
[12] I. Beltagy, M. E. Peters, and A. Cohan, “Longformer: The long-document transformer,” arXiv preprint arXiv:2004.05150, 2020.
[13] M. Zaheer, G. Guruganesh, K. A. Dubey, J. Ainslie, C. Alberti, S. Ontanon, P. Pham, A. Ravula et al., "Big Bird: Transformers for longer sequences," in Advances in Neural Information Processing Systems (NeurIPS), vol. 33, 2020, pp. 17283–17297.
[14] H. Shirzad, A. Velingker, B. Venkatachalam, D. J. Sutherland, and A. K. Sinop, “Exphormer: Sparse transformers for graphs,” in Proceedings of the 40th International Conference on Machine Learning (ICML), vol. 202, 2023, pp. 31613–31632.
[15] Z. Ye, Q. Guo, Q. Gan, X. Qiu, and Z. Zhang, “BP-Transformer: Modelling long-range context via binary partitioning,” arXiv preprint arXiv:1911.04070, 2019.
[16] Z. Zhu and R. Soricut, “H-Transformer-1D: Fast one-dimensional hierarchical attention for sequences,” in Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics (ACL), 2021, pp. 3801–3815.
[17] R. Socher, C. C.-Y. Lin, A. Y. Ng, and C. D. Manning, “Parsing natural scenes and natural language with recursive neural networks,” in Proceedings of the 28th International Conference on Machine Learning (ICML), 2011, pp. 129–136.
[18] K. S. Tai, R. Socher, and C. D. Manning, “Improved semantic representations from tree-structured long short-term memory networks,” in Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics (ACL), 2015, pp. 1556–1566.
[19] A. Gu, K. Goel, and C. Ré, “Efficiently modeling long sequences with structured state spaces,” in International Conference on Learning Representations (ICLR), 2022.
[20] A. Gu and T. Dao, “Mamba: Linear-time sequence modeling with selective state spaces,” arXiv preprint arXiv:2312.00752, 2023.
[21] W. Merrill, J. Petty, and A. Sabharwal, “The illusion of state in state-space models,” in Proceedings of the 41st International Conference on Machine Learning (ICML), 2024.
[22] E. Fink, “Learning the Word Problem: Geodesic lengths and cryptographic applications,” 2026. [Online]. Available: https://arxiv.org/abs/2607.26241
[23] F. Scarselli, M. Gori, A. C. Tsoi, M. Hagenbuchner, and G. Monfardini, “The graph neural network model,” IEEE Transactions on Neural Networks, vol. 20, no. 1, pp. 61–80, 2009.
[24] Y. Li, D. Tarlow, M. Brockschmidt, and R. Zemel, “Gated graph sequence neural networks,” in International Conference on Learning Representations (ICLR), 2016.
[25] I. Loshchilov and F. Hutter, “Decoupled weight decay regularization,” in International Conference on Learning Representations (ICLR), 2019. [Online]. Available: https://openreview.net/forum?id=Bkg6RiCqZ
[26] ___,“SGDR: Stochastic gradient descent with warm restarts,” in International Conference on Learning Representations (ICLR), 2017.
A Detailed Results Tables
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | |||||
| Flat Transformer (RoPE + At-ttnPool) | OOM |
Table A1: Zero-shot length extrapolation accuracy on task override_qa (Part 1).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + At-ttnPool) | OOM | OOM | OOM | OOM | OOM | OOM |
Table A2: Zero-shot length extrapolation accuracy on task override_qa (Part 2).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | |||||
| Flat Transformer (RoPE + At-ttnPool) | OOM |
Table A3: Zero-shot length extrapolation accuracy on task unaligned_kv (Part 1).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Expansion) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + At-tnPool) | OOM | OOM | OOM | OOM | OOM | OOM |
Table A4: Zero-shot length extrapolation accuracy on task unaligned_kv (Part 2).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Expansion) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | |||||
| Flat Transformer (RoPE + At-tnPool) | OOM |
Table A5: Zero-shot length extrapolation accuracy on task pointer_hop (Part 1).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Expansion) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + At-tnPool) | OOM | OOM | OOM | OOM | OOM | OOM |
Table A6: Zero-shot length extrapolation accuracy on task pointer_hop (Part 2).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Expansion) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | |||||
| Flat Transformer (RoPE + At-tnPool) | OOM |
Table A7: Zero-shot length extrapolation accuracy on task intrusion_fsm (Part 1).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Expansion) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + At-tnPool) | OOM | OOM | OOM | OOM | OOM | OOM |
Table A8: Zero-shot length extrapolation accuracy on task intrusion_fsm (Part 2).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | |||||
| Flat Transformer (RoPE + At-tnPool) | OOM |
Table A9: Zero-shot length extrapolation accuracy on task code_scope_shadow (Part 1).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + At-tnPool) | OOM | OOM | OOM | OOM | OOM | OOM |
Table A10: Zero-shot length extrapolation accuracy on task code_scope_shadow (Part 2).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | |||||
| Flat Transformer (RoPE + At-tnPool) | OOM |
Table A11: Zero-shot length extrapolation accuracy on task multi_needle_rag (Part 1).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + At-tnPool) | OOM | OOM | OOM | OOM | OOM | OOM |
Table A12: Zero-shot length extrapolation accuracy on task multi_needle_rag (Part 2).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | |||||
| Flat Transformer (RoPE + At-tnPool) | OOM |
Table A13: Zero-shot length extrapolation accuracy on task xml_bracket_check (Part 1).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + At-tnPool) | OOM | OOM | OOM | OOM | OOM | OOM |
Table A14: Zero-shot length extrapolation accuracy on task xml_bracket_check (Part 2).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | |||||
| Flat Transformer (RoPE + At-tnPool) | OOM |
Table A15: Zero-shot length extrapolation accuracy on task adversarial_decoys (Part 1).
| Architecture | ||||||
|---|---|---|---|---|---|---|
| GraphTree (Bidirectional: Up + Down) | ||||||
| GraphTree (Bottom-Up + Short-cuts) | ||||||
| GraphTree (Local Shift, No Ex-pander) | ||||||
| Pure Binary Tree-GNN (No Shortcuts) | ||||||
| Unbounded Tree-GNN (No Convex Gate) | ||||||
| Flat Transformer (Sinusoidal) | OOM | OOM | OOM | OOM | OOM | OOM |
| Flat Transformer (RoPE + At-tnPool) | OOM | OOM | OOM | OOM | OOM | OOM |
Table A16: Zero-shot length extrapolation accuracy on task adversarial_decoys (Part 2).