SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2306.01589 · NeurIPS · 2023

Transfer learning for atomistic simulations using GNNs and kernel mean embeddings

Massimiliano Pontil, Pietro Novelli, John Falk, Luigi Bonati, Michele Parrinello

arXiv · PDF · Open in the Atlas

Code that ran

7 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-23; 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/2306.01589.json · badge: /api/ran/2306.01589.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
IsakFalk/atomistic_transfer_mekrr canonical (classifier label)
classifier basis: census
6 ran · 1 no recorded run
isakfalk/atomistic_transfer_mekrr canonical (classifier label)
classifier basis: classifier_2025
1 ran · 2 no recorded run
FunctionStatusWhere it lives
KernelMeanEmbeddingRidgeRegression Ran
ran on a synthesized input · constructed an object; no result was computed
isakfalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/models/distribution_regression.py
code served (permissive licence) · get_code("538da70b4de12205")
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 KernelMeanEmbeddingRidgeRegression: the class was constructed and called, and the call returned an instance of its own class. 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.linalg as LA
from torch import Tensor
from abc import ABC, abstractmethod
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.metrics import mean_squared_error


class SimpleKernel(ABC):
    @abstractmethod
    def __call__(self, x, y):
        pass


class RBFKernel(SimpleKernel):
    def __init__(self, sigma: float = 1.0):
        self.sigma = sigma
    
    def __call__(self, x: Tensor, y: Tensor) -> Tensor:
        # RBF kernel: exp(-||x - y||^2 / (2 * sigma^2))
        x_norm = (x ** 2).sum(dim=1, keepdim=True)
        y_norm = (y ** 2).sum(dim=1, keepdim=True)
        dist_sq = x_norm + y_norm.t() - 2 * (x @ y.t())
        return torch.exp(-dist_sq / (2 * self.sigma ** 2))


class SimpleMeanEmbeddingKernel(ABC):
    def __init__(self, kernel: SimpleKernel):
        self.kernel = kernel

    @abstractmethod
    def __call__(self, x, y):
        pass

    def _mean_embedding_kernel(self, x: Tensor, y: Tensor, **kwargs) -> Tensor:
        t, n, d = x.shape
        l, m, d = y.shape
        x = x.reshape(t * n, d)
        y = y.reshape(l * m, d)
        k0 = self.kernel(x, y).reshape(t, n, l, m)
        k = k0.sum(axis=(1, 3)) / (n * m)
        return k


class MeanEmbeddingKernelImpl(SimpleMeanEmbeddingKernel):
    def __call__(self, x: Tensor, y: Tensor) -> Tensor:
        return self._mean_embedding_kernel(x, y)


class Kernel(ABC):
    @abstractmethod
    def __call__(self, x, y):
        pass


class MeanEmbeddingKernel(ABC):
    def __init__(self, kernel: Kernel):
        self.kernel = kernel

    @abstractmethod
    def __call__(self, x, y):
        pass

    def _mean_embedding_kernel(self, x: Tensor, y: Tensor, **kwargs) -> Tensor:
        t, n, d = x.shape
        l, m, d = y.shape
        x = x.reshape(t * n, d)
        y = y.reshape(l * m, d)
        k0 = self.kernel(x, y).reshape(t, n, l, m)
        k = k0.sum(axis=(1, 3)) / (n * m)
        return k


class KernelMeanEmbeddingRidgeRegression(BaseEstimator, RegressorMixin):
    def __init__(self, kernel: MeanEmbeddingKernel, lmbda: float = 1.0):
        self.kernel = kernel
        self.lmbda = lmbda

    def fit(self, X: Tensor, y: Tensor):
        assert len(X.shape) == 3
        assert len(y.shape) == 2
        self.X_ = X
        self.y_ = y
        k = self.kernel(X, X)
        klmbda = k - k.diag().diag() + (self.lmbda * self.X_.shape[0] + k.diag()).diag()
        self.k_ = k
        self.alpha_ = LA.solve(klmbda, y)
        return self

    def predict(self, X: Tensor) -> Tensor:
        assert len(X.shape) == 3
        k = self.kernel(X, self.X_)
        return k @ self.alpha_

    def predict_y_and_grad(self, X: Tensor, pos: Tensor) -> Tensor:
        assert len(X.shape) == 3
        T, num_atoms, d = X.shape
        k = self.kernel(X, self.X_)
        y_pred = k @ self.alpha_
        grad_pred = torch.autograd.grad(y_pred, pos, grad_outputs=torch.ones_like(y_pred), create_graph=False, allow_unused=False)[0].reshape(T, num_atoms, -1)
        return (y_pred, grad_pred)

    def score(self, X: Tensor, y: Tensor) -> float:
        y_pred = self.predict(X)
        return float(mean_squared_error(y, y_pred))


