pyamrex

GPU-Enabled, Zero-Copy AMReX Python Bindings including AI/ML

https://github.com/amrex-codes/pyamrex

Science Score: 39.0%

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

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.6%) to scientific vocabulary

Keywords

amrex python
Last synced: 6 months ago · JSON representation

Repository

GPU-Enabled, Zero-Copy AMReX Python Bindings including AI/ML

Basic Info
  • Host: GitHub
  • Owner: AMReX-Codes
  • License: other
  • Language: Python
  • Default Branch: development
  • Homepage: http://pyamrex.readthedocs.io
  • Size: 1.9 MB
Statistics
  • Stars: 48
  • Watchers: 15
  • Forks: 22
  • Open Issues: 43
  • Releases: 34
Topics
amrex python
Created about 5 years ago · Last pushed 6 months ago
Metadata Files
Readme License Code of conduct Zenodo

README.md

pyAMReX

Python3 Python3 API: Beta Documentation Status Discussions Linux macOS Windows License pyAMReX DOI (source)

The Python binding pyAMReX bridges the compute in AMReX block-structured codes and data science: it provides zero-copy application GPU data access for AI/ML, in situ analysis, application coupling and enables rapid, massively parallel prototyping. pyAMReX enhances the Block-Structured AMR Software Framework AMReX and its applications.

Users

pyAMReX can be installed with package managers or from source.

Usage

Please see the manual and our test cases for detailed examples.

Use AMReX objects and APIs from Python: ```python import amrex.space3d as amr

amr.initialize([])

smallend = amr.IntVect() bigend = amr.IntVect(2, 3, 4)

b = amr.Box(smallend, bigend) print(b)

...

amr.finalize() ```

Note that many AMReX functions may cause a segmentation fault if run without first initializing AMReX (amr.initialize([])).

Developers

If you are new to CMake, this short tutorial from the HEP Software foundation is the perfect place to get started with it.

If you just want to use CMake to build the project, jump into sections 1. Introduction, 2. Building with CMake and 9. Finding Packages.

Dependencies

pyAMReX depends on the following popular third party software.

Optional dependencies include: - mpi4py 2.1+: for multi-node and/or multi-GPU execution - CCache: to speed up rebuilds (for CUDA support, needs 3.7.9+ and 4.2+ is recommended) - further optional dependencies of AMReX - pandas 2+: for DataFrame support - pytest 6.2+: for running unit tests

Optional CUDA-capable dependencies for tests include: - cupy 11.2+ - numba 0.56+ - torch 1.12+

Install Dependencies

macOS/Linux: ```bash spack env activate -d .

optional:

spack add cuda

spack install `` (in new terminals, re-activate the environment withspack env activate -d .` again)

or macOS/Linux: bash brew update brew install ccache cmake libomp mpi4py numpy open-mpi python

Now, cmake --version should be at version 3.24.0 or newer.

Or go: bash python3 -m pip install -U pip python3 -m pip install -U build packaging setuptools[core] wheel python3 -m pip install -U cmake

If you wish to run unit tests, then please install pytest

bash python3 -m pip install -U pytest

Some of our tests depend on optional third-party modules (e.g., pandas, cupy, numba, and/or pytorch). If these are not installed then their tests will be skipped.

Configure your compiler

For example, using the Clang compiler: bash export CC=$(which clang) export CXX=$(which clang++)

If you also want to select a CUDA compiler: bash export CUDACXX=$(which nvcc) export CUDAHOSTCXX=$(which clang++)

Build

From the base of the pyAMReX source directory, execute: ```bash

optional controls (example):

export AMREX_SPACEDIM=3

export AMREX_MPI=ON

export AMREX_OMP=ON

export AMREXGPUBACKEND=CUDA

export AMREX_SRC=$PWD/../amrex

export CMAKEBUILDPARALLEL_LEVEL=8

python3 -m pip install -U -r requirements.txt python3 -m pip install -v --force-reinstall --no-deps . ```

If you are iterating on builds, it will faster to rely on ccache and to let CMake call the pip install logic: bash cmake -S . -B build -DAMReX_SPACEDIM="1;2;3" cmake --build build --target pip_install -j 8

Test

After successful installation, you can run the unit tests (assuming pytest is installed). If AMREX_MPI=ON, then please prepend the following commands with mpiexec -np <NUM_PROCS>

```bash

Run all tests

python3 -m pytest tests/

Run tests from a single file

python3 -m pytest tests/test_intvect.py

Run a single test (useful during debugging)

python3 -m pytest tests/testintvect.py::testiv_conversions

Run all tests, do not capture "print" output and be verbose

python3 -m pytest -s -vvvv tests/ ```

