SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2107.01952 · NeurIPS · 2021

Partition and Code: learning how to compress graphs

Michael Bronstein, Andreas Loukas, Giorgos Bouritsas, Nikolaos Karalias

arXiv · PDF · Open in the Atlas

Code that ran

7 of 14 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; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 3 failures of our instrument; 7 no recorded run), measured 2026-11-22; 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/2107.01952.json · badge: /api/ran/2107.01952.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
gbouritsas/PnC marked official in Papers with Code
Papers with Code archive
7 ran · 7 no recorded run
FunctionStatusWhere it lives
choose_activation Ran
ran; our contract draft was wrong, not the code
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("8cece8d22b52bc54")
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 ReLU. 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)

ARGS = {
    'activation': 'relu'
}
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 ReLU — a ReLU output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ReLU 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
global_add_pool_sparse Ran
ran; our contract draft was wrong, not the code
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("83e9302ed0fe1f1b")
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 Tensor, ndim 2, dtype family float, shape (2, 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)

# Create a small feature tensor: shape (num_nodes, feature_dim)
# Using distinct dimensions: 6 nodes, 4 features
x = torch.randn(6, 4)

# Create batch tensor: assigns each node to a graph
# Values range from 0 to num_graphs-1
# 6 nodes distributed across 2 graphs
batch = torch.tensor([0, 0, 0, 1, 1, 1], dtype=torch.long)

# num_graphs is optional, but we'll provide it
num_graphs = 2