class ConcreteKernel(Kernel):
    def __init__(self, sigma: float = 1.0):
        self.sigma = sigma
    
    def __call__(self, x: Tensor, y: Tensor) -> Tensor:
        x_norm = (x ** 2).sum(dim=1, keepdim=True)
        y_norm = (y ** 2).sum(dim=1, keepdim=True)
        dist_sq = x_norm + y_norm.t() - 2 * (x @ y.t())
        return torch.exp(-dist_sq / (2 * self.sigma ** 2))


class ConcreteMeanEmbeddingKernel(MeanEmbeddingKernel):
    def __call__(self, x: Tensor, y: Tensor) -> Tensor:
        return self._mean_embedding_kernel(x, y)


INIT_ARGS = {
    'kernel': ConcreteMeanEmbeddingKernel(ConcreteKernel(sigma=1.0)),
    'lmbda': 0.1
}

X_train = torch.randn(3, 2, 4)
y_train = torch.randn(3, 1)
X_test = torch.randn(2, 2, 4)
y_test = torch.randn(2, 1)

ARGS = {
    'X': X_train,
    'y': y_train
}

METHOD = 'fit'

if __name__ == '__main__':
    model = KernelMeanEmbeddingRidgeRegression(**INIT_ARGS)
    model.fit
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type KernelMeanEmbeddingRidgeRegression — the call returned an instance of its own class, which has no array shape; none is stated — the instrument coerces any output to an array; for a KernelMeanEmbeddingRidgeRegression 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
aggregate_metric Ran
ran on a synthesized input
IsakFalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/common/utils.py
code served (permissive licence) · get_code("357cb629c800ace4")
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 float, ndim 0, dtype family float, shape () 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)

# The function aggregate_metric takes a metric parameter
# and processes it through torch_detach_maybe, then computes mean().item()

# The metric can be:
# - A torch.Tensor
# - A list (which gets recursively processed)
# - A scalar or other type (gets converted to tensor)

# Let's create valid test cases:

# Case 1: Simple tensor
metric_tensor = torch.randn(2, 4)

# Case 2: List of tensors
metric_list = [torch.randn(2, 4), torch.randn(3, 5)]

# Case 3: List of scalars
metric_scalar_list = [1.5, 2.3, 3.1]

# Case 4: Nested list
metric_nested = [[1.0, 2.0], [3.0, 4.0]]

# Case 5: Single scalar
metric_scalar = 5.0

# For the function to work, we need a valid metric argument
# The function will call torch_detach_maybe on it and then compute mean()
# Let's use a simple tensor as the primary test case

ARGS = {
    "metric": torch.randn(2, 4)
}
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 float, ndim 0, dtype family float, shape () — shape () 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
energy_mae Ran
ran on a synthesized input
IsakFalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/modules/evaluator.py
code served (permissive licence) · get_code("5b4761e4a55124d9")
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 0, dtype family float, shape () 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)

# The function expects two arguments: prediction and target
# Each should be a dict with an 'energy' key containing a tensor
# The function computes mean absolute error between prediction['energy'] and target['energy']

prediction = {
    'energy': torch.tensor([1.5, 2.3], dtype=torch.float32)
}

target = {
    'energy': torch.tensor([1.2, 2.8], dtype=torch.float32)
}

