Skip to content

Conversation

@tharittk
Copy link
Collaborator

I introduce the complex number support for NCCL communication here.

Changes made:

  • _nccl.py - Previously, the number of elements sent is equivalent to the number of elements in the send_buf. To support the complex number, we can simply send 2x of that size (_nccl_buf_size()). The receiving data layout does not need changes as it will be according to the recv_buf i.e., it will already be complex if send_buf is complex.

  • test files - I enabled all the tests. Some were muted earlier due to lack of complex-number support. Now the NCCL and MPI both have 306 tests.

  • Fredholm1.py - This likely needs some discussion (please see TODO: comment). Particularly, the private function _allgather is called because Ops do not take base_comm_nccl as an argument. Also, Fredholm operator needs some array unrolling in _rmatvec

Testing:

  • As mentioned, now both NCCL+CuPy and MPI+NumPy cover 306 tests.

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.

@tharittk very good to see support for complex numbers in the NCCL engine 🚀

I just left a few comments here and there and some about your TODO comments.

Only a few things left to do once you address them:

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.

@tharittk good stuff, I like this new approach to pre- and post-process nccl_allgather 😄

I just left a few minor comments, will let you address them and then we are ready to merge this PR. And you can add tests on those new methods in the other PR (#151)...

if deps.nccl_enabled and getattr(self, "base_comm_nccl"):
return nccl_allgather(self.sub_comm, send_buf, recv_buf)
if hasattr(send_buf, "shape"):
send_shapes = self.base_comm.allgather(send_buf.shape)
Copy link
Contributor

Choose a reason for hiding this comment

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

you sure is not self.sub_comm?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh yes, you are right. Strange enough, no test case catches that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, I would think here

xmaskedloc = arr.asarray(masked=True)
the test should fail... the original code (in current main branch) looks correct but your previous commit should have called this
return nccl_asarray(self.sub_comm if masked else self.base_comm_nccl,
in the .asarray call... anyways, now it is correct 😄

@mrava87
Copy link
Contributor

mrava87 commented Jul 3, 2025

@tharittk great work!

I am going to merge this. In a separate PR, we may want to consider adding tests targeting the some of the other methods in the _nccl utils beyond those for nccl_allgather that you have put here 😄

@mrava87 mrava87 merged commit 2c8bf53 into PyLops:main Jul 3, 2025
61 checks passed
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.

2 participants