Skip to main content

GO-Diff

GO-Diff: Data-free and amortized global structure optimization a generative diffusion framework for atomistic structure search. It couples a diffusion model with an energy/force calculator and iteratively refines the model through Boltzmann-weighted training, adaptive temperature annealing, and an adaptive replay buffer.


Installation

Install from pypi

pip install go-diff

(Optional) Install of MLIPs for running GO-Diff

E.g.

pip install mace-torch

Quick Start

import numpy as np

from ase.build import fcc111, surface
from mace.calculators import mace_mp

from agedi import AtomsGraph, create_diffusion
from agedi.diffusion import ForcefieldGuidanceConfig

from go_diff import GODiff, MinEnergyFilter
from go_diff.controllers import SampleController, BufferController, TemperatureSchedule, MomentumConsensusStop
from go_diff.noisers import WeightedConfinedCellPositions

##### SYSTEM #####
formula = "Pt"

template = surface('Pt', (1,2,2), 5, vacuum=8.0)
template.positions[:, 2] -= template.positions[:, 2].min()

confinement_above_zmax = np.array([0.0, 4.0])
confinement = confinement_above_zmax + template.positions[:, 2].max()


##### CALCULATOR #####
from mace.calculators import mace_mp
calc = mace_mp(model="medium", dispersion=False, default_dtype="float32", device='cuda')


#### DIFFUSION MODEL #####
diffusion = create_diffusion(noisers=(WeightedConfinedCellPositions(),), force_field=True)


#### GO-DIFF #####
godiff = GODiff(
    calculator=calc,
    diffusion=diffusion,
    temperature_schedule=TemperatureSchedule(fast=0.5, slow=0.9),
    sample_controller=SampleController(initial_N=16, target_ess=8),
    buffer_controller=BufferController(initial_buffer_size=16, max_buffer_size=96, adaption_rate=0.2),
    training_controller=MomentumConsensusStop(min_steps=100, patience=250, drop_factor=0.9),
    sample_config={
        "template": template,
        "formula": formula,
        "confinement": confinement,
        "ff_guidance": ForcefieldGuidanceConfig(guidance=1.0,)
    },
    dataset_config={
        "mask": "MaskFixed",
        "confinement": confinement,
        "regressor_data": "all_data", # use all data for training the regressor, not just the data in the buffer
    },
    trainer_config={
        "name": name
    },
    # Opt-in: relax each sample with the diffusion model's own force-field
    # regressor (requires AGeDi >= 1.5.0 and force_field=True above) before
    # it reaches the real calculator. None (the default) leaves this off;
    # an empty dict turns it on with fmax=0.05, steps=200. batch_size
    # mirrors the sampling batch size unless set here explicitly.
    # relax_config={
    #     "fmax": 0.05,
    #     "steps": 200,
    # },
    # Opt-in: source roughly half of each sampling call's structures from
    # agedi.inpaint (requires AGeDi >= 1.5.0) by regenerating a small
    # contiguous patch of a replay-buffer structure, instead of always
    # generating de novo from noise. None (the default) leaves this off;
    # an empty dict turns it on with portion=0.5, fraction=0.20,
    # contiguous=True, and a random t_start in (0.4, 0.8) per call. Falls
    # back to pure de-novo sampling whenever the buffer is empty (e.g.
    # iteration 0) or has no eligible parent.
    # inpaint_config={
    #     "portion": 0.5,
    #     "fraction": 0.20,
    #     "contiguous": True,
    # },
    min_E=min_E,
    valid_structure_filters=[MinEnergyFilter(-200)],    
)

#### RUN GO-Diff #####
godiff.run(max_iterations=20)

