numba-mpi

Numba @jit compatible wrappers for MPI C API tested on Linux, macOS and Windows

https://github.com/numba-mpi/numba-mpi

Science Score: 64.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: sciencedirect.com, zenodo.org
  • Committers with academic emails
    3 of 7 committers (42.9%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.7%) to scientific vocabulary

Keywords

conda-forge hpc mpi mpi4py numba pypi-package python

Keywords from Contributors

atmospheric-modelling research advection advection-diffusion numerical-integration pde-solver
Last synced: 6 months ago · JSON representation ·

Repository

Numba @jit compatible wrappers for MPI C API tested on Linux, macOS and Windows

Basic Info
Statistics
  • Stars: 43
  • Watchers: 3
  • Forks: 10
  • Open Issues: 27
  • Releases: 52
Topics
conda-forge hpc mpi mpi4py numba pypi-package python
Created about 5 years ago · Last pushed 6 months ago
Metadata Files
Readme License Code of conduct Citation Zenodo

README.md

numba-mpi logo numba-mpi

Python 3 LLVM Linux OK macOS OK Windows OK Github Actions Status Maintenance License: GPL v3 PyPI version Anaconda-Server Badge AUR package DOI

Overview

numba-mpi provides Python wrappers to the C MPI API callable from within Numba JIT-compiled code (@jit mode). For an outline of the project, rationale, architecture, and features, refer to: numba-mpi paper in SoftwareX (open access) (please cite if numba-mpi is used in your research).

Support is provided for a subset of MPI routines covering: size/rank, send/recv, allreduce, reduce, bcast, scatter/gather & allgather, barrier, wtime and basic asynchronous communication with isend/irecv (only for contiguous arrays); for request handling including wait/waitall/waitany and test/testall/testany.

The API uses NumPy and supports both numeric and character datatypes (e.g., broadcast). Auto-generated docstring-based API docs are published on the web: https://numba-mpi.github.io/numba-mpi

Packages can be obtained from PyPI, Conda Forge, Arch Linux or by invoking pip install git+https://github.com/numba-mpi/numba-mpi.git.

