arXiv:2610.27439cs.LGOct 2026

Manuscript Offprint

arXiv:2610.27439

Scaling Graph Reasoning in Language Models with Learnable Graph Positional Encodings

Javier Porras-Valenzuela, Arush Arora, Alejandro Ribeiro

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Solving reasoning tasks supported on graphs typically requires providing a Language Reasoning Model (LRM) with a serialized description of the graph. This approach results in the input length growing with the number of edges, which limits the size of the problems that can be solved. Furthermore, even when graphs fit in context, performance sharply decays as the graphs grow. We propose to address this by augmenting LRMs with scalable and permutation equivariant graph positional encodings that modulate attention logits. An additional post-fusion-style module incorporates structural information into hidden states. We compute these positional encodings using a GNN followed by a Graph Transformer. This eliminates the need for serialized adjacencies, reducing the context burden to O(N)O(N). We jointly fine-tune the positional encoder and the LRM LoRA adapters using optimal solutions generated by graph-theoretic solvers, resulting in a computationally efficient method. Trained on small graphs, the model exhibits improved size-generalization across graph-theoretic tasks on graphs with up to 1,000 nodes, and produces fewer tokens than a conventional LRM. Additionally, we observe that our model remains robust to node relabelings. Evaluations on graph-theoretic benchmarks also show that performance on small graphs is preserved.

1 INTRODUCTION

The remarkable success of Language Reasoning Models (LRMs) in autonomously solving complex tasks has fueled advancements in a variety of domains, such as coding, math and biology. Despite this, LRMs appear to struggle to scale on problems supported on graphs. More recently, Zhang et al. (2026) empirically showed that LRMs' reasoning performance on graph tasks sharply decays with problem length. Graphs provide a general substrate for the complexity of reasoning, and their underperformance calls into question whether LRMs truly are general reasoning engines.

Several efforts have been focused on adapting LRMs to graph-related reasoning domains. In particular, G1 Guo et al. (2025) showed that LRMs can be finetuned on graph-theoretic tasks, such as minimum spanning trees and shortest paths using RLVR on graphs of fewer than 40 nodes. In this approach, the LRM is prompted to solve a graph task accompanied by a text-based representation of the graph structure. However, we observe that this approach results in limited scalability, for two reasons: (i) transformers with sequential positional encodings are designed to bias towards sequence proximity; they possess no structural bias to encode graph locality nor structural symmetries, and (ii) serialization of the graph structure causes the prefill to have quadratic complexity in the number of edges. This results in an architecture that exhibits limited generalization and scalability to larger graphs. In contrast, the main contribution of our work is that:

• [C1] We develop GREG (GREG Reasoning Encodings for Graphs), a Graph Reasoning Model (GRM) that is able to solve graph-theoretic tasks at scale. To the best of our knowledge, this is the first GRM that can scale to graphs of up to 1,000 nodes.

Graph-aware models are known to have enough expressive power to solve fundamental graph reasoning tasks such as substructure and cycle counting, shortest paths Kanatsoulis et al. (2025), among others. In particular, graph neural networks exhibit key properties for graph reasoning, such as being permutation equivariant, stable, and generalizable to larger graphs than those seen during training.

Figure

Figure 1: Exact match on shortest paths over increasing graph sizes. As graphs grow, GREG retains its ability to recover shortest paths, while similar off-the-shelf LRMs and GRMs, even when fine-tuned for scale, decay sharply with graph size.

Furthermore, Graph Transformers have also been shown to exhibit size-generalization and improved empirical performance.

In light of these properties, we posit that graph models are useful to construct learnable positional encodings that provide a scalable method to endow LRMs with structural awareness. In this work, we propose a method for adapting LRMs into scalable GRMs. Our architecture leverages graph information via three architectural modifications: (i) GNN-based relative positional encodings, (ii) multi-hop graph attention masking for graph tokens, and (iii) a post-fusion-style Graph Transformer to modify the LRM's hidden states.

The rest of our contributions are the following:

[C2] A novel graph reasoning architecture that consists of an LRM with learnable relative positional encodings, multi-hop attention masking and post-fusion adapters. We propose an oracle-based SFT training method that aligns language and graph modalities more efficiently than distillation and RL-based training methods.

[C3] We conduct extensive experiments showing that this framework is (i) scalable to graphs of up to N nodes, (ii) robust to graph permutations and relabelings, and (iii) more computationally efficient both in training and inference than related graph finetuning approaches.

References (33)