atombatch
atombatch batches the energy and force evaluations of many independent ASE tasks into shared model calls. Relaxations, NEB bands, molecular dynamics, phonon displacements, and Monte Carlo trials run their ordinary, unmodified ASE code. The pending requests of all running tasks are evaluated together in one batched call per model, and each task receives exactly the result it would get from an independent run.
A machine-learned interatomic potential evaluated on one small structure leaves a GPU mostly idle, because each call pays a fixed cost for kernel launches, synchronization, and host bookkeeping. Batching amortizes that cost. For 64 FIRE relaxations of 40-atom SrTiO3 cells, with identical step counts to a sequential ASE loop:
| Model | GPU | Throughput gain at 64 cells per call | Relaxations |
|---|---|---|---|
| Symmetrix, MACE-OMat-0 medium (FP32) | NVIDIA RTX 4090 | 14.3x | 4.2x |
| Symmetrix, MACE-OMat-0 medium (FP64) | NVIDIA RTX 4090 | 5.4x | 3.7x |
| MACE-MP small via TorchSim (FP32) | NVIDIA RTX 4090 | 4.6x | 4.1x |
| Symmetrix, MACE-OMat-0 medium (FP32) | Apple M1 Max | 6.3x | 4.8x |
On a CPU the gain is small and depends on the batch size. See performance for the full measurements.
Installation
pip install atombatch
atombatch needs Python 3.10 or later, NumPy, and ASE. The model is installed separately.
Symmetrix
Symmetrix-XL evaluates MACE models natively on CPUs and GPUs. Install the package for your hardware together with matscipy, which Symmetrix needs for fast neighbor lists, and Numba, which atombatch uses to update cached neighbor lists:
| Hardware | Install |
|---|---|
| Linux, CPU | pip install "atombatch[symmetrix]" |
| Linux, NVIDIA GPU | pip install atombatch matscipy numba symmetrix-xl-cuda12-sm89 (choose sm80, sm86, sm89, sm90, or cuda13-sm120 for your GPU, or run symmetrix backend install after installing symmetrix-xl) |
| macOS, Apple GPU | pip install atombatch matscipy numba "symmetrix-xl @ git+https://github.com/bonan-group/symmetrix-xl.git@main#subdirectory=symmetrix" (builds the Metal backend from source in a few minutes; needs the Xcode command line tools), or the prebuilt wheels of the metal-preview-1 release |
Symmetrix evaluates a JSON export of a MACE model. For example, for MACE-MP-0b medium (the conversion needs mace-torch):
curl -L -o mace_agnesi_medium.model https://github.com/ACEsuit/mace-mp/releases/download/mace_mp_0b/mace_agnesi_medium.model
symmetrix_extract_mace --model mace_agnesi_medium.model --output mace-mp-0b-medium.json
On machines where an old CUDA toolkit is on the library path, the Symmetrix CUDA wheels can load the wrong libnvrtc.so or libcudart.so and fail with nvrtcGetCUBIN or invalid device ordinal. The installation guide gives the fix.
Other models
MACE, fairchem, SevenNet, ORB, MatterSim, NequIP, Nequix, and metatomic models are batched through TorchSim (Python 3.12 or later):
pip install "atombatch[torchsim]" mace-torch
Any other ASE calculator also works, evaluated one structure at a time. Further extras: atomate2 (Python 3.11 or later), phonons (phonopy and phono3py), test, and docs.
Quick start
Relax 64 rattled SrTiO3 supercells with Symmetrix. Each round, the forces of all 64 cells are evaluated in one call:
from ase import Atoms
from ase.optimize import FIRE
from symmetrix import Symmetrix
from atombatch import Scheduler, relax
def perovskite(seed):
atoms = Atoms(
"SrTiO3",
scaled_positions=[(0, 0, 0), (0.5, 0.5, 0.5), (0.5, 0.5, 0), (0.5, 0, 0.5), (0, 0.5, 0.5)],
cell=[3.95, 3.95, 3.95],
pbc=True,
).repeat(2)
atoms.rattle(0.05, seed=seed)
return atoms
calculator = Symmetrix("mace-mp-0b-medium.json", dtype="float32") # add metal=True on Apple silicon
scheduler = Scheduler(max_active=64)
scheduler.add_model("mace", calculator)
for seed in range(64):
scheduler.submit(relax(perovskite(seed), fmax=0.05, optimizer=FIRE), "mace")
results = scheduler.run() # one TaskResult per task, in submission order
print(sum(r.value["converged"] for r in results), "of", len(results), "converged")
print(scheduler.batch_log[0]) # ('mace', 64, 2560): 64 cells, 2560 atoms in the first call
Other tasks are submitted the same way and share the same batched calls. Here images is a list of NEB images, and atoms and alloy are structures of your own:
from ase import units
from ase.md.langevin import Langevin
from atombatch import equation_of_state, molecular_dynamics, neb, swap_monte_carlo
scheduler.submit(neb(images, neb_kwargs={"climb": True}, interpolate="idpp"), "mace")
scheduler.submit(molecular_dynamics(atoms, Langevin, 10_000, timestep=2 * units.fs, temperature_K=600, friction=0.02 / units.fs), "mace")
scheduler.submit(equation_of_state(atoms), "mace")
scheduler.submit(swap_monte_carlo(alloy, [300, 600, 1200], steps=1000), "mace")
More complete scripts, for cell relaxations of all orderings, several NEB bands, MD at several temperatures, phonons, and swap Monte Carlo, are in examples/ (described on the Examples page), with a SLURM job template.
With a TorchSim model, only the model changes:
import torch
from mace.calculators.foundations_models import mace_mp
from torch_sim.models.mace import MaceModel
model = MaceModel(mace_mp(model="small", return_raw_model=True, default_dtype="float32"), device=torch.device("cuda"), dtype=torch.float32, compute_stress=True)
scheduler.add_model("mace", model)
atomate2
atomate2 force-field and ASE makers run batched without changes, and return atomate2's own documents:
from atomate2.forcefields.jobs import ForceFieldRelaxMaker
from atombatch.integrations.atomate2 import atomate2_task
for structure in structures:
scheduler.submit(atomate2_task(ForceFieldRelaxMaker(relax_cell=True), structure), "mace")
documents = [result.value for result in scheduler.run()] # ForceFieldTaskDocuments
For 28 cell relaxations with Symmetrix on an M1 Max, the batched jobs ran 2.4 times faster than the same jobs one after another, with identical step counts. See the atomate2 page.
Scope
- Tasks: single points, relaxations (any ASE optimizer, cell filters included), NEB (regular and climbing image, several bands at once), and molecular dynamics (any ASE integrator), mixed in one run.
- Batched workflows: tasks that need many independent evaluations submit them together through
TaskContext.evaluate, so one workflow fills a batch on its own.displacement_forces: forces on all displaced supercells of a phonopy or phono3py object in one request.equation_of_state: all scaled cells in one request, fitted withase.eos.swap_monte_carlo: Metropolis swaps of site occupancies with replica exchange, the trial configurations of all temperatures evaluated in one request per step.airssandhot_airss: random structure searching, one task per sample (random structure, relaxation, and for hot-AIRSS a high-temperature anneal and a second relaxation), with structures from the AIRSSbuildcellprogram or a built-in generator.- Custom workflows call
context.evaluate(structures)from any task function.
- Scheduling: finished tasks are replaced from a queue (
max_active) so that batches stay full, and calls are split at a per-model atom budget (max_atoms). - Models: several models in one run, batched per model. Symmetrix-XL from 0.1.1 is batched natively, TorchSim models in one model call, and user functions with the signature
evaluate(structures, properties)connect any model with its own batched inference. - Results are the same as running each task independently, because each task receives exactly the energies and forces it requested. The tests check this against independent ASE runs and against each model's own ASE calculator.
Related work
- TorchSim and the NVIDIA ALCHEMI toolkit batch many systems by reimplementing optimizers and integrators as vectorized GPU code. atombatch keeps ASE's algorithms and batches only the model evaluation.
- The fairchem
InferenceBatcherbatches requests from concurrent ASE simulations through Ray Serve for fairchem models. atombatch aims at the same pattern without Ray and independently of the model package. - MatterSim's
BatchRelaxersteps ASE optimizers in lockstep for relaxations with one model. - i-PI batches force requests across replicas and systems within its own simulation engine.
Documentation
The documentation is at https://deng-group.github.io/atombatch/. It covers installation, examples, models, batched workflows, writing tasks, performance, and the API. To build it locally:
pip install -e ".[docs]"
sphinx-build -W docs docs/_build/html
Development
uv venv && source .venv/bin/activate
uv pip install -e ".[test]"
pytest
License
atombatch is distributed under the GNU General Public License, version 3 or later. See LICENSE.
Metadata
Release files for atombatch 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| atombatch-0.2.1.tar.gz | 97.9 kB | With provenance | Details for atombatch-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| atombatch-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for atombatch-0.2.1-py3-none-any.whl |
Total release size: 145.4 kB
Release files / atombatch-0.2.1.tar.gz
| Download URL | atombatch-0.2.1.tar.gz |
|---|---|
| Size | 97.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aad2f2ad7e27f36154796093e1a04f00d9fec7980c1ab67f4d4e9c44baffa153
|
|
BLAKE2b-256 checksum How to use checksums |
d1c9606a8246a7ff061724970177b96492482bca3bd87b837624f3d5aff4f692
|
| 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 13, 2026.
Transparency logRelease files / atombatch-0.2.1-py3-none-any.whl
| Download URL | atombatch-0.2.1-py3-none-any.whl |
|---|---|
| Size | 47.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4a58bcc4137a7e728920d18f27a3cf2016b1f9e3e6f6acead7612ce7a1e22d5
|
|
BLAKE2b-256 checksum How to use checksums |
6e5b686c6e8a8aef2437ca4850f9943fbca8be6e0723d39cde1629d4af5383dc
|
| 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 13, 2026.
Transparency logSecurity for atombatch 0.2.1
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.
Attestation for atombatch-0.2.1.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 13, 2026.
Transparency logA 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.