Skip to main content

PM++: Multi-GPU Particle-Mesh Cosmology

PM++ logo

Documentation Status Package build PyPI version Python versions License

What is PM++?

PM++ is a JAX-based, differentiable particle-mesh simulator for large-scale structure cosmology. It distributes a single simulation across multiple GPUs and covers the path from Gaussian initial modes through Lagrangian perturbation theory and N-body evolution to density fields and scientific summary statistics.

PM++ is designed for simulations that need both scale and derivatives. It can differentiate observables with respect to initial modes, particle states, and cosmological parameters while keeping the distributed forward model and its adjoint in one JAX program.

The implementation builds on ideas from PMWD. The maintained validation suite compares PM++ directly with PMWD for forward evolution and gradients. For the configurations covered by those tests, the two agree down to machine precision.

Capabilities

  • End-to-end cosmological evolution: transfer and growth calculations, Gaussian and nested initial fields, linear modes, LPT, PM N-body evolution, density assignment, observers, and power-spectrum analysis.
  • Automatic differentiation: forward and reverse derivatives through the simulation, including a custom N-body adjoint for memory-efficient reverse sweeps.
  • Distributed execution: sharded particle ownership, mesh-halo exchange, distributed FFTs, and particle migration across a multi-GPU device mesh.
  • Accelerated particle-mesh operations: paired Pallas CIC kernels and an optional compiled CUDA routing backend, with portable JAX fallbacks.
  • Scientific configuration: float32 and float64 execution, configurable particle and force meshes, integration schedules, correction models, and differentiable cosmological parameters.
  • Validation and analysis: PMWD forward and gradient comparisons, mass and ownership checks, finite-difference tests, power spectra, projections, and CAMELS and QUIJOTE data adapters.

What PM++ enables

By combining multi-GPU execution with differentiability, PM++ makes it possible to simulate larger cosmological volumes or use finer mass resolution without giving up parameter sensitivities. This supports field-level inference, initial-condition reconstruction, gradient-based calibration, and sensitivity studies of how cosmological parameters shape large-scale structure.

Installation

PM++ requires Python 3.10 or newer and supports jax>=0.9.1,<0.11. Install the JAX build for the accelerator and driver before installing PM++. For a CUDA 12 environment:

python -m venv ~/.venvs/pmpp
source ~/.venvs/pmpp/bin/activate
python -m pip install --upgrade pip
python -m pip install "jax[cuda12]>=0.9.1,<0.11"
python -m pip install pmpp

Choose the PM++ extra that matches the environment:

Use Installation
Run simulations python -m pip install pmpp
Run the repository tests python -m pip install "pmpp[dev]"
Build the documentation python -m pip install "pmpp[docs]"
Develop, test, and build documentation python -m pip install "pmpp[dev,docs]"

When a compatible CUDA development toolkit and CMake are available, build the optional accelerated routing extension in the same environment:

pmpp-build-cuda-routing

The compiled router is optional. PM++ uses its portable JAX implementation when the extension or a compatible nvcc is unavailable.

See the installation guide for CUDA 13, HPC cluster, Compute Canada, and offline-wheel instructions.

Documentation

The complete documentation is available at pmpp-docs.readthedocs.io. It contains the getting-started workflow, scientific configuration guide, multi-GPU setup, differentiation guidance, solver internals, and API reference.

Useful entry points:

Repository layout

PMpp/
|-- src/pmpp/
|   |-- core/                  # Configuration and shared utilities
|   |-- cosmology/             # Cosmological models, transfer, and growth
|   |-- initial_conditions/    # White noise, linear modes, and LPT
|   |-- nbody/                 # Particles, gravity, integration, and observers
|   |-- cic/                   # Scatter, gather, and Pallas CIC kernels
|   |-- distributed/           # Device meshes, FFTs, halos, and routing
|   |-- numerics/              # Local FFT and ODE primitives
|   |-- corrections/           # Optional force and phase-space corrections
|   |-- analysis/              # Power spectra and plotting
|   `-- extras/                # CAMELS and QUIJOTE adapters
|-- cuda/                      # Optional native CUDA routing sources
|-- tests/
|   `-- pmwd/                  # Test-only PMWD reference implementation
|-- docs/source/
|   |-- getting_started/       # Installation and first-run guidance
|   |-- user_guide/            # Scientific and runtime configuration
|   |-- internals/             # Algorithms and distributed design
|   |-- api/                   # Public API reference
|   `-- notebooks/             # Pre-rendered scientific workflows
|-- pyproject.toml             # Package metadata, dependencies, and tooling
`-- requirements.txt           # Read the Docs environment requirements

The importable implementation lives entirely under src/pmpp. The copy of PMWD under tests/pmwd is retained only as a numerical reference for validation.

Citation

See the citation guide for PM++, its discrete-adjoint foundation, and PMWD attribution.

License

PM++ is distributed under the BSD 3-Clause license. See LICENSE. PM++ retains the original PMWD notice in THIRD_PARTY_NOTICES.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pmpp-1.0.0.tar.gz (182.0 kB view details)

Uploaded Source

Built Distribution

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

pmpp-1.0.0-py3-none-any.whl (212.4 kB view details)

Uploaded Python 3

File details

Details for the file pmpp-1.0.0.tar.gz.

File metadata

  • Download URL: pmpp-1.0.0.tar.gz
  • Upload date:
  • Size: 182.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pmpp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 813c3fb165c29d38aa68298ce9c4074ef5745741df84ca1b24b0a6a78ded7ccd
MD5 9ed1421194e25f988c5b0e4694118e46
BLAKE2b-256 541068c56a1c237a3bb88e7c6052a80caa1caaf2cd6b7a7f9807dffbcc9ef5d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pmpp-1.0.0.tar.gz:

Publisher: publish-to-pypi.yml on rouzib/PMpp

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

File details

Details for the file pmpp-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pmpp-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 212.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pmpp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0d97fa3ff6dc321a9e1dd4a7cd44afa705e97737aa017ac21280c922b4f88e7
MD5 5cd907270cab33679cd97d81ae8a0965
BLAKE2b-256 e7b5fdb91106e115a34cd796460c205df95802459ad88ce9a02d4108c3e9d2b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pmpp-1.0.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on rouzib/PMpp

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

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

0.2.2

2 files

0.2.1

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

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