Gradformer
A graph transformer whose attention decays exponentially with graph distance, with a learnable mask per head.
Graphs and geometry · 341 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Graphs and geometry
- Parameters
- 188.8K
- Operations
- 341
- Framework
- PyTorch
- Recurrent
- No
- Published
- IJCAI 2024
- Cited by
- 7 (as of 17 October 2026)
- Authors
- Chuang Liu, Zelin Yao, Yibing Zhan and others
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m1227
- Graph hash
- 1648c957aca80e303fb9503cfde49fd8953b9f13f7310edb2924d55b78d08dfd
- Skeleton hash
- d27f29e9a0636c54ec37cabb6ad14640a6afbd5633dd9633c14b94f5c4e512a1
- Architecture hash
- 1585cfd8689abe346144c8983da56e620f299c40188b20063c0425e9c98d48cb
- Diagram SHA-256
- 16afbde436a768665257a8d04fe97385703a88d0b932ec06a58fdb13b3a32182
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
Gradformer is a graph transformer that puts graph structure back into self-attention by applying an exponential decay mask to the attention matrix. The motivation is that plain self-attention in graph transformers overlooks the graph's inductive biases, above all those tied to structure, which matter for graph tasks. Positional encodings and attention biases were earlier fixes, but the authors argue their effectiveness is still suboptimal.
The mask's values fall off exponentially as node proximity in the graph decreases. The model therefore keeps its reach to distant nodes while concentrating on local detail. A learnable constraint in the mask lets different attention heads learn distinct decay masks, which diversifies the heads. The mask is multiplied with the attention score, explicitly controlling each node's attention weights relative to the other nodes.
Across benchmarks, Gradformer is reported to beat both graph neural network and graph transformer baselines on graph classification and regression. It also trains deep: accuracy holds or improves as the network deepens, where other graph transformers lose accuracy. The code traced here is the authors' implementation for the IJCAI'24 paper, titled Gradformer: Graph Transformer with Exponential Decay.
Key idea. An exponential decay mask on graph transformer attention, tied to node proximity and learnable per head, that restores the graph's structural inductive bias.
- gradformer
- graph transformer with exponential decay
- exponential decay mask
- graph transformer
- graph classification
- nci1
- ijcai 2024
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{liu2024gradformergraphtransformerexponential,
title={Gradformer: Graph Transformer with Exponential Decay},
author={Chuang Liu and Zelin Yao and Yibing Zhan and Xueqi Ma and Shirui Pan and Wenbin Hu},
year={2024},
eprint={2404.15729},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2404.15729},
}