Skip to main content

JAX/Equinox port of espaloma-charge partial charge inference (bundled v0.0.8 weights)

Project description

expaloma

Native JAX/Equinox partial-charge inference, ported from espaloma_charge so downstream simulators can avoid PyTorch + DGL at runtime.

Install

uv sync
# optional dev (pytest)
uv sync --extra dev

Typer CLI

The package exposes a typer application (src/expaloma/cli.py) registered as the expaloma console script in pyproject.toml ([project.scripts]). Commands:

  • expaloma infer SMILES — partial charges (bundled .eqx by default).
  • expaloma convert-weights MODEL.pt OUT.eqx — offline conversion (needs a git checkout with scripts/ and submodules; not available from a PyPI-only install).
  • expaloma --version — print the installed package version.

PyPI and uv tool

After you publish to PyPI:

pip install expaloma
expaloma infer "CCO"

Install as a uv tool (isolated env with the expaloma console script on PATH):

uv tool install expaloma
expaloma --version
# one-shot without installing:
uvx --from expaloma expaloma infer "CCO"

CI and releases

Workflow Purpose
.github/workflows/ci.yml Lint/tests on push/PR to main
.github/workflows/publish.yml Build with uv build and upload to PyPI on GitHub Release (OIDC trusted publishing)

Configure trusted publishing on PyPI for this repo/workflow, and add a GitHub Environment named pypi if you use environment protection rules. Tag releases (e.g. v0.1.0) and publish a GitHub Release to trigger the workflow (or run it manually via workflow_dispatch).

Branch protection (gh CLI)

GitHub’s rulesets API is the supported approach. After CI is green, you can require the test check on main via the web UI (Settings → Rules → Rulesets), or use the API. Examples:

# Repo visibility / basics (requires gh auth)
gh repo view maraxen/expaloma

# Many teams configure rulesets in the UI so required checks match exactly (e.g. "test" from ci.yml).
# To require pull requests before merging, use Settings → Rulesets → Add rule → Target: main.

For automation-heavy setups, create a ruleset with the REST API (gh api repos/{owner}/{repo}/rulesets) using JSON from Settings → Rulesets → View JSON, or start from GitHub’s ruleset documentation. The gh CLI does not yet offer a single stable gh ruleset create for all options; the UI or API remains the reliable path.

Inference (bundled weights)

The public v0.0.8 checkpoint is shipped as Equinox bytes at src/expaloma/weights/espaloma_v0_0_8.eqx (also included in wheels). Provenance and SHA256 hashes are in src/expaloma/weights/README.md.

uv run expaloma infer "CC(=O)Oc1ccccc1C(=O)O"
# or pass a custom checkpoint:
uv run expaloma infer "CCO" --weights path/to/custom.eqx

From Python:

from expaloma.infer import charges_for_rdkit_mol, charges_for_smiles
from rdkit import Chem

q = charges_for_smiles("CCO")  # uses bundled .eqx by default
q = charges_for_rdkit_mol(Chem.MolFromSmiles("CCO"))  # same atom order as RDKit

Convert PyTorch model.pt to .eqx (offline)

Conversion uses PyTorch only in the script environment (not a runtime dependency of expaloma):

uv pip install torch --index-url https://download.pytorch.org/whl/cpu
uv run python scripts/convert_weights.py path/to/model.pt out.eqx

Tests

uv sync --extra dev
uv pip install torch --index-url https://download.pytorch.org/whl/cpu
curl -fsSL -o /tmp/espaloma_model.pt \
  "https://github.com/choderalab/espaloma_charge/releases/download/v0.0.8/model.pt"
uv run pytest tests/ -v

CI downloads the same model.pt for JAX vs PyTorch reference parity checks; golden vectors and bundled .eqx cover regression without relying on that download for basic JAX tests.

Benchmark (local)

scripts/benchmark_infer.py runs warmup + timed repeats with jax.block_until_ready. Timing is environment-dependent and not part of default CI.

uv run python scripts/benchmark_infer.py --repeats 50

Attribution

The original espaloma_charge project is MIT-licensed (see references/espaloma-charge/LICENSE). This port bundles weights derived from the published v0.0.8 release; retain upstream notices in distributions.

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

expaloma-0.1.0.tar.gz (567.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

expaloma-0.1.0-py3-none-any.whl (571.4 kB view details)

Uploaded Python 3

File details

Details for the file expaloma-0.1.0.tar.gz.

File metadata

  • Download URL: expaloma-0.1.0.tar.gz
  • Upload date:
  • Size: 567.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for expaloma-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c291960a8b6d9ef566f44bfd70e71fc6b2d80e1355898167672cc2968e8a8d1
MD5 152fcb43fa9a76abe8da93c99a5aeca5
BLAKE2b-256 b95ba40dd31a87fcd8667924b24448e8b0273b9594c23d1123db961908b90742

See more details on using hashes here.

Provenance

The following attestation bundles were made for expaloma-0.1.0.tar.gz:

Publisher: publish.yml on maraxen/expaloma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file expaloma-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: expaloma-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 571.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for expaloma-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 226a0d8d30dff170a51609d063ce99abde241505f1350da03f7e5ae606526d80
MD5 462bb48c5097e9e3c5f1c92515454930
BLAKE2b-256 e38aea777f427ad466bc233ab45d958274e9feb2053c4a770907d26e5602b938

See more details on using hashes here.

Provenance

The following attestation bundles were made for expaloma-0.1.0-py3-none-any.whl:

Publisher: publish.yml on maraxen/expaloma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page