Build Options

If you are using the pip-driven install, selected AMReX CMake options can be controlled with environment variables:

| Environment Variable | Default & Values | Description | |------------------------------|--------------------------------------------|--------------------------------------------------------------| | AMREX_OMP | ON/OFF | Enable OpenMP | | AMREX_GPU_BACKEND | NONE/SYCL/CUDA/HIP | On-node, accelerated GPU backend | | AMREX_MPI | ON/OFF | Enable MPI | | AMREX_PRECISION | SINGLE/DOUBLE | Precision of AMReX Real type | | AMREX_SPACEDIM | "1;2;3" | Dimension(s) of AMReX as a ;-separated list | | AMREX_BUILD_SHARED_LIBS | ON/OFF | Build the core AMReX library as shared library | | AMREX_SRC | None | Absolute path to AMReX source directory (preferred if set) | | AMREX_REPO | https://github.com/AMReX-Codes/amrex.git | Repository URI to pull and build AMReX from | | AMREX_BRANCH | development | Repository branch for AMREX_REPO | | AMREX_INTERNAL | ON/OFF | Needs a pre-installed AMReX library if set to OFF | | PYBIND11_INTERNAL | ON/OFF | Needs a pre-installed pybind11 library if set to OFF | | CMAKE_BUILD_PARALLEL_LEVEL | 2 | Number of parallel build threads | | PYAMREX_LIBDIR | None | If set, search for pre-built a pyAMReX library | | PYAMREX_CCACHE | ON/OFF | Search and use CCache to speed up rebuilds | | PYAMREX_IPO | ON/OFF | Compile with interprocedural/link optimization (IPO/LTO) | | PY_PIP_OPTIONS | -v | Additional options for pip, e.g., -vvv;-q | | PY_PIP_INSTALL_OPTIONS | None | Additional options for pip install, e.g., --user;-q |

Furthermore, pyAMReX adds a few selected CMake build options:

| CMake Option | Default & Values | Description | |------------------------------|--------------------------------------------|---------------------------------------------------------------| | AMReX_SPACEDIM | 3, use "1;2;3" for all | Dimension(s) of AMReX as a ;-separated list | | pyAMReX_CCACHE | ON/OFF | Search and use CCache to speed up rebuilds | | pyAMReX_IPO | ON/OFF | Compile with interprocedural/link optimization (IPO/LTO) | | pyAMReX_INSTALL | ON/OFF | Enable install targets for pyAMReX | | pyAMReX_amrex_src | None | Absolute path to AMReX source directory (preferred if set) | | pyAMReX_amrex_internal | ON/OFF | Needs a pre-installed AMReX library if set to OFF | | pyAMReX_amrex_repo | https://github.com/AMReX-Codes/amrex.git | Repository URI to pull and build AMReX from | | pyAMReX_amrex_branch | development | Repository branch for pyAMReX_amrex_repo | | pyAMReX_pybind11_src | None | Absolute path to pybind11 source directory (preferred if set) | | pyAMReX_pybind11_internal | ON/OFF | Needs a pre-installed pybind11 library if set to OFF | | pyAMReX_pybind11_repo | https://github.com/pybind/pybind11.git | Repository URI to pull and build pybind11 from | | pyAMReX_pybind11_branch | v3.0.0 | Repository branch for pyAMReX_pybind11_repo | | Python_EXECUTABLE | (newest found) | Path to Python executable |

As one example, one can also build against a local AMReX copy. Assuming AMReX' source is located in $HOME/src/amrex, then export AMREX_SRC=$HOME/src/amrex.

Or as a one-liner, assuming your AMReX source directory is located in ../amrex: bash AMREX_SRC=$PWD/../amrex python3 -m pip install -v --force-reinstall . Note that you need to use absolute paths for external source trees, because pip builds in a temporary directory.

Or build against an AMReX feature branch of a colleague. Assuming your colleague pushed AMReX to https://github.com/WeiqunZhang/amrex/ in a branch new-feature then

bash unset AMREX_SRC # preferred if set AMREX_REPO=https://github.com/WeiqunZhang/amrex.git AMREX_BRANCH=new-feature python3 -m pip install -v --force-reinstall .

You can speed up the install further if you pre-install AMReX, e.g. with a package manager. Set AMREX_INTERNAL=OFF and add installation prefix of AMReX to the environment variable CMAKEPREFIXPATH. Please see the short CMake tutorial that we linked above if this sounds new to you.

Acknowledgements

This work was supported by the Laboratory Directed Research and Development Program of Lawrence Berkeley National Laboratory under U.S. Department of Energy Contract No. DE-AC02-05CH11231.

Copyright Notice

pyAMReX Copyright (c) 2023, The Regents of the University of California, through Lawrence Berkeley National Laboratory, National Renewable Energy Laboratory Alliance for Sustainable Energy, LLC and Lawrence Livermore National Security, LLC (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.

If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Intellectual Property Office at IPO@lbl.gov.

Please see the full license agreement in LICENSE. Please see the notices in NOTICE. The SPDX license identifier is BSD-3-Clause-LBNL.

Owner

  • Name: AMReX-Codes
  • Login: AMReX-Codes
  • Kind: organization

AMReX-Codes: Block-Structured AMR Software Framework and Applications

GitHub Events

Total
  • Create event: 26
  • Release event: 10
  • Issues event: 12
  • Watch event: 11
  • Delete event: 13
  • Issue comment event: 56
  • Push event: 111
  • Pull request review comment event: 60
  • Pull request review event: 87
  • Pull request event: 123
  • Fork event: 2
Last Year
  • Create event: 26
  • Release event: 10
  • Issues event: 12
  • Watch event: 11
  • Delete event: 13
  • Issue comment event: 56
  • Push event: 111
  • Pull request review comment event: 60
  • Pull request review event: 87
  • Pull request event: 123
  • Fork event: 2

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 18
  • Total pull requests: 195
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 5 days
  • Total issue authors: 7
  • Total pull request authors: 14
  • Average comments per issue: 0.94
  • Average comments per pull request: 0.33
  • Merged pull requests: 167
  • Bot issues: 0
  • Bot pull requests: 50
Past Year
  • Issues: 9
  • Pull requests: 85
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 5 days
  • Issue authors: 3
  • Pull request authors: 10
  • Average comments per issue: 0.11
  • Average comments per pull request: 0.35
  • Merged pull requests: 67
  • Bot issues: 0
  • Bot pull requests: 23
Top Authors
Issue Authors
  • ax3l (9)
  • BenWibking (3)
  • matilde-t (2)
  • RTSandberg (1)
  • EZoni (1)
  • archermarx (1)
  • indra098124 (1)
Pull Request Authors
  • ax3l (106)
  • pre-commit-ci[bot] (50)
  • EZoni (9)
  • dpgrote (8)
  • WeiqunZhang (5)
  • siddanib (3)
  • AlexanderSinn (3)
  • atmyers (3)
  • RemiLehe (2)
  • BenWibking (2)
  • JBlaschke (1)
  • RevathiJambunathan (1)
  • baperry2 (1)
  • roelof-groenewald (1)
Top Labels
Issue Labels
good first issue (5) help wanted (5) enhancement (4) API: breaking (3) install (3) component: particles (2) component: tests (2) bug (1) gpu (1) question (1) component: documentation (1)
Pull Request Labels
component: tests (43) component: documentation (32) enhancement (25) bug (23) install (20) bug: affects latest release (18) component: third party (16) backend: cuda (5) component: particles (5) API: breaking (4) backend: hip (3) backend: openmp (3) warning (3) documentation (2) component: MPI (1) backend: sycl (1) help wanted (1)

Dependencies

requirements.txt pypi
  • numpy *
.github/workflows/ci.yml actions
  • actions/upload-artifact v3 composite
.github/workflows/cleanup-cache-postpr.yml actions
  • actions/checkout v3 composite
.github/workflows/cleanup-cache.yml actions
  • actions/checkout v3 composite
.github/workflows/codeql.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/autobuild v2 composite
  • github/codeql-action/init v2 composite
.github/workflows/hip.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
.github/workflows/intel.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
.github/workflows/macos.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
.github/workflows/post-pr.yml actions
  • actions/upload-artifact v3 composite
.github/workflows/stubs.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • stefanzweifel/git-auto-commit-action v4 composite
.github/workflows/ubuntu.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/windows.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • seanmiddleditch/gha-setup-ninja master composite
docs/requirements.txt pypi
  • breathe *
  • docutils >=0.17.1
  • numpy *
  • pygments *
  • recommonmark *
  • sphinx >=5.3,<7.2
  • sphinx-design *
  • sphinx_rtd_theme >=1.1.1
pyproject.toml pypi
requirements_mpi.txt pypi
  • mpi4py >=2.1.0
setup.py pypi