Skip to main content

NuMPI

Tests Flake8 Docs

Numerical tools for MPI-parallelized Python codes. Code written with NuMPI runs unchanged in parallel under mpirun and serially without any MPI installation.

  • MPI is optional: NuMPI.MPI is mpi4py's MPI module if mpi4py is installed, and otherwise a stub with the same interface for a single process.
  • Reductions (sum, max, min, mean, dot, any, all) over distributed arrays, for mpi4py communicators and for muGrid's Communicator.
  • Parallel I/O of domain-decomposed arrays in numpy's .npy format with MPI I/O.
  • FFT engines with the interface of muGrid's FFTEngine: a serial engine based on numpy.fft, and muGrid's MPI-parallel engine for domain-decomposed grids.
  • Parallel optimizers: L-BFGS (unconstrained, bound-constrained, and with a linear equality), bound-constrained trust-region Newton-CG and constrained conjugate gradients, all on distributed arrays.
  • Testing utilities: pytest fixtures for communicators of several sizes and assertions that agree across processes.

Installation

pip install NuMPI

NuMPI requires Python 3.10 or later. The mpi extra installs mpi4py, the fft extra muGrid for parallel FFTs:

pip install NuMPI[mpi,fft]

Note: mpi4py and muGrid must be compiled against the MPI library of your system. Build them from source:

CC=mpicc CXX=mpicxx pip install --no-binary mpi4py --no-binary muGrid NuMPI[mpi,fft]

Quick start

import numpy as np
from NuMPI import MPI
from NuMPI.IO import save_npy
from NuMPI.Tools import Reduction

comm = MPI.COMM_WORLD
pnp = Reduction(comm)

# Each process holds 10 rows of a global array with 10 * comm.size rows
local = np.full((10, 4), comm.rank, dtype=float)
print(pnp.sum(local))  # same value on every process

save_npy("data.npy", local, subdomain_locations=(10 * comm.rank, 0),
         nb_grid_pts=(10 * comm.size, 4), comm=comm)

Run it serially with python example.py, or in parallel with mpirun -n 4 python example.py.

Development

git clone https://github.com/muSpectre/NuMPI.git
cd NuMPI
pip install -e .[test]
python -m pytest                                  # serially, with the MPI stub
mpirun --oversubscribe -n 4 python -m pytest      # in parallel, needs mpi4py

Documentation

Full documentation (installation, communicators and reductions, parallel I/O, FFT engines, optimizers and their MPI conventions, testing utilities) is at https://muspectre.github.io/NuMPI/ and in the docs/ folder.

License

MIT — see LICENSE.md.

Funding

Development of this project is funded by the European Research Council within Starting Grant 757343 and by the Deutsche Forschungsgemeinschaft within project EXC 2193.

Metadata

Release files for NuMPI 0.17.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for NuMPI 0.17.1
File Size Uploaded Provenance Actions
numpi-0.17.1.tar.gz 145.2 kB Without provenance Details for numpi-0.17.1.tar.gz

Built distribution (wheel)

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

Total release size: 222.7 kB

Release files / numpi-0.17.1.tar.gz

Download URL numpi-0.17.1.tar.gz
Size 145.2 kB
Tags Source
SHA-256 checksum
How to use checksums
239ad203ea7fd055eb18613e4abb04d8e2a470a25478f2b3acfd2517be48eac4
BLAKE2b-256 checksum
How to use checksums
ab0acbd6da4eeb664de3bed84e3a8cb84a22dec3987b57b7d65b7db3359e86d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / numpi-0.17.1-py3-none-any.whl

Download URL numpi-0.17.1-py3-none-any.whl
Size 77.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30c96ddc3d13d658decb877bac899f516c5c059152dde7b524b9d0ca8cfe4582
BLAKE2b-256 checksum
How to use checksums
aeb5515d61b2ec9844ec76651140e4607d026333349e3a16d12751847a37fe36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for NuMPI 0.17.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.17.1 This release

2 release files No 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