numba-mpi is a pure-Python package. The codebase includes a test suite used through the GitHub Actions workflows (thanks to mpi4py's setup-mpi!) for automated testing on: Linux (MPICH, OpenMPI & Intel MPI), macOS (MPICH & OpenMPI) and Windows (MS MPI). Note, that some of those combinations may not be fully supported yet - see Known Issues for more information.

Features that are not implemented yet include (help welcome!): - support for non-default communicators - support for MPI_IN_PLACE in [all]gather/scatter and allreduce - support for MPI_Type_create_struct (Numpy structured arrays) - ...

Hello world send/recv example:

```python import numba, numba_mpi, numpy

@numba.jit() def hello(): src = numpy.array([1., 2., 3., 4., 5.]) dsttst = numpy.emptylike(src)

if numba_mpi.rank() == 0:
    numba_mpi.send(src, dest=1, tag=11)
elif numba_mpi.rank() == 1:
    numba_mpi.recv(dst_tst, source=0, tag=11)

hello() ```

Example comparing numba-mpi vs. mpi4py performance:

The example below compares Numba+mpi4py vs. Numba+numba-mpi performance. The sample code estimates $\pi$ by numerical integration of $\int0^1 (4/(1+x^2))dx=\pi$ dividing the workload into `nintervalshandled by separate MPI processes and then obtaining a sum usingallreduce(see, e.g., analogous [Matlab docs example](https://www.mathworks.com/help/parallel-computing/numerical-estimation-of-pi-using-message-passing.html)). The computation is carried out in a JIT-compiled functiongetpipart()and is repeated NTIMES. The repetitions and the MPI-handled reduction are done outside or inside of the JIT-compiled block formpi4pyandnumba-mpi, respectively. Timing is repeatedNREPEATtimes and the minimum time is reported. The generated plot shown below depicts the speedup obtained by replacingmpi4py withnumbampi, plotted as a function ofNTIMES / nintervals- the number of MPI calls per interval. The speedup, which stems from avoiding roundtrips between JIT-compiled and Python code is significant (150%-300%) in all cases. The more often communication is needed (smallernintervals), the larger the measured speedup. Note that nothing in the actual number crunching (within thegetpipart()function) or in the employed communication logic (handled by the same MPI library) differs between thempi4pyornumba-mpisolutions. These are the overhead ofmpi4pyhigher-level abstractions and the overhead of repeatedly entering and leaving the JIT-compiled block if usingmpi4py, which can be eliminated by usingnumba-mpi, and which the measured differences in execution time stem from. ``python import timeit, mpi4py, numba, numpy as np, numba_mpi

N_TIMES = 10000 RTOL = 1e-3

@numba.jit def getpipart(nintervals=1000000, rank=0, size=1): h = 1 / nintervals partialsum = 0.0 for i in range(rank + 1, nintervals, size): x = h * (i - 0.5) partialsum += 4 / (1 + x**2) return h * partialsum

@numba.jit def pinumbampi(nintervals): pi = np.array([0.]) part = np.emptylike(pi) for _ in range(NTIMES): part[0] = getpipart(nintervals, numbampi.rank(), numbampi.size()) numbampi.allreduce(part, pi, numbampi.Operator.SUM) assert abs(pi[0] - np.pi) / np.pi < RTOL

def pimpi4py(nintervals): pi = np.array([0.]) part = np.emptylike(pi) for _ in range(NTIMES): part[0] = getpipart(nintervals, mpi4py.MPI.COMMWORLD.rank, mpi4py.MPI.COMMWORLD.size) mpi4py.MPI.COMMWORLD.Allreduce(part, (pi, mpi4py.MPI.DOUBLE), op=mpi4py.MPI.SUM) assert abs(pi[0] - np.pi) / np.pi < RTOL

plotx = [x for x in range(1, 11)] ploty = {'numbampi': [], 'mpi4py': []} for x in plotx: for impl in ploty: ploty[impl].append(min(timeit.repeat( f"pi{impl}(nintervals={N_TIMES // x})", globals=locals(), number=1, repeat=10 )))

if numbampi.rank() == 0: from matplotlib import pyplot pyplot.figure(figsize=(8.3, 3.5), tightlayout=True) pyplot.plot(plotx, np.array(ploty['mpi4py'])/np.array(ploty['numbampi']), marker='o') pyplot.xlabel('number of MPI calls per interval') pyplot.ylabel('mpi4py/numba-mpi wall-time ratio') pyplot.title(f'mpiexec -np {numbampi.size()}') pyplot.grid() pyplot.savefig('readmeplot.svg') ```

plot

Known Issues

NOTE: Issues listed below only relate to combinations of platforms and MPI distributions that we target to support, but due to various reason are currently not working and are temporarily excluded from automated testing:

  • tests on Ubuntu 2024.4 that use MPICH are not run due to failures caused by newer version of MPICH (4.2.0); note, that previous tests ran using version 4.0.2 of MPICH (that is installed by default on Ubuntu 2022.4 using apt) were passing (see related issue - TODO #162),
  • tests on MacOS (both Intel- and ARM-based) that use OpenMPI are currently not run due to failures being under investigation (see related issue - TODO #163).

MPI resources on the web:

  • MPI standard and general information:
    • https://www.mpi-forum.org/docs
    • https://en.wikipedia.org/wiki/MessagePassingInterface
  • MPI implementations:
    • OpenMPI: https://www.open-mpi.org
    • MPICH: https://www.mpich.org
    • MS MPI: https://learn.microsoft.com/en-us/message-passing-interface
    • Intel MPI: https://intel.com/content/www/us/en/developer/tools/oneapi/mpi-library-documentation.html
  • MPI bindings:
    • Python: https://mpi4py.readthedocs.io
    • Python/JAX: https://mpi4jax.readthedocs.io
    • Julia: https://juliaparallel.org/MPI.jl
    • Rust: https://docs.rs/mpi
    • C++: https://boost.org/doc/html/mpi.html
    • R: https://cran.r-project.org/web/packages/Rmpi

Acknowledgements:

We thank all contributors and users who reported feedback to the project through GitHub issues.

Development of numba-mpi has been supported by the Polish National Science Centre (grant no. 2020/39/D/ST10/01220), the Max Planck Society and the European Union (ERC, EmulSim, 101044662). We further acknowledge Poland’s high-performance computing infrastructure PLGrid (HPC Centers: ACK Cyfronet AGH) for providing computer facilities and support within computational grant no. PLG/2023/016369.

Owner

  • Name: numba-mpi
  • Login: numba-mpi
  • Kind: organization

Numba @njittable wrappers for MPI C API

Citation (CITATION.cff)

cff-version: 1.2.0
title: "numba-mpi"
url: "https://github.com/numba-mpi/numba-mpi"
preferred-citation:
  type: article
  authors:
  - family-names: "Derlatka"
    given-names: "Kacper"
  - family-names: "Manna"
    given-names: "Maciej"
  - family-names: "Bulenok"
    given-names: "Oleksii"
  - family-names: "Zwicker"
    given-names: "David"
  - family-names: "Arabas"
    given-names: "Sylwester"
  doi: "10.1016/j.softx.2024.101897"
  journal: "SoftwareX"
  title: "Numba-MPI v1.0: Enabling MPI communication within Numba/LLVM JIT-compiled Python code"
  year: 2024

GitHub Events

Total
  • Create event: 15
  • Release event: 4
  • Issues event: 19
  • Watch event: 5
  • Delete event: 7
  • Member event: 1
  • Issue comment event: 37
  • Push event: 58
  • Pull request review comment event: 8
  • Pull request review event: 15
  • Pull request event: 19
  • Fork event: 3
Last Year
  • Create event: 15
  • Release event: 4
  • Issues event: 19
  • Watch event: 5
  • Delete event: 7
  • Member event: 1
  • Issue comment event: 37
  • Push event: 58
  • Pull request review comment event: 8
  • Pull request review event: 15
  • Pull request event: 19
  • Fork event: 3

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 114
  • Total Committers: 7
  • Avg Commits per committer: 16.286
  • Development Distribution Score (DDS): 0.377
Past Year
  • Commits: 22
  • Committers: 4
  • Avg Commits per committer: 5.5
  • Development Distribution Score (DDS): 0.545
Top Committers
Name Email Commits
Sylwester Arabas s****s@u****l 71
David Zwicker d****r@d****e 20
Sylwester Arabas s****s@a****l 10
Kacper Derlatka 5****r 7
Maciej Manna m****a@g****m 3
Oleksii Bulenok o****k@s****m 2
Kacper Derlatka k****a@p****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 67
  • Total pull requests: 108
  • Average time to close issues: 6 months
  • Average time to close pull requests: 22 days
  • Total issue authors: 10
  • Total pull request authors: 6
  • Average comments per issue: 3.54
  • Average comments per pull request: 1.26
  • Merged pull requests: 93
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 9
  • Pull requests: 17
  • Average time to close issues: 2 months
  • Average time to close pull requests: 19 days
  • Issue authors: 4
  • Pull request authors: 4
  • Average comments per issue: 0.67
  • Average comments per pull request: 2.88
  • Merged pull requests: 17
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • slayoo (48)
  • Delcior (5)
  • xann16 (5)
  • Konjkov (2)
  • DManowitz (2)
  • david-zwicker (1)
  • pnvdp (1)
  • abulenok (1)
  • elyurn (1)
  • jpmorgan98 (1)
Pull Request Authors
  • slayoo (86)
  • Delcior (19)
  • xann16 (9)
  • david-zwicker (8)
  • Sfonxu (4)
  • abulenok (2)
Top Labels
Issue Labels
good first issue (11) no-activity (10) bug (2) high-priority (2) no-issue-activity (2) help wanted (1) enhancement (1)
Pull Request Labels
no-activity (3) no-pr-activity (1) high-priority (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 1,160 last-month
  • Total dependent packages: 2
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 56
  • Total maintainers: 2
pypi.org: numba-mpi

Numba @jittable MPI wrappers tested on Linux, macOS and Windows

  • Versions: 47
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 1,160 Last month
Rankings
Dependent packages count: 3.2%
Downloads: 9.0%
Average: 12.0%
Stargazers count: 12.5%
Forks count: 13.3%
Dependent repos count: 22.1%
Maintainers (2)
Last synced: 6 months ago
conda-forge.org: numba-mpi
  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Average: 46.4%
Forks count: 47.7%
Dependent packages count: 51.2%
Stargazers count: 52.6%
Last synced: 6 months ago

Dependencies

.github/workflows/main.yml actions
  • JamesIves/github-pages-deploy-action 4.1.1 composite
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • actions/setup-python v1 composite
  • mpi4py/setup-mpi v1 composite
  • notiz-dev/github-action-json-property release composite
  • pypa/gh-action-pypi-publish unstable/v1 composite
.github/workflows/readme.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
  • mpi4py/setup-mpi v1 composite
.github/workflows/stale.yml actions
  • actions/stale v3 composite