ARGS = {
    'prediction': prediction,
    'target': target
}
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 0, dtype family float, shape () — shape () 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
forces_mae Ran
ran on a synthesized input
IsakFalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/modules/evaluator.py
code served (permissive licence) · get_code("f184773d827cdf85")
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 0, dtype family float, shape () 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)

# The function expects two dicts, each containing a 'forces' key
# The forces tensor should have shape (batch, atoms, 3) based on sum(dim=2)
# We'll use batch=2, atoms=4, forces=3

prediction = {
    'forces': torch.randn(2, 4, 3)
}

target = {
    'forces': torch.randn(2, 4, 3)
}

ARGS = {
    'prediction': prediction,
    'target': target
}
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 0, dtype family float, shape () — shape () 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
forces_rmse Ran
ran on a synthesized input
IsakFalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/modules/evaluator.py
code served (permissive licence) · get_code("e715396821430ff8")
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 0, dtype family float, shape () 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)

# The function expects prediction and target to be dicts with 'forces' keys
# The 'forces' values should be tensors with shape (batch, atoms, 3) or similar
# since it does e.sum(dim=2).mean() - summing over dimension 2 and then taking mean

# Create prediction dict with forces tensor
# Shape: (batch=2, atoms=4, coordinates=3)
prediction = {
    'forces': torch.randn(2, 4, 3)
}

# Create target dict with forces tensor of same shape
target = {
    'forces': torch.randn(2, 4, 3)
}

ARGS = {
    'prediction': prediction,
    'target': target
}
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 0, dtype family float, shape () — shape () 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
median_heuristic Ran
ran on a synthesized input
IsakFalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/models/distribution_regression.py
code served (permissive licence) · get_code("6d77dd5f3c3a99b9")
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 float, ndim 0, dtype family float, shape () 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 import Tensor

torch.manual_seed(0)

# Create two small tensors with distinct dimensions
# x: batch_size=2, features=4
# y: batch_size=3, features=4
x = torch.randn(2, 4)
y = torch.randn(3, 4)

ARGS = {
    "x": x,
    "y": y,
}
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 float, ndim 0, dtype family float, shape () — shape () 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
torch_detach_maybe Ran
ran on a synthesized input
IsakFalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/common/utils.py
code served (permissive licence) · get_code("d5f02955c7ab1571")
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 (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)

# The function torch_detach_maybe handles:
# 1. lists - recursively processes each element
# 2. torch.Tensor - clones and detaches
# 3. other types - converts to tensor

# Test with a single tensor
ARGS = {
    "x": torch.randn(2, 4)
}
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 (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
Kernel Not yet run
unverified (harvested, no recorded run)
isakfalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/models/distribution_regression.py
code served (permissive licence) · get_code("3344cafe530a018d")
How it ran

no invocation recorded.

MeanEmbeddingKernel Not yet run
unverified (harvested, no recorded run)
isakfalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/models/distribution_regression.py
code served (permissive licence) · get_code("4706d81afc298fee")
How it ran

no invocation recorded.

get_config Not yet run
unverified (harvested, no recorded run)
IsakFalk/atomistic_transfer_mekrr/ocpmodels/transfer_learning/common/utils.py
code served (permissive licence) · get_code("3267a3f35af300d7")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 10 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.

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

Repositories linked to this paper

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

Abstract

Interatomic potentials learned using machine learning methods have been successfully applied to atomistic simulations. However, accurate models require large training datasets, while generating reference calculations is computationally demanding. To bypass this difficulty, we propose a transfer learning algorithm that leverages the ability of graph neural networks (GNNs) to represent chemical environments together with kernel mean embeddings. We extract a feature map from GNNs pre-trained on the OC20 dataset and use it to learn the potential energy surface from system-specific datasets of catalytic processes. Our method is further enhanced by incorporating into the kernel the chemical species information, resulting in improved performance and interpretability. We test our approach on a series of realistic datasets of increasing complexity, showing excellent generalization and transferability performance, and improving on methods that rely on GNNs or ridge regression alone, as well as similar fine-tuning approaches.

For agents

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

get_harvested_code_for_paper("2306.01589")
get_code_for_paper("2306.01589")
have("2306.01589")

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

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

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

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

Connect an agent — have() is free.