ASE - Remote Procedure Call
Project description
ASE - Remote Procedure Call
A lightweight RPC framework for serving ASE (Atomic Simulation Environment) calculators over ZeroMQ.
This package is primarily designed to run MLIP calculators in dedicated python environments to handle dependency conflicts or for multi-GPU distribution.
Quick Start
- Start the broker:
aserpc broker
- Check available calculators:
aserpc list
# or
aserpc list --registry tmp/registry.py:CALCULATORS
A registry file (or module via pck.registry:CALCULATORS) example:
# tmp/registry.py
from ase.calculators.lj import LennardJones
# Registry: name -> calculator factory
CALCULATORS = {
"LJ": LennardJones,
}
- Start a worker:
aserpc worker LJ # optional --registry tmp/registry.py:CALCULATORS
- Use the remote calculator:
from aserpc import RemoteCalculator
from ase.build import molecule
water = molecule("H2O")
water.calc = RemoteCalculator("LJ")
energy = water.get_potential_energy()
Calculator Discovery
Workers discover calculators through Python entry point providers. This allows packages to register calculators that aserpc can automatically find.
Provider Functions
Register a provider function that returns calculator metadata:
# pyproject.toml
[project.entry-points."aserpc.calculators"]
mypackage = "mypackage.aserpc:get_calculators"
# mypackage/aserpc.py
import importlib.util
def get_calculators() -> dict[str, dict]:
"""Return metadata for available calculators.
Each entry is: {"factory": "module:class", "args": [...], "kwargs": {...}}
Use importlib.util.find_spec() to check availability without importing.
"""
calcs = {}
# Simple calculators (always available with ASE)
calcs["LJ"] = {"factory": "ase.calculators.lj:LennardJones"}
calcs["EMT"] = {"factory": "ase.calculators.emt:EMT"}
# Check if mace is installed (without importing torch!)
if importlib.util.find_spec("mace") is not None:
calcs["mace_mp"] = {
"factory": "mace.calculators:mace_mp",
"kwargs": {"model": "medium"},
}
# Check if chgnet is installed
if importlib.util.find_spec("chgnet") is not None:
calcs["chgnet"] = {"factory": "chgnet.model:CHGNetCalculator"}
return calcs
After installing the package, the new calculators should show up on aserpc list and can be started as workers:
aserpc worker LJ
aserpc worker mace_mp
Using a Registry File
Alternatively, specify a registry file with calculator factories:
# registry.py
from ase.calculators.lj import LennardJones
CALCULATORS = {
"LJ": LennardJones,
}
aserpc worker LJ --registry registry.py:CALCULATORS
Listing Available Calculators
List all discoverable calculators:
# From entry points
aserpc list
# From a registry file
aserpc list --registry registry.py:CALCULATORS
# From a running broker
aserpc list --broker ipc:///tmp/aserpc/frontend.ipc
Architecture
flowchart TD
Client <--> Broker <--> Worker1[Worker 1]
Broker <--> Worker2[Worker 2]
Broker <--> WorkerN[Worker N]
- Broker: Routes requests to available workers, handles load balancing
- Worker: Runs calculator computations, sends heartbeats
- Client:
RemoteCalculatoracts as a drop-in ASE calculator
Configuration
Configuration can be set via environment variables or pyproject.toml. Environment variables take precedence.
Environment Variables
| Variable | Default | Description |
|---|---|---|
ASERPC_IPC_DIR |
.aserpc (cwd) |
Directory for IPC sockets |
ASERPC_IPC_FRONTEND |
ipc://{IPC_DIR}/frontend.ipc |
Client socket address |
ASERPC_IPC_BACKEND |
ipc://{IPC_DIR}/backend.ipc |
Worker socket address |
ASERPC_WORKER_TIMEOUT |
30.0 | Seconds before broker considers worker dead |
ASERPC_HEARTBEAT_INTERVAL |
5.0 | Seconds between heartbeats |
ASERPC_IDLE_TIMEOUT |
300.0 | Seconds before idle worker shuts down |
ASERPC_REQUEST_QUEUE_TIMEOUT |
60.0 | Seconds before queued request expires |
ASERPC_CLIENT_TIMEOUT_MS |
60000 | Client timeout in milliseconds |
pyproject.toml
[tool.aserpc]
ipc_dir = "/tmp/aserpc"
worker_timeout = 30.0
heartbeat_interval = 5.0
idle_timeout = 300.0
request_queue_timeout = 60.0
client_timeout_ms = 60000
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file aserpc-0.1.1.tar.gz.
File metadata
- Download URL: aserpc-0.1.1.tar.gz
- Upload date:
- Size: 107.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e996bb9742992084a10f943e246259e1b6bda54a916fba82c1264b1c6ce7db56
|
|
| MD5 |
6b047a7624feb29c64860587c9ce4675
|
|
| BLAKE2b-256 |
ed831b7bfba149bee01da57cf2187eb1a1d9d8ee734ecab5b7191c0b3b822f47
|
Provenance
The following attestation bundles were made for aserpc-0.1.1.tar.gz:
Publisher:
publish.yaml on zincware/aserpc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aserpc-0.1.1.tar.gz -
Subject digest:
e996bb9742992084a10f943e246259e1b6bda54a916fba82c1264b1c6ce7db56 - Sigstore transparency entry: 740721604
- Sigstore integration time:
-
Permalink:
zincware/aserpc@d147faefa07888942f595e2ad87d760257b5ae56 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/zincware
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@d147faefa07888942f595e2ad87d760257b5ae56 -
Trigger Event:
release
-
Statement type: