已合并
update _is_support_hccl_comm_name api #13853
guan-longfeng创建于 2024年8月20日
update _is_support_hccl_comm_name api #13853
已合并
guan-longfeng创建于 2024年8月20日
refs/pull/13853/head合入到master
9 个文件变更+36-9
Mtest/distributed/test_api_set_hcom_name.py+1-1
@@ -24,7 +24,7 @@ class SetHcclCommNameTest(TestCase):
24 dist_group = init_pg(rank, world_size)24 dist_group = init_pg(rank, world_size)
25 25 
26 pg1 = torch.distributed.new_group()26 pg1 = torch.distributed.new_group()
27- isSupportHcclName = pg1._get_backend(torch.device('npu'))._is_support_hccl_comm_name()27+ isSupportHcclName = torch_npu.distributed._is_support_hccl_comm_name()
28 assert isSupportHcclName28 assert isSupportHcclName
29 pg1._get_backend(torch.device('npu'))._set_hccl_comm_name("test")29 pg1._get_backend(torch.device('npu'))._set_hccl_comm_name("test")
30 pg1._get_backend(torch.device('npu'))._set_hccl_comm_name("test")30 pg1._get_backend(torch.device('npu'))._set_hccl_comm_name("test")
Mtorch_npu/csrc/core/npu/interface/HcclInterface.cpp+11-0
@@ -39,5 +39,16 @@ extern HcclResult HcclCommResumeFace(HcclComm comm)
39 " maybe you cann version is too low, please upgrade it", DIST_ERROR(ErrCode::NOT_FOUND));39 " maybe you cann version is too low, please upgrade it", DIST_ERROR(ErrCode::NOT_FOUND));
40 return func(comm);40 return func(comm);
41}41}
42+ 
43+extern bool isHcclFeatureSupported(HcclCommConfigCapability configParameter)
44+{
45+ typedef uint32_t(*HcclGetCommConfigCapabilityFunc)();
46+ static HcclGetCommConfigCapabilityFunc func = (HcclGetCommConfigCapabilityFunc) GET_FUNC(
47+ HcclGetCommConfigCapability);
48+ if (func == nullptr) {
49+ return false;
50+ }
51+ return configParameter < func();
52+}
42} // namespace native53} // namespace native
43} // namespace at_npu54} // namespace at_npu
Mtorch_npu/csrc/core/npu/interface/HcclInterface.h+12-0
@@ -17,5 +17,17 @@ extern HcclResult HcclGetCommNameFace(HcclComm commHandle, char* commName);
17 17 
18extern HcclResult HcclCommResumeFace(HcclComm comm);18extern HcclResult HcclCommResumeFace(HcclComm comm);
19 19 
20+/**
21+ * @ingroup AscendCL
22+ * @brief checkout hccl config Feature Supported
23+ *
24+ * @param configParameter [IN] config Feature enum
25+ * @param bool [OUT] feature supported status
26+ *
27+ * @retval ACL_SUCCESS The function is successfully executed.
28+ * @retval OtherValues Failure
29+ */
30+extern bool isHcclFeatureSupported(HcclCommConfigCapability configParameter);
31+ 
20} // namespace native32} // namespace native
21} // namespace at_npu33} // namespace at_npu
Mtorch_npu/csrc/distributed/HCCLUtils.cpp+6-0
@@ -1,4 +1,5 @@
1#include "torch_npu/csrc/distributed/HCCLUtils.hpp"1#include "torch_npu/csrc/distributed/HCCLUtils.hpp"
2+#include "torch_npu/csrc/core/npu/interface/HcclInterface.h"
2 3 
3 4 
4namespace c10d_npu {5namespace c10d_npu {
@@ -85,4 +86,9 @@ std::string getHcclDataTypeSerialString(HcclDataType type)
85 }86 }
86}87}
87 88 
89+bool isSupportHcclCommName()
90+{
91+ return at_npu::hccl::isHcclFeatureSupported(HcclCommConfigCapability::HCCL_COMM_CONFIG_COMM_NAME);
92+}
93+ 
88}94}
Mtorch_npu/csrc/distributed/HCCLUtils.hpp+2-0
@@ -61,6 +61,8 @@ std::string getHcclDataTypeSerialString(HcclDataType type);
61 61 
62bool isFileExists(const std::string& path);62bool isFileExists(const std::string& path);
63 63 
64+bool isSupportHcclCommName();
65+ 
64// RAII wrapper for HCCL communicator66// RAII wrapper for HCCL communicator
65class HCCLComm {67class HCCLComm {
66public:68public:
Mtorch_npu/csrc/distributed/Init.cpp+2-1
@@ -273,6 +273,8 @@ PyObject* c10d_npu_init(PyObject* _unused, PyObject* noargs) {
273 py::arg("src") = 0,273 py::arg("src") = 0,
274 py::call_guard<py::gil_scoped_release>());274 py::call_guard<py::gil_scoped_release>());
275 275 
276+ module.def("_is_support_hccl_comm_name", &c10d_npu::isSupportHcclCommName);
277+ 
276 shared_ptr_class_<c10d_npu::Reducer>(module, "Reducer")278 shared_ptr_class_<c10d_npu::Reducer>(module, "Reducer")
277 .def(py::init<279 .def(py::init<
278 std::vector<at::Tensor>,280 std::vector<at::Tensor>,
@@ -385,7 +387,6 @@ PyObject* c10d_npu_init(PyObject* _unused, PyObject* noargs) {
385 py::call_guard<py::gil_scoped_release>())387 py::call_guard<py::gil_scoped_release>())
386 .def("get_hccl_comm", &::c10d_npu::ProcessGroupHCCL::getHcclComm)388 .def("get_hccl_comm", &::c10d_npu::ProcessGroupHCCL::getHcclComm)
387 .def("_set_hccl_comm_name", &::c10d_npu::ProcessGroupHCCL::setHcclCommName)389 .def("_set_hccl_comm_name", &::c10d_npu::ProcessGroupHCCL::setHcclCommName)
388- .def("_is_support_hccl_comm_name", &::c10d_npu::ProcessGroupHCCL::isSupportHcclCommName)
389 .def("resume_hccl_comm", &::c10d_npu::ProcessGroupHCCL::resumeHcclComm)390 .def("resume_hccl_comm", &::c10d_npu::ProcessGroupHCCL::resumeHcclComm)
390 .def("set_watchdog_status", &::c10d_npu::ProcessGroupHCCL::setWatchdogStatus)391 .def("set_watchdog_status", &::c10d_npu::ProcessGroupHCCL::setWatchdogStatus)
391 .def("clear_workmeta_list", &::c10d_npu::ProcessGroupHCCL::clearWorkMetaList)392 .def("clear_workmeta_list", &::c10d_npu::ProcessGroupHCCL::clearWorkMetaList)
Mtorch_npu/csrc/distributed/ProcessGroupHCCL.cpp+0-5
@@ -1429,11 +1429,6 @@ void ProcessGroupHCCL::setHcclCommName(const std::string& hccl_comm_name)
1429 hccl_comm_name, ", current hcclCommName:", currentHcclCommName, DIST_ERROR(ErrCode::VALUE));1429 hccl_comm_name, ", current hcclCommName:", currentHcclCommName, DIST_ERROR(ErrCode::VALUE));
1430}1430}
1431 1431 
1432-bool ProcessGroupHCCL::isSupportHcclCommName()
1433-{
1434- return isHcclFeatureSupported(HcclCommConfigCapability::HCCL_COMM_CONFIG_COMM_NAME);
1435-}
1436- 
1437std::string ProcessGroupHCCL::getHcclCommName(int rankid, bool init_comm)1432std::string ProcessGroupHCCL::getHcclCommName(int rankid, bool init_comm)
1438{1433{
1439 TORCH_CHECK(rankid >= 0, "Invalid rank ", rankid, DIST_ERROR(ErrCode::VALUE));1434 TORCH_CHECK(rankid >= 0, "Invalid rank ", rankid, DIST_ERROR(ErrCode::VALUE));
Mtorch_npu/csrc/distributed/ProcessGroupHCCL.hpp+0-2
@@ -411,8 +411,6 @@ public:
411 411 
412 void setHcclCommName(const std::string& hccl_comm_name);412 void setHcclCommName(const std::string& hccl_comm_name);
413 413 
414- bool isSupportHcclCommName();
415- 
416 void resumeHcclComm(int device_id);414 void resumeHcclComm(int device_id);
417 415 
418 void setWatchdogStatus(int status);416 void setWatchdogStatus(int status);
Mtorch_npu/distributed/__init__.py+2-0
@@ -24,6 +24,8 @@ if is_available() and not torch_npu._C._c10d_npu_init():
24 24 
25from torch_npu._C._distributed_c10d import (25from torch_npu._C._distributed_c10d import (
26 _verify_params_across_processes,26 _verify_params_across_processes,
27+ _is_support_hccl_comm_name,
27)28)
28 29 
30+ 
29from .distributed_c10d import batch_isend_irecv, gather, gather_object, is_hccl_available31from .distributed_c10d import batch_isend_irecv, gather, gather_object, is_hccl_available