SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2202.03036 · ICML · 2022

Structure-Aware Transformer for Graph Representation Learning

Karsten Borgwardt, Dexiong Chen, Leslie O'bray

arXiv · PDF · Open in the Atlas

Code that ran

8 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 3 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 1 failure of our instrument; 1 no recorded run), measured 2026-11-21; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2202.03036.json · badge: /api/ran/2202.03036.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
borgwardtlab/sat canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
borgwardtlab/pst community (classifier label)
classifier basis not recorded on the link
6 ran · 1 no recorded run
FunctionStatusWhere it lives
accuracy Ran
ran on a synthesized input
borgwardtlab/pst/pst/downstream/mlp.py
code served (permissive licence) · get_code("e6346ac266435823")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# The function expects:
# - output: a tensor with shape (batch_size, num_classes) that has a .topk() method
# - target: a tensor with shape (batch_size,) that has .size() and .view() methods
# - topk: a tuple of integers (default (1,))

batch_size = 2
num_classes = 4

# Create output tensor (logits/predictions): shape (batch_size, num_classes)
output = torch.randn(batch_size, num_classes)

# Create target tensor (ground truth labels): shape (batch_size,)
# Labels should be in range [0, num_classes)
target = torch.tensor([0, 2])

# topk parameter
topk = (1,)

