Skip to content

Implementation of MPI SUMMA matrix mul #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

astroC86
Copy link
Contributor

No description provided.

@astroC86 astroC86 marked this pull request as draft July 14, 2025 23:49
Copy link
Contributor

@mrava87 mrava87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astroC86 very well done, this code looks amazingly clear and (I hope) efficient as the SUMMA promises to be 😄

I think at this point we are left with the following:

  • add a chaining of MPISummaMatrixMult with another operator like we did for MPIMatrixMult
  • add unittests
  • refractor MatrixMult.py to contain 2 private classes _MPIBlockMatrixMult and _MPISummaMatrixMult and a public class MPIMatrixMult which takes all the inputs required by both of the private classes and a kind parameter to choose between block and summa - see https://github.com/PyLops/pylops/blob/dev/pylops/signalprocessing/fft2d.py for a similar pattern

for k in range(self._P_prime):
Atemp = self.A.copy() if self._col_id == k else np.empty_like(self.A)
Xtemp = x_block.copy() if self._row_id == k else np.empty_like(x_block)
self._row_comm.Bcast(Atemp, root=k)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: do you think you could use bcast instead of Bcast?

The reason I am asking is because we currently use always lower-case methods, which although sub-optimal (mpi4py/mpi4py#657) has the advantage of working with CuPy arrays out of the box whilst we saw some issues when @tharittk tried to use upper-case methods (although it was Send/Recv)... my suggestion would be, let's stick to what we currently do and soon (hopefully during @tharittk second part of GSoC) we will switch all MPI4PY calls involving NumPy/CuPy arrays to buffers (aka upper-case methods)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok perfect! will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super super weird when I changed from Bcast to bcast I am getting wrong values

@astroC86 astroC86 force-pushed the actual-SUMMA branch 6 times, most recently from 21ea369 to a994192 Compare July 26, 2025 19:08
@astroC86 astroC86 requested a review from mrava87 July 27, 2025 14:49
@astroC86 astroC86 marked this pull request as ready for review July 27, 2025 14:50
Copy link

@mrava87SW mrava87SW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astroC86 good job!

I think the code reads well and the way you created the MPIMatrixMult operator. I noticed (even before I pushed some minor stylistic fixes) that one test was failing... but did not have time to look into it, I guess you can probably more quickly figure out why 😉

Once the tests are passing, @hongyx11 has also looked at the SUMMA implementation and we have discussed the point I raised above about upper vs lower case communication routines*, we should be ready to merge this PR!

  • as I suspected, after my last commit, the kind=blocked works with CuPy arrays whilst kind=summa leads to a segmentation fault - likely due to the same cause of this #144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants