arXiv:2610.18471cs.LGOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.18471

Graph Metanetworks for Transformer Based Language Models

Yonathan Wolanowsky, Guy Bar-Shalom, Fabrizio Frasca, Haggai Maron

Abstract

Weight-space learning treats the weights of neural networks as data, processed by other models called metanetworks. A key challenge is that different weights can realize the same function, related by a group of symmetries the metanetwork should respect. While symmetry-aware metanetworks for simple architectures such as MLPs are well developed, a comprehensive treatment of transformers, and in particular transformer-based language models, is still missing. Importantly, their weight space has a richer symmetry group: beyond neuron permutations, attention introduces continuous general-linear symmetries of the attention matrices and permutations of entire heads. Existing methods for transformer weights either capture only part of these symmetries or are restricted to a single, fixed architecture, and none accounts for language-model-specific components such as the token embeddings. Building on graph metanetworks, we propose a graph-based approach that is both symmetry-aware and applicable across depths and widths. We formalize a weight-space symmetry group of complete decoder-only language models and provide a graph construction that is invariant to it. We further introduce two new transformer-population datasets with novel tasks, such as training-corpus prediction and fine-tuning detection, on which our approach notably outperforms existing baselines.

1 Introduction

The success of deep learning, together with the large number of publicly available trained models, has created a new data modality: the weights of neural networks themselves. The emerging field of weight-space learning [11, 40] treats these weights as data to train metanetworks that can process other networks' weights and predict model properties or edited weights with a single forward pass [21, 26, 36].

Two important challenges arise when designing effective metanetworks. First, input architectures may vary widely: an MLP, a CNN, and a transformer share no common parameterization, and even networks of the same family differ in architectural choices such as depth and width. Second, many different weight configurations realize the same function, related by a group of symmetries acting on the weight space, most prominently the permutations of hidden neurons [26, 44]. A metanetwork that is not invariant or equivariant to this group would need to use its capacity and data only to learn to treat such configurations as equivalent. These obstacles have motivated recent work on Graph metanetworks [18, 20], which address both challenges by representing a neural network as a graph (with neurons as nodes and parameters as edges) and by processing it with a graph neural network (GNN). Crucially, since GNNs are equivariant to node permutations, they respect the neuron-permutation symmetries of the encoded network.

Despite this progress, transformers [37] and, in particular, the decoder-only language models built from them, remain underexplored as a weight space, especially in terms of the underlying symmetry structure and graph representation. These architectures arguably represent the most important and widely used today, and their weight space is, in fact, also considerably richer in symmetries than that of other architectures. For example, within each attention head, the query and key projections enter the computation only through their product Wq(Wk)⊤\mathbf{W}^{q}(\mathbf{W}^{k})^{\top}, and the value and output projections only through WvWO\mathbf{W}^{v}\mathbf{W}^{O}, so each pair admits a continuous general-linear symmetry, on top of which entire heads can be permuted. Existing approaches to transformer weights follow two lines, each capturing only part of this picture. The first Graph Metanetworks [18, 20] provide a preliminary, simplified construction for attention, but do not account for the general-linear symmetries and do not encode the head structure faithfully. Conversely, Tran et al. [35] design layers equivariant to the general-linear and head-permutation symmetries, but tie the metanetwork to a single, fixed transformer architecture. Moreover, none of these works treats the components specific to language models, such as the token embedding matrices, and the symmetries they induce. As a result, no existing approach respects the symmetries of a complete transformer language model while remaining agnostic to its depth, width, and number of heads.

Our approach. We begin by formalizing a weight-space symmetry group of a complete decoder-only transformer language model, from the token embedding, through the stack of transformer blocks with their normalization layers and residual connections, up to the unembedding layer. This group combines permutations of the feed-forward hidden neurons, a permutation of the residual-stream features shared across all blocks, per-head general-linear symmetries of the query-key and value-output pairs, permutations of the heads within each block, as well as a permutation of the vocabulary that couples the embedding and unembedding matrices together. We prove that these transformations leave the function computed by the model unchanged (up to a relabeling of the vocabulary). Our approach thus unifies a range of previous, independent subcomponent analyses [34], [18], [20] into a single, comprehensive framework, extending the attention symmetries by Tran et al. [35] to a complete language model, including its residual stream, normalization layers, embedding, and unembedding.

We then design tailored graph constructions for transformers whose symmetries match this group, which we call Graph Metanetworks for Transformers (GMT). As in prior graph metanetworks, parameters are placed on edges between layers of nodes, so that a single GNN can process transformers of any depth, width, and number of heads. Unlike prior constructions, though, GMT uses parameter-free coupling edges and auxiliary head nodes which we show tie together exactly those node permutations that correspond to symmetries of the network: the residual-stream permutation is shared across blocks, the dimensions of each head module are bound together within each head, and the embedding is linked to the unembedding. We prove that, under mild rank conditions, two weight configurations yield isomorphic graphs if and only if they are related by an element of the aforementioned group: processing these graphs with a GNN thus guarantees the metanetwork remains invariant (or equivariant), to the transformer weight space group by construction. We propose two variants that trade exactness for efficiency: GMT-GL captures the full group, including the general-linear symmetries, and GMT-P, which as we will show, restricts these symmetries to permutations, yielding a more compact graph.

Finally, as open-weight language models are increasingly released and modified by third parties, questions such as what data was a model trained on? and has it been altered, and where? become pressing, yet lie beyond existing weight-space benchmarks, which focus on implicit neural representations and small vision classifiers. As a first step, we introduce two datasets of transformer language models with tasks that serve as small-scale, controlled proxies for these questions: predicting a model's training-corpus mixture, detecting fine-tuning, and identifying which weights it modified.

GMT outperforms existing baselines on all three, e.g., reducing the KL divergence of corpus-mixture prediction by 25% and halving the error of weight-level fine-tuning detection relative to prior graph metanetworks.

Contributions. We (i) formalize a weight-space symmetry group of complete decoder-only language models; (ii) introduce GMT, architecture-agnostic graph constructions whose isomorphisms match this group; and (iii) release two transformer-population datasets with auditing-motivated tasks, on which GMT outperforms existing baselines.

References (43)