See scripts/*.py for the full scripts.


Key components

Class / module Description
GODiff Main optimisation loop (sample → evaluate → buffer → train)
TemperatureSchedule Adaptive annealing; fast / slow cooling factors based on heat capacity
SampleController Stops sampling when the Effective Sample Size (ESS) reaches a target
MomentumConsensusStop Stops training when gradient–momentum agreement drops
AdaptiveRefinementStop Stop criterion based on split-batch gradient agreement EMA
WeightedPositions Boltzmann-weighted position noiser for the diffusion model
GODiffLogger TensorBoard logger (energies, ESS, timing, analysis figures)
Reporter Console output sink every controller and GODiff.run() write through

Run output

GODiff.run() writes into the trainer's log directory (logs/<name>/version_<N> by default; see trainer_config={"name": ...} above):

logs/<name>/version_N/
  progress.md            # markdown table, one row per iteration -- tail this
  metrics.jsonl          # one JSON object per iteration, for scripted analysis
  config.yaml            # resolved run configuration, written once at start
  best.traj              # global-best structure, one frame per iteration
  all_data.traj          # every evaluated structure, unchanged from before
  last_good_state.pt     # NaN-guard rollback anchor, unchanged from before
  final_model.ckpt       # final checkpoint, unchanged from before
  checkpoints/           # AGeDi's own best_model.ckpt / last_model.ckpt
  iter_0000/
    samples.traj         # this iteration's newly evaluated structures
    buffer.traj          # the replay buffer after this iteration
    model.ckpt           # written every `checkpoint_every` iterations (default 3)
    summary.txt          # plain-text twin of the console's end-of-iteration panel
  iter_0001/ ...

checkpoint_every (constructor arg, default 3) keeps a checkpoint on a stride rather than only the most recent few, so you can reload the model at any earlier temperature for transferability checks — metrics.jsonl records each iteration's temperature and a "checkpoint": true/false flag, so a kept checkpoint's temperature never needs to be decoded from its filename. Pass checkpoint_every=0 or None to disable the per-iteration checkpoint entirely (AGeDi's own checkpoints/best_model.ckpt / last_model.ckpt and final_model.ckpt still cover "the best" and "the last" model).

Console output goes through a single Reporter (go_diff.Reporter); pass GODiff(..., reporter=Reporter(quiet=True)) to silence it. All output is flushed immediately, so it survives a SLURM job being killed mid-iteration.

Note: this per-iteration-directory layout replaced an earlier flat one (iteration_data_T*.traj, buffer_T*.traj, diffusion_model_T*.ckpt directly under the run directory). A script reading those paths from an older run needs updating to the layout above.


Running the tests

<!-- CLONE package -->
git clone https://github.com/nronne/go-diff.git 
cd go-diff

<!-- INSTALL with pip including test extras-->
pip install ".[test]"

<!-- RUN pytest -->
pytest

Citation

If you use GO-Diff please cite:

Ronne, Nikolaj, Tejs Vegge and Arghya Bhowmik. "GO-Diff: Data-free and amortized global structure optimization" arXiv:2510.13448. Preprint, arXiv, October 15, 2025. https://arxiv.org/abs/2510.13448

Ronne, Nikolaj, and Bjork Hammer. "Atomistic Generative Diffusion for Materials Modeling." arXiv:2507.18314. Preprint, arXiv, July 24, 2025. https://arxiv.org/abs/2507.18314

If studying surface-supported systems please also cite:

Ronne, Nikolaj, Alan Aspuru-Guzik, and Bjork Hammer. "Generative Diffusion Model for Surface Structure Discovery." Physical Review B 110, no. 23 (2024): 235427. https://doi.org/10.1103/PhysRevB.110.235427

Optionally, if using any AGOX functionality please cite:

Christiansen, Mads-Peter V., Nikolaj Ronne, and Bjork Hammer. "Atomistic Global Optimization X: A Python Package for Optimization of Atomistic Structures." The Journal of Chemical Physics 157, no. 5 (2022): 054701. https://doi.org/10.1063/5.0094165

Metadata

Release files for GO-Diff 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GO-Diff 1.3.0
File Size Uploaded Provenance Actions
go_diff-1.3.0.tar.gz 307.6 kB With provenance Details for go_diff-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for GO-Diff 1.3.0
File Interpreter ABI Platform Actions
go_diff-1.3.0-py3-none-any.whl Python 3 none any Details for go_diff-1.3.0-py3-none-any.whl

Total release size: 416.3 kB

Release files / go_diff-1.3.0.tar.gz

Download URL go_diff-1.3.0.tar.gz
Size 307.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f4a13ebcf7a094695a0464eabb467c25071efbe1837da0cdb8c1aa745c21f0c8
BLAKE2b-256 checksum
How to use checksums
e76652eeab379f0a2f006a1b1d077b38cbe4985c97851bfe52ad0d24beea15d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / go_diff-1.3.0-py3-none-any.whl

Download URL go_diff-1.3.0-py3-none-any.whl
Size 108.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ae1d30aa240f7daf4377ba7351a3a0c952cee136fae5bb99b38977cf36d3b1e
BLAKE2b-256 checksum
How to use checksums
c19955b8b4765ed7ccb8a52243062a71122e21c79e2ea3d95ae3af8a2cb29bf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for GO-Diff 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for go_diff-1.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page