ARGS = {
    "x": x,
    "batch": batch,
    "num_graphs": num_graphs,
}
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 Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 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
global_mean_pool_sparse Ran
ran; our contract draft was wrong, not the code
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("2da63d8f037ad4d9")
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 Tensor, ndim 2, dtype family float, shape (2, 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
from torch_geometric.utils import degree

torch.manual_seed(0)

# Create small tensors for testing
# x: node features, shape [num_nodes, feature_dim]
num_nodes = 6
feature_dim = 4
x = torch.randn(num_nodes, feature_dim)

# batch: graph assignment for each node, shape [num_nodes]
# Assign nodes to 2 different graphs
batch = torch.tensor([0, 0, 0, 1, 1, 1], dtype=torch.long)

# num_graphs: number of graphs (optional, can be None)
num_graphs = 2

ARGS = {
    "x": x,
    "batch": batch,
    "num_graphs": num_graphs,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch, torch_geometric — 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 (2, 4) — shape (2, 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
mlp Ran
ran on a synthesized input
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("cd5a40ffd4482a6d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 3) 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
import torch.nn as nn

def choose_activation(activation):
    if activation == 'elu':
        return nn.ELU()
    elif activation == 'relu':
        return nn.ReLU()
    elif activation == 'tanh':
        return nn.Tanh()
    elif activation == 'identity':
        return lambda x: x
    else:
        raise NotImplementedError

class mlp(torch.nn.Module):

    def __init__(self, in_features, out_features, d_k, activation='elu', batch_norm=False):
        super(mlp, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.d_k = d_k
        self.activation_name = activation
        self.batch_norm = batch_norm
        self.fc = []
        self.bn = []
        d_in = [in_features]
        d_k = d_k + [out_features]
        for i in range(0, len(d_k)):
            self.fc.append(nn.Linear(d_in[i], d_k[i], bias=True))
            d_in = d_in + [d_k[i]]
            if self.batch_norm and i != len(d_k) - 1:
                self.bn.append(nn.BatchNorm1d(d_k[i]))
        self.fc = nn.ModuleList(self.fc)
        self.bn = nn.ModuleList(self.bn)
        self.activation = choose_activation(activation)

    def forward(self, x):
        for i in range(0, len(self.fc) - 1):
            if self.batch_norm:
                x = self.activation(self.bn[i](self.fc[i](x)))
            else:
                x = self.activation(self.fc[i](x))
        x = self.fc[-1](x)
        return x


INIT_ARGS = {
    'in_features': 4,
    'out_features': 3,
    'd_k': [8],
    'activation': 'elu',
    'batch_norm': False
}

ARGS = {
    'x': torch.randn(2, 4)
}

model = mlp(**INIT_ARGS)
output = model(**ARGS)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 (2, 3) — shape (2, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
multi_embedding Ran
ran on a synthesized input
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("c1e8d544258036a5")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, 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

# INIT_ARGS: d_in is a list of vocabulary sizes, d_out is embedding dimension
INIT_ARGS = {
    'd_in': [10, 15, 8],  # Three different vocabulary sizes
    'd_out': 6,
    'aggr': 'concat',
    'init': None
}

# ARGS: tensor should have shape (batch_size, num_embeddings) with integer indices
# Each column contains indices for the corresponding embedding table
ARGS = {
    'tensor': torch.tensor([
        [2, 5, 3],
        [7, 10, 1]
    ], dtype=torch.long)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
one_hot_encoder Ran
ran on a synthesized input
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("1f0176d5abd4a4be")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, 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

INIT_ARGS = {
    'd_in': [4, 3, 5]
}

# Construct input tensor with batch=2, sequence length=3 (matching len(d_in))
# Values in each column must be within the corresponding d_in range
ARGS = {
    'tensor': torch.tensor([
        [1, 0, 2],
        [3, 1, 4]
    ], dtype=torch.long)
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
zero_encoder Ran
ran on a synthesized input
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("c3f1381752954a99")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 3) 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

INIT_ARGS = {
    'd_out': 3
}

ARGS = {
    'tensor': torch.randn(2, 4)
}

if __name__ == '__main__':
    from torch import nn
    
    class zero_encoder(nn.Module):
        def __init__(self, d_out):
            super(zero_encoder, self).__init__()
            self.d_out = d_out
            return

        def forward(self, tensor):
            return torch.zeros((tensor.shape[0], self.d_out), device=tensor.device)

        def __repr__(self):
            return '{}({})'.format(self.__class__.__name__, self.d_out)
    
    model = zero_encoder(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Model: {model}")
    print(f"Input shape: {ARGS['tensor'].shape}")
    print(f"Output shape: {output.shape}")
    print(f"Output:\n{output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 (2, 3) — shape (2, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
DiscreteEmbedding Not yet run
unverified (harvested, no recorded run)
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("8b73e3e20eed4c7e")
How it ran

no invocation recorded.

MPNN Not yet run
unverified (harvested, no recorded run)
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("25c4c0727f9562c6")
How it ran

no invocation recorded.

MPNN_edge Not yet run
unverified (harvested, no recorded run)
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("4f5c1b211865576c")
How it ran

no invocation recorded.

MPNN_edge_sparse Not yet run
unverified (harvested, no recorded run)
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("8495449348deca6c")
How it ran

no invocation recorded.

MPNN_sparse Not yet run
unverified (harvested, no recorded run)
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("c25767f2fc88847f")
How it ran

no invocation recorded.

NeuralPartGNN Not yet run
unverified (harvested, no recorded run)
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("70d10c25ac5a1544")
How it ran

no invocation recorded.

central_encoder Not yet run
unverified (harvested, no recorded run)
gbouritsas/PnC/models/GNN_neural_part_subgraph_selection.py
code served (permissive licence) · get_code("43b0a3df8a2ecc9c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 13 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
choose_activation
brick of this paper's assembly: helper
3 other papers
3 later
2304.07702 (2023-04)
An Empirical Study of Realized GNN Expressiveness
2402.08595 (2024-02)
Homomorphism Counts for Graph Neural Networks: All About That Basis
2511.08028 (2025-11)
Generalizable Insights for Graph Transformers in Theory and Practice

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-22.

Repositories linked to this paper

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

Abstract

Can we use machine learning to compress graph data? The absence of ordering in graphs poses a significant challenge to conventional compression algorithms, limiting their attainable gains as well as their ability to discover relevant patterns. On the other hand, most graph compression approaches rely on domain-dependent handcrafted representations and cannot adapt to different underlying graph distributions. This work aims to establish the necessary principles a lossless graph compression method should follow to approach the entropy storage lower bound. Instead of making rigid assumptions about the graph distribution, we formulate the compressor as a probabilistic model that can be learned from data and generalise to unseen instances. Our "Partition and Code" framework entails three steps: first, a partitioning algorithm decomposes the graph into subgraphs, then these are mapped to the elements of a small dictionary on which we learn a probability distribution, and finally, an entropy encoder translates the representation into bits. All the components (partitioning, dictionary and distribution) are parametric and can be trained with gradient descent. We theoretically compare the compression quality of several graph encodings and prove, under mild conditions, that PnC achieves compression gains that grow either linearly or quadratically with the number of vertices. Empirically, PnC yields significant compression improvements on diverse real-world networks. 1

For agents

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

get_harvested_code_for_paper("2107.01952")
get_code_for_paper("2107.01952")
have("2107.01952")

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

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

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

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

Connect an agent — have() is free.