Week 3,4 - GSOC 2023
This blog post briefly describes the work done on the project during the 3rd and 4th weeks of GSoC 2023.
Work Done
Added
axis
as a parameter to DistributedArray.Setup Sphinx Documentation
Build the docs in a GitHub Action and host them on GitHub Pages.
Added plotting functions to visualize DistributedArray.
Add Dot Product for vectors in a distributed fashion.
Add numpy.linalg.norm for vectors in a distributed fashion.
Add
MPIBlockDiag
class
Add axis as a parameter to DistributedArray
As discussed with my mentors, adding the axis of partition will be useful as we are working with Linear Operators. The axis
is added as a parameter to the DistributedArray
class.
# 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)
Also added a README file that explains the project details.
Setup Sphinx Documentation
Sphinx is used for generating HTML web pages, so setting it up early would be an added advantage. I also added a deploy-docs.yml
which builds the sphinx docs and hosts them on GitHub pages using GitHub Actions.
Plotting Functions for DistributedArray
Much like PyLops, we represent the DistributedArray
as plots to give a better understanding of the array. This can be used to plot any DistributedArray
. The plots are made using matplotlib. For more information look into the examples folder of the project. Use the below command to run an example.
$ mpiexec -n 3 python <script_name>.py
Below is an example visualization of a DistributedArray over axis=0
, the output showcases how the original array is distributed across different ranks, in this case, three different ranks/processes. Each rank handles its portion of the global array.
Here's an implementation that demonstrates a change in the axis of distribution, specifically when axis=1
.
Dot Product and Norm Method
For solvers, there was a need to apply dot product and numpy.linalg.norm in a distributed fashion which was completed successfully.
Added MPIBlockDiag
I Added MPIBlockDiag
class which is written on top of pylops.BlockDiag
. This class distributes operators to different ranks thereby each rank has a portion of the model and data and computations happen at each rank. Added _matvec
and _rmatvec
which performs matrix-vector multiplication in a distributed fashion.
Challenges I ran into
It took me some time to figure out the logic of distributing the array along an axis. Had to dig deep into the documentation of the norm method to understand and implement it.
Finally, MPIBlockDiag took me almost a week to think about logic and write that logic as an efficient code, but thanks to my mentors, I was able to do it.
To Do in Coming Weeks
In the coming week, I will be working on the Post-Stack Inversion Problem.
Thank you for reading this post!
Subscribe to my newsletter
Read articles from Rohan Babbar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by