Let the Heads Talk: Beyond Diagonal Graph Attention

Riccardo Ali, Alessio Borgi, Mario Severino, Alessio Gravina, Davide Bacciu, Pietro Liò, Christopher IrwinarXiv 2026

TL;DR

Standard multi-head attention in Graph Neural Networks (GNNs) suffers from a "diagonal bottleneck": information in one head can only talk to the same head in a neighboring node. This paper introduces Topological Attention (Top-A), which allows attention heads to communicate across different channels on a per-edge basis, significantly boosting performance in complex relational and algorithmic reasoning tasks.

What Problem Does This Paper Address?

Most GNNs use scalar weights to pass messages—essentially just re-weighting a neighbor's features. While Sheaf Neural Networks (SNNs) introduced matrix-valued transport (transforming features during passage), they are often mathematically heavy and their specific benefits remain poorly understood.

Meanwhile, Multi-Head Attention (MHA) is the industry standard for GNNs. However, the authors point out a fundamental limitation: MHA is "diagonal." If you have 8 heads, head #3 at node $A$ only influences head #3 at node $B$. There is no way for an edge to say, "for this specific interaction, information in head #3 should be routed to head #5." This lack of cross-head communication limits the model's ability to handle complex relational compositions where the type of interaction should dictate how features are transformed.

Methods

The authors bridge the gap between SNNs and MHA using the formalism of quiver representations. They isolate the "transport primitive"—the linear map applied to a message along an edge—and show that standard MHA is just a special case where this map is a diagonal matrix.

To break this limitation, they propose Topological Attention (Top-A). The core mechanism is: $$T_{i \leftarrow j} = D_{i \leftarrow j}(I_H + \lambda \Omega_{i \leftarrow j})$$

  • $D_{i \leftarrow j}$: The standard diagonal attention matrix.
  • $I_H$: The identity matrix (preserving the original same-head paths).
  • $\Omega_{i \leftarrow j}$: A learned, edge-conditioned off-diagonal routing matrix that allows cross-head communication.
  • $\lambda$: A scale parameter to control the strength of this routing.
Comparison of message passing paradigms: Convolutional (scalar), MHA (diagonal matrix), and Top-A (full matrix transport).

Crucially, this routing happens before neighborhood aggregation. The authors provide a mathematical proof (Theorem 4.1) showing that this edge-specific pre-aggregation mixing cannot be replicated by simply adding a shared linear layer after aggregation.

Detailed view of how Top-A enables off-diagonal routing between source and receiver heads.

Datasets

The authors evaluated Top-A across four distinct settings:

  1. STaR (Systematic Relational Reasoning): Synthetic graphs (RCC-8 and Interval Algebra) where edges represent logical relations that must be composed along paths.
  2. MovieLens-100K: A real-world heterogeneous graph (users and movies) used for link prediction.
  3. CLRS-30 Algorithmic Reasoning Benchmark: 30 classical algorithms (sorting, searching, etc.) where models are trained on small instances and tested on much larger ones (Out-of-Distribution generalization).
  4. Heterophilic Node Classification: Standard benchmarks (e.g., Roman-empire, Chameleon) where neighbors often have different labels.

Key Insights and Ideas

  • MHA is a Sheaf: The paper proves that symmetric multi-head attention is mathematically equivalent to a specific type of diagonal cellular sheaf transport. This provides a solid theoretical foundation for why MHA works and how to extend it.
  • The Power of Pre-Aggregation: The "aha moment" is that once you sum up messages from all neighbors, you lose the ability to transform them individually based on their specific relationship to the receiver. Top-A's edge-specific routing preserves this relational nuance.
  • Heterophily isn't the whole story: Surprisingly, Top-A didn't provide a systematic advantage on standard heterophilic benchmarks. This suggests that the real value of matrix transport isn't just handling "different" neighbors, but rather handling interaction-dependent transformations—like those found in logic and algorithms.

Key Results

  • Relational Reasoning (STaR): Top-A showed massive gains in depth generalization. On the Interval Algebra task, Top-A variants achieved ~57% accuracy compared to ~18% for standard backbones when generalizing to unseen reasoning depths.
  • Algorithmic Reasoning (CLRS): Top-A significantly improved out-of-distribution performance, particularly on Sorting (+29.2 points) and Searching (+12.4 points) for GATv2 backbones.
  • Heterogeneous Graphs: On MovieLens, Top-A improved AUROC and revealed that the model learned distinct, asymmetric transport patterns for "rates" vs. "rated-by" relations.
Accuracy vs. reasoning depth on the STaR benchmark, showing Top-A's superior OOD generalization.

Limitations and Future Work

  • Computational Cost: Generating a dense $H \times H$ routing matrix for every edge adds overhead. The authors note the cost is $O(|E|H^2(p + C))$, which might be prohibitive for graphs with massive numbers of heads or very large edge feature dimensions ($p$).
  • Task Specificity: The benefits are highly task-dependent. While it excels at algorithmic logic, it offers little to no gain on simple node classification tasks where scalar weighting suffices.
  • Future Directions: The authors suggest exploring more efficient parameterizations of the routing matrix $\Omega$ and investigating how this cross-head communication interacts with deeper, non-recurrent GNN architectures.

Summary updated

Abstract

Sheaf Neural Networks generalize scalar-weighted message passing by replacing scalar edge weights with linear transport maps between local feature spaces. Yet the role of this matrix-valued transport is entangled with the broader sheaf-diffusion construction. We isolate the transport primitive through quiver representations and establish a direct connection with multi-head attention. Treating attention heads as coordinates of a local transport space reveals that standard multi-head attention implements diagonal edge maps: along each directed interaction, a source head can contribute only to the corresponding receiver head. Allowing off-diagonal entries instead enables edge-conditioned communication across heads before neighborhood aggregation. We show that this operation cannot, in general, be absorbed into a single shared linear map applied after aggregation. Building on this characterization, we introduce Topological Attention (Top-A), a multi-head attention that learns edge-dependent off-diagonal routes while preserving the original same-head paths and exactly recovering vanilla attention when the additional routing vanishes. We evaluate Top-A on relational reasoning, heterogeneous graph learning, and algorithmic reasoning, including out-of-distribution generalization, with heterophilic node classification as a contrast setting. The results show that cross-head transport is most useful when the task benefits from interaction-dependent transformations, while heterophily alone provides no systematic advantage. These findings identify edge-conditioned cross-head communication as a distinct computational primitive of matrix-valued transport.
BibTeX
@misc{ali2026let,
  author = {Riccardo Ali and Alessio Borgi and Mario Severino and Alessio Gravina and Davide Bacciu and Pietro Liò and Christopher Irwin},
  title = {{Let the Heads Talk: Beyond Diagonal Graph Attention}},
  year = {2026},
  eprint = {2610.01494},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.01494},
}
Figure