Skip to main content

mpiparticles

Tests Static analysis Docs codecov PyPI Python

A distributed marker (particle) container for MPI codes: per-rank storage in component-major arrays on NumPy or CuPy (through cunumpy), globally unique int64 ids, and migrate, which sends the markers that left a rank to the rank that owns them. Without an MPI launcher it runs on one rank and makes no MPI call.

import cunumpy as xp
import maybempi

from mpiparticles import (
    BoxDecomposition,
    IdAllocator,
    ParticleStore,
    global_count,
    migrate,
)

comm = maybempi.get_mpi().COMM_WORLD
decomposition = BoxDecomposition(comm, [0.0, 0.0], [1.0, 1.0], proc_sizes=[1, 1])
store = ParticleStore(ndim=2, nvel=3, id_allocator=IdAllocator.from_comm(comm))

store.add(xp.asarray([[0.2, 0.7], [0.4, 0.9]]), xp.zeros((3, 2)))
store.positions[:, : store.length] += 0.1  # push
sent, received = migrate(store, decomposition)  # collective: call it on every rank
store.compact_if_needed()
print(global_count(store, comm))
mpiexec -n 4 python example.py   # with proc_sizes=[2, 2]; or just: python example.py
  • ParticleStore holds positions (ndim, n), velocities (nvel, n), weights, alive flags and ids, with growth by doubling, dead markers until compact, sort_by_key, snapshot/restore, and a transposed non-copy view for plasmacoll’s MarkerSet.
  • IdAllocator hands out int64 ids with a rank stride, independent of the decomposition.
  • Decomposition is a protocol (comm, rank, size, owners, owned_mask); BoxDecomposition is a small reference implementation.
  • migrate sends only the leavers, ids as int64 (exact above 2^53), and appends the arrivals. keep_owned, global_count and gather_columns are the companions.

Documentation: https://max-models.github.io/mpiparticles/

Install

With uv:

make install    # uv sync --extra dev, plus the pre-commit hooks

Or create and activate a Python environment (3.10 or newer) and install with pip:

pip install -e .          # serial
pip install -e ".[mpi]"   # with mpi4py, for mpiexec runs

The test, docs and dev extras install the test runner, the documentation tooling and the linters:

pip install -e ".[dev]"

Development

Formatting and linting use ruff, type checking pyright, run by pre-commit and in CI:

make lint     # ruff check, ruff format --check, pyright
make test     # pytest with coverage; includes mpiexec -n 2 and -n 4 jobs when mpiexec is found

Commit messages follow Conventional Commits; see CONTRIBUTING.md.

Build docs

The documentation in docs/ is an Astro + Starlight site: hand-written pages, the notebooks in tutorials/ executed and published as pages, complete Python scripts in examples/ published with their plots, and the API reference generated from the docstrings with starlight-pydocs. It needs Node 22 or newer.

make docs-install     # npm packages and the Python docs extra
make docs-notebooks   # execute tutorials/*.ipynb and convert them to pages
make docs-examples    # run examples/*.py and publish their plots
make docs-dev         # live preview at http://localhost:4321/mpiparticles/
make docs-build       # the static site in docs/dist

Build the README

README.md is rendered from README.qmd with Quarto:

make readme

Releases

Before merging a release to main, update the version in pyproject.toml, src/mpiparticles/__init__.py and CITATION.cff (including its release date), and add the release notes to CHANGELOG.md. The push to main creates a GitHub release with a vX.Y.Z tag and publishes the package to PyPI with trusted publishing (OIDC). The one-time PyPI and GitHub configuration is described in the publishing tutorial.

Metadata

Release files for mpiparticles 0.1.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 mpiparticles 0.1.0
File Size Uploaded Provenance Actions
mpiparticles-0.1.0.tar.gz 25.6 kB With provenance Details for mpiparticles-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mpiparticles 0.1.0
File Interpreter ABI Platform Actions
mpiparticles-0.1.0-py3-none-any.whl Python 3 none any Details for mpiparticles-0.1.0-py3-none-any.whl

Total release size: 53.8 kB

Release files / mpiparticles-0.1.0.tar.gz

Download URL mpiparticles-0.1.0.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
807eff536f8386758e60fafc853e261aa7d9ea741f62ab76b3153828054c594c
BLAKE2b-256 checksum
How to use checksums
227d93b7f232dfb4040d4c06793f0c8ca5a7ff209f9f2c97d7aa207258175532
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 Oct 20, 2026.

Transparency log

Release files / mpiparticles-0.1.0-py3-none-any.whl

Download URL mpiparticles-0.1.0-py3-none-any.whl
Size 28.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
106b692f0519eb1cc77fdcf3385c016c86cc9bd4d6198dc4a4991e24341ccaa6
BLAKE2b-256 checksum
How to use checksums
6633a6e5d8133023573476d1c1a5c1a610b576a6139d504e3e87005b0454b437
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 Oct 20, 2026.

Transparency log

Security for mpiparticles 0.1.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mpiparticles-0.1.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 Oct 20, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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