ARGS = {
    "output": output,
    "target": target,
    "topk": topk,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
apply_rotary_pos_emb Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
borgwardtlab/pst/pst/rotary_embedding.py
code served (permissive licence) · get_code("2a127d3ae372d7bd")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Analyze function usage:
# - x: tensor that gets chunked on dim=-1, so needs even last dimension
# - cos: tensor indexed as cos[:, :x.shape[-2], :], so needs shape (batch, seq, dim)
# - sin: tensor indexed as sin[:, :x.shape[-2], :], so needs shape (batch, seq, dim)
# All tensors participate in element-wise operations

# Create small tensors with distinct dimensions
batch_size = 2
seq_len = 3
hidden_dim = 4

# x: (batch, seq_len, hidden_dim) - last dim must be even for rotate_half to chunk it
x = torch.randn(batch_size, seq_len, hidden_dim)

# cos and sin: (batch, seq_len, hidden_dim)
# They will be sliced to [:, :seq_len, :] which should work fine
cos = torch.randn(batch_size, seq_len + 1, hidden_dim)  # slightly larger to test slicing
sin = torch.randn(batch_size, seq_len + 1, hidden_dim)

ARGS = {
    "x": x,
    "cos": cos,
    "sin": sin,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 4) — shape (2, 3, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
eval_epoch Ran
ran, honoured the contract we drafted
borgwardtlab/sat/experiments/train_zinc.py
code served (permissive licence) · get_code("324691a9739115fa")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader, TensorDataset

torch.manual_seed(0)

# Create a minimal model that accepts data with .y attribute and returns predictions
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, data):
        # data has .x and .y attributes
        return self.linear(data.x)

# Create a minimal data object with .x and .y attributes
class MinimalData:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    
    def cuda(self):
        self.x = self.x.cuda()
        self.y = self.y.cuda()
        return self

# Create a minimal loader that has .dataset attribute
class MinimalLoader:
    def __init__(self, data_list):
        self.data_list = data_list
        self.dataset = type('Dataset', (), {'__len__': lambda self: len(data_list)})()
    
    def __iter__(self):
        return iter(self.data_list)
    
    def __len__(self):
        return len(self.data_list)

# Build tiny data samples
x1 = torch.randn(2, 4)
y1 = torch.randn(2, 3)
data1 = MinimalData(x1, y1)

x2 = torch.randn(2, 4)
y2 = torch.randn(2, 3)
data2 = MinimalData(x2, y2)

# Create loader
loader = MinimalLoader([data1, data2])

# Create model
model = MinimalModel()

# Create criterion
criterion = nn.MSELoss()

ARGS = {
    'model': model,
    'loader': loader,
    'criterion': criterion,
    'use_cuda': False,
    'split': 'Val'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_model Ran
ran on a synthesized input
borgwardtlab/pst/pst/esm2.py
code served (permissive licence) · get_code("a86103fee746fce2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned DummyModel. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class DummyModel(nn.Module):
    def __init__(self, embed_dim, num_heads, num_layers, **kwargs):
        super().__init__()
        self.embed_dim = embed_dim
        self.num_heads = num_heads
        self.num_layers = num_layers
        self.linear = nn.Linear(embed_dim, embed_dim)
    
    def forward(self, x):
        return self.linear(x)

ARGS = {
    'cls': DummyModel,
    'model_name': 'esm2_t6_8M_UR50D',
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DummyModel — a DummyModel output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DummyModel output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
rotate_half Ran
ran, honoured the contract we drafted
borgwardtlab/pst/pst/rotary_embedding.py
pointer only (licence: BSD-3-Clause); the stored copy get_code serves, from tdooms/bilinear-decomposition, is pointer only (licence: NONE) · get_code("437c7011506995a3")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-3-Clause), but get_code serves the stored copy, first harvested from tdooms/bilinear-decomposition, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

to_dense_batch Ran
ran on a synthesized input
borgwardtlab/pst/pst/utils.py
code served (permissive licence) · get_code("34890f3c2b8599f9")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Build x as a single tensor with shape [num_nodes + num_cls_tokens, feature_dim]
# We'll have 5 nodes total + 2 cls tokens = 7 elements
num_nodes_total = 5
num_cls_tokens = 2
feature_dim = 4

x = torch.randn(num_nodes_total + num_cls_tokens, feature_dim)

# Build ptr to define graph structure with 2 graphs
# ptr[i] is the cumulative count of nodes up to (but not including) graph i
# Graph 0: nodes 0-2 (3 nodes)
# Graph 1: nodes 3-4 (2 nodes)
ptr = torch.tensor([0, 3, 5], dtype=torch.long)

return_mask = False
fill_value = 0.0

ARGS = {
    'x': x,
    'ptr': ptr,
    'return_mask': return_mask,
    'fill_value': fill_value,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 4, 4) — shape (2, 4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
train_epoch Ran
ran, honoured the contract we drafted
borgwardtlab/sat/experiments/train_zinc.py
code served (permissive licence) · get_code("ab698930f5477224")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned float, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal model that accepts data and returns output
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, data):
        # The function calls model(data) and expects output
        # output is used with criterion(output, data.y)
        return self.linear(data.x)

# Create a minimal data class with required attributes
class MinimalData:
    def __init__(self, x, y, abs_pe):
        self.x = x
        self.y = y
        self.abs_pe = abs_pe
    
    def cuda(self):
        # Return self for chaining, but stay on CPU
        return self

# Create a minimal data loader (list of batches)
def create_loader():
    batches = []
    for _ in range(3):
        x = torch.randn(2, 4)  # batch_size=2, features=4
        y = torch.randint(0, 2, (2,))  # batch_size=2, binary labels
        abs_pe = torch.randn(2, 5)  # batch_size=2, pe_dim=5
        data = MinimalData(x, y, abs_pe)
        batches.append(data)
    return batches

# Create criterion
criterion = nn.CrossEntropyLoss()

# Create model
model = MinimalModel()

# Create optimizer
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)

# Create lr_scheduler (callable that takes iteration and returns lr)
def lr_scheduler(iteration):
    return 0.01 * (0.9 ** (iteration // 10))

# Create loader with dataset attribute
loader = create_loader()
loader_with_dataset = type('Loader', (), {
    '__iter__': lambda self: iter(loader),
    '__len__': lambda self: len(loader),
    'dataset': type('Dataset', (), {'__len__': lambda self: sum(len(b.y) for b in loader)})()
})()

# Global args object for the function to access
class Args:
    warmup = None
    abs_pe = 'lap'

args = Args()

# Make args globally accessible
import sys
sys.modules[__name__].args = args

ARGS = {
    'model': model,
    'loader': loader_with_dataset,
    'criterion': criterion,
    'optimizer': optimizer,
    'lr_scheduler': lr_scheduler,
    'epoch': 0,
    'use_cuda': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (fixture:KeyError)
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unpad_dense_batch Ran
ran on a synthesized input
borgwardtlab/pst/pst/utils.py
code served (permissive licence) · get_code("94a8734c22d5fd0f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (7, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Construct arguments for unpad_dense_batch
# The function expects:
# - x: tensor of shape (bsz, n, d) - a batch of padded sequences
# - mask: boolean tensor of shape (bsz, n) - True where padding is
# - ptr: tensor of pointers indicating sequence boundaries

bsz = 2  # batch size
n = 5    # padded sequence length (includes potential cls token)
d = 4    # embedding dimension

# Create x tensor: (bsz, n, d)
x = torch.randn(bsz, n, d)

# Create mask: True indicates padding positions
# For this example, first sequence has 3 real tokens + 2 padding,
# second sequence has 2 real tokens + 3 padding
mask = torch.tensor([
    [False, False, False, True, True],
    [False, False, True, True, True]
])

# Create ptr: cumulative pointer array
# ptr[0] = 0 (start), ptr[1] = 3 (first seq has 3 nodes), ptr[2] = 5 (second seq has 2 more nodes)
ptr = torch.tensor([0, 3, 5])

ARGS = {
    "x": x,
    "mask": mask,
    "ptr": ptr
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (7, 4) — shape (7, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
train_and_eval_linear Not yet run
unverified (harvested, no recorded run)
borgwardtlab/pst/pst/downstream/mlp.py
code served (permissive licence) · get_code("59c49da00f1bc1d8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 2 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 2 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
rotate_half 13 other papers
13 later · 2 only as an assembly brick
2203.07852 (2022-03)
Block-Recurrent Transformers
2403.00043 (2024-03)
RiNALMo: General-Purpose RNA Language Models Can Generalize Well on Structure Prediction Tasks
2406.03386 (2024-06)
Learning Long Range Dependencies on Graphs via Random Walks
and 10 more not named here
apply_rotary_pos_emb 3 other papers
3 later
2406.03386 (2024-06)
Learning Long Range Dependencies on Graphs via Random Walks
2408.11363 (2024-08)
ProteinGPT: Multimodal LLM for Protein Property Prediction and Structure Understanding
2606.18703 (2026-06)
Contextualizing Biological Language Models across Modalities via Logit-Space Contrastive Alignment

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

The Transformer architecture has gained growing attention in graph representation learning recently, as it naturally overcomes several limitations of graph neural networks (GNNs) by avoiding their strict structural inductive biases and instead only encoding the graph structure via positional encoding. Here, we show that the node representations generated by the Transformer with positional encoding do not necessarily capture structural similarity between them. To address this issue, we propose the Structure-Aware Transformer, a class of simple and flexible graph Transformers built upon a new self-attention mechanism. This new self-attention incorporates structural information into the original self-attention by extracting a subgraph representation rooted at each node before computing the attention. We propose several methods for automatically generating the subgraph representation and show theoretically that the resulting representations are at least as expressive as the subgraph representations. Empirically, our method achieves state-of-the-art performance on five graph prediction benchmarks. Our structure-aware framework can leverage any existing GNN to extract the subgraph representation, and we show that it systematically improves performance relative to the base GNN model, successfully combining the advantages of GNNs and Transformers. Our code is available at https: //github.com/BorgwardtLab/SAT.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2202.03036")
get_code_for_paper("2202.03036")
have("2202.03036")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2202.03036.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2202.03036.svg)](https://syntology.ai/paper/2202.03036)

Connect an agent — have() is free.