Skip to main content

Python library implementing linear operators with MPI

Project description

PyLops-MPI

Build status Documentation status OS-support Slack Status

PyLops MPI

pylops-mpi is a Python library built on top of PyLops, designed to enable distributed and parallel processing of large-scale linear algebra operations and computations.

Installation

To install pylops-mpi, you need to have MPI (Message Passing Interface) installed on your system.

  1. Download and Install MPI: Visit the official MPI website to download an appropriate MPI implementation for your system. Follow the installation instructions provided by the MPI vendor.

  2. Verify MPI Installation: After installing MPI, verify its installation by opening a terminal or command prompt and running the following command:

    mpiexec --version
    
  3. Install pylops-mpi: Once MPI is installed and verified, you can proceed to install pylops-mpi.

    You can install with pip:

    pip install pylops-mpi
    

    You can install with make and conda:

    make install_conda
    

Run Pylops-MPI

Once you have installed the prerequisites and pylops-mpi, you can run pylops-mpi using the mpiexec command. Here's an example on how to run the command:

mpiexec -n <NUM_PROCESSES> python <script_name>.py

Example

The DistributedArray can be used to either broadcast or scatter the NumPy array across different ranks or processes.

from pylops_mpi import DistributedArray, Partition

global_shape = (10, 5)

# Initialize a DistributedArray with partition set to Broadcast
dist_array_broadcast = DistributedArray(global_shape=global_shape,
                                        partition=Partition.BROADCAST)

# Initialize a DistributedArray with partition set to Scatter
dist_array_scatter = DistributedArray(global_shape=global_shape,
                                      partition=Partition.SCATTER)

Additionally, the DistributedArray can be used to scatter the array along any specified axis.

# Partition axis = 0
dist_array_0 = DistributedArray(global_shape=global_shape, 
                                partition=Partition.SCATTER, axis=0)

# Partition axis = 1
dist_array_1 = DistributedArray(global_shape=global_shape, 
                                partition=Partition.SCATTER, axis=1)

The DistributedArray class provides a to_dist class method that accepts a NumPy array as input and converts it into an instance of the DistributedArray class. This method is used to transform a regular NumPy array into a DistributedArray that can be distributed and processed across multiple nodes or processes.

import numpy as np
np.random.seed(42)

dist_arr = DistributedArray.to_dist(x=np.random.normal(100, 100, global_shape), 
                                    partition=Partition.SCATTER, axis=0)

The DistributedArray also provides fundamental mathematical operations, like element-wise addition, subtraction, and multiplication, as well as dot product and the np.linalg.norm function in a distributed fashion, thus utilizing the efficiency of the MPI protocol. This enables efficient computation and processing of large-scale distributed arrays.

Running Tests

The test scripts are located in the tests folder. Use the following command to run the tests:

mpiexec -n <NUM_PROCESSES> pytest --with-mpi

The --with-mpi option tells pytest to enable the pytest-mpi plugin, allowing the tests to utilize the MPI functionality.

Documentation

The official documentation of Pylops-MPI is available here. Visit the official docs to learn more about pylops-mpi.

Contributors

  • Rohan Babbar, rohanbabbar04
  • Matteo Ravasi, mrava87

Project details


Download files

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

Source Distribution

pylops-mpi-0.1.0.tar.gz (165.5 kB view details)

Uploaded Source

Built Distribution

pylops_mpi-0.1.0-py3-none-any.whl (189.9 kB view details)

Uploaded Python 3

File details

Details for the file pylops-mpi-0.1.0.tar.gz.

File metadata

  • Download URL: pylops-mpi-0.1.0.tar.gz
  • Upload date:
  • Size: 165.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pylops-mpi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 907c0de9885bf5b5402de33d9ea9ba2151a214cdbe80b9c4cfd3ba5d8275b841
MD5 4674eca5d8f7fb79a32695bac99c3f4e
BLAKE2b-256 37068a14d47ac4546bc3ed588502f94f80a2c49c21e36039a8e61cb3fef8cdbd

See more details on using hashes here.

File details

Details for the file pylops_mpi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pylops_mpi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 189.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pylops_mpi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f80e4d2957bd518c4dc356bdf1b7b50b991c2399eacf16faf89c202918b1e738
MD5 1124a809b6f5143866094db8fc82f1a7
BLAKE2b-256 6da4fd37699fb1e3cbe7f0a4b297e29f9ae291a90e4e5e21b82c032718b8bc00

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page