MLIP calculators with isolated Python environments
Project description
Rootstock
Run MLIP (Machine Learning Interatomic Potential) calculators in isolated pre-built Python environments, communicating via the i-PI protocol over Unix sockets.
Quick Start
from ase.build import bulk
from rootstock import RootstockCalculator
atoms = bulk("Cu", "fcc", a=3.6) * (5, 5, 5)
# Using a known cluster
with RootstockCalculator(
cluster="modal", # or "della"
model="mace-medium", # or "chgnet", "mace-small", etc.
device="cuda",
) as calc:
atoms.calc = calc
print(atoms.get_potential_energy())
print(atoms.get_forces())
# Or with an explicit root path
with RootstockCalculator(
root="/scratch/gpfs/SHARED/rootstock",
model="mace-medium",
device="cuda",
) as calc:
atoms.calc = calc
print(atoms.get_potential_energy())
Note: Environments must be pre-built before use. See Administrator Setup.
Installation
pip install rootstock
# or
uv pip install rootstock
Model String Format
The model parameter encodes both the environment and model-specific argument:
model= |
Environment | Model Arg |
|---|---|---|
"mace-medium" |
mace_env | "medium" |
"mace-small" |
mace_env | "small" |
"mace-large" |
mace_env | "large" |
"chgnet" |
chgnet_env | "" (default) |
"mace-/path/to/weights.pt" |
mace_env | "/path/to/weights.pt" |
Known Clusters
| Cluster | Root Path |
|---|---|
modal |
/vol/rootstock |
della |
/scratch/gpfs/SHARED/rootstock |
For other clusters, use root="/path/to/rootstock" directly.
Administrator Setup
Environments must be pre-built before users can run calculations.
1. Create Directory Structure
mkdir -p /scratch/gpfs/SHARED/rootstock/{environments,envs,cache}
2. Create Environment Source Files
# mace_env.py
cat > /scratch/gpfs/SHARED/rootstock/environments/mace_env.py << 'EOF'
# /// script
# requires-python = ">=3.10"
# dependencies = ["mace-torch>=0.3.0", "ase>=3.22", "torch>=2.0"]
# ///
"""MACE environment for Rootstock."""
def setup(model: str, device: str = "cuda"):
from mace.calculators import mace_mp
return mace_mp(model=model, device=device, default_dtype="float32")
EOF
3. Build Environments
# Build MACE environment with model pre-download
rootstock build mace_env --root /scratch/gpfs/SHARED/rootstock --models small,medium,large
# Build CHGNet environment
rootstock build chgnet_env --root /scratch/gpfs/SHARED/rootstock
# Verify
rootstock status --root /scratch/gpfs/SHARED/rootstock
Architecture
Main Process Worker Process (subprocess)
+-------------------------+ +-----------------------------+
| RootstockCalculator | | Pre-built venv Python |
| (ASE-compatible) | | (mace_env/bin/python) |
| | | |
| server.py (i-PI server) |<-------->| worker.py (i-PI client) |
| - sends positions | Unix | - receives positions |
| - receives forces | socket | - calculates forces |
+-------------------------+ +-----------------------------+
The worker process uses a pre-built virtual environment, providing:
- Fast startup: No dependency installation at runtime
- Filesystem compatibility: Works on NFS, Lustre, GPFS, Modal volumes
- Reproducibility: Same environment every time
Directory Structure
{root}/
├── environments/ # Environment SOURCE files (*.py with PEP 723)
│ ├── mace_env.py
│ └── chgnet_env.py
├── envs/ # Pre-built virtual environments
│ ├── mace_env/
│ │ ├── bin/python
│ │ ├── lib/python3.11/site-packages/
│ │ └── env_source.py # Copy of environment source
│ └── chgnet_env/
└── cache/ # XDG_CACHE_HOME for model weights
├── mace/ # MACE models
└── huggingface/ # HuggingFace models
CLI Commands
# Build a pre-built environment
rootstock build <env_name> --root <path> [--models m1,m2] [--force]
# Show status
rootstock status --root <path>
# Register an environment source file
rootstock register <env_file> --root <path>
# List environments
rootstock list --root <path>
Running on Modal
# Initialize volume and build environments (takes ~10-15 min)
modal run modal_app.py::init_rootstock_volume
# Test pre-built environments
modal run modal_app.py::test_prebuilt
# Show status
modal run modal_app.py::inspect_status
# Run benchmarks
modal run modal_app.py::benchmark_v4
Performance
IPC overhead is <5% for systems with 1000+ atoms compared to direct in-process execution.
| System Size | Atoms | Typical Overhead |
|---|---|---|
| Small | 64 | ~10-15% |
| Medium | 256 | ~5-8% |
| Large | 1000 | <5% |
Local Development
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]"
ruff check rootstock/
ruff format rootstock/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rootstock-0.5.0.tar.gz.
File metadata
- Download URL: rootstock-0.5.0.tar.gz
- Upload date:
- Size: 237.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75d6415ca57e06ea52c81047656fe539de64558e73439fc33e3a4552b2f0ddf9
|
|
| MD5 |
08ef4fa1866a0dd11473d44c370250e0
|
|
| BLAKE2b-256 |
a2ac9af48c755aa8bb977148765bf94ebf243472ac7280d313b1a487941a72a6
|
Provenance
The following attestation bundles were made for rootstock-0.5.0.tar.gz:
Publisher:
publish.yml on Garden-AI/rootstock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rootstock-0.5.0.tar.gz -
Subject digest:
75d6415ca57e06ea52c81047656fe539de64558e73439fc33e3a4552b2f0ddf9 - Sigstore transparency entry: 913842469
- Sigstore integration time:
-
Permalink:
Garden-AI/rootstock@08e9318d8ca6d36d87c79ff34f9723be362a19e3 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Garden-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08e9318d8ca6d36d87c79ff34f9723be362a19e3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rootstock-0.5.0-py3-none-any.whl.
File metadata
- Download URL: rootstock-0.5.0-py3-none-any.whl
- Upload date:
- Size: 24.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a12c1bbe52853b83cea1241412b51d029c8ec239e81d112c29fdb82b94d689a
|
|
| MD5 |
cd3d41ceb5aef28e195d055840b1fbd3
|
|
| BLAKE2b-256 |
fca7f88d83a814ba1f705f1f3f42baa65569ad106febfcb25e1b374d85580983
|
Provenance
The following attestation bundles were made for rootstock-0.5.0-py3-none-any.whl:
Publisher:
publish.yml on Garden-AI/rootstock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rootstock-0.5.0-py3-none-any.whl -
Subject digest:
4a12c1bbe52853b83cea1241412b51d029c8ec239e81d112c29fdb82b94d689a - Sigstore transparency entry: 913842517
- Sigstore integration time:
-
Permalink:
Garden-AI/rootstock@08e9318d8ca6d36d87c79ff34f9723be362a19e3 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Garden-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@08e9318d8ca6d36d87c79ff34f9723be362a19e3 -
Trigger Event:
release
-
Statement type: