-
Notifications
You must be signed in to change notification settings - Fork 90
feat: add NPU process group initialization and management. #456
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
base: main
Are you sure you want to change the base?
Conversation
| : ProcessGroup(device) { | ||
| c10::intrusive_ptr<c10d_npu::ProcessGroupHCCL::Options> hccl_pg_options = | ||
| c10d_npu::ProcessGroupHCCL::Options::create(); | ||
| // hccl_pg_options->group_name = group_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if TORCH_VERSION_MAJOR >= 2 && TORCH_VERSION_MINOR >= 7
pg_options->group_name = group_name;
#endif There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I'll add the version check.
To ensure forward compatibility (e.g., for PyTorch 3.0 where MINOR might be 0), I'll adjust the logic to cover cases where MAJOR > 2 as well
| #include "npu_process_group.h" | ||
| #include "xllm_kernels/core/include/atb_speed/base/external_comm_manager.h" | ||
| #include "xllm_kernels/core/include/atb_speed/utils/singleton.h" | ||
| #include "xllm_kernels/models/base/param/mapping.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 22-24 seems useless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. These lines were not added by me, but I verified that lines 22-23 are actually necessary for atb_speed::GetSingleton. However, line 24 is indeed unused, so I will remove it.
| limitations under the License. | ||
| ==============================================================================*/ | ||
|
|
||
| #include "npu_process_group.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npu_process_group.cpp should be deleted, because npu_process_group.h is enough, like cuda/mlu_process_group.h.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. However, I strongly prefer to keep the .cpp file. Defining implementation directly in the header is generally considered bad practice. I hope you understand my decision to maintain this separation.
| // for (int i = 0; i < outputs.size(); ++i) { | ||
| // outputs[i].copy_(flattened_output[i], /*non_blocking=*/true); | ||
| // } | ||
| std::unique_ptr<xllm::ProcessGroup> create_process_group( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_process_group function can placed into an anonymous namespace in collective_communicator.cpp for all devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback.
Regarding the suggestion to consolidate the create_process_group functions, I have a few concerns:
Since ProcessGroupHCCL, ProcessGroupCncl, and ProcessGroupNccl are device-specific implementations , moving them to collective_communicator.cpp would introduce excessive #if/#elif preprocessor directives.
9b68705 to
3b6f3d1
Compare
|
I have updated the three images on the main branch, and the build is now passing. Would you mind taking a look at the code to see if it is ready for merging? I would appreciate your review. @yq33victor |

No description provided.