Skip to content

Commit 17ab3a8

Browse files
committed
issue/988 - adapt to ali ppu
1 parent 70862bc commit 17ab3a8

46 files changed

Lines changed: 458 additions & 29 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/infinicore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ typedef enum {
4747
INFINI_DEVICE_KUNLUN = 7,
4848
INFINI_DEVICE_HYGON = 8,
4949
INFINI_DEVICE_QY = 9,
50+
INFINI_DEVICE_ALI = 10,
5051
INFINI_DEVICE_TYPE_COUNT
5152
} infiniDevice_t;
5253

include/infinicore/device.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Device {
2222
KUNLUN = INFINI_DEVICE_KUNLUN,
2323
HYGON = INFINI_DEVICE_HYGON,
2424
QY = INFINI_DEVICE_QY,
25+
ALI = INFINI_DEVICE_ALI,
2526
COUNT = INFINI_DEVICE_TYPE_COUNT,
2627
};
2728

python/infinicore/device.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def _from_infinicore_device(infinicore_device: _infinicore.Device):
8282
_infinicore.Device.Type.KUNLUN: "cuda",
8383
_infinicore.Device.Type.HYGON: "cuda",
8484
_infinicore.Device.Type.QY: "cuda",
85+
_infinicore.Device.Type.ALI: "cuda",
8586
}
8687

8788

src/infiniccl-test/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void printUsage() {
1212
std::cout << "infiniccl-test --<device>" << std::endl
1313
<< std::endl;
1414
std::cout << " --<device>" << std::endl;
15-
std::cout << " Specify the device type --(nvidia|cambricon|ascend|metax|moore|iluvatar|qy|kunlun|hygon)." << std::endl
15+
std::cout << " Specify the device type --(nvidia|cambricon|ascend|metax|moore|iluvatar|qy|kunlun|hygon|ali)." << std::endl
1616
<< std::endl;
1717
std::cout << "The program will run tests on all visible devices of the specified device type."
1818
<< " Use Environmental Variables such as CUDA_VSIBLE_DEVICES to limit visible device IDs.";
@@ -46,6 +46,7 @@ ParsedArgs parseArgs(int argc, char *argv[]) {
4646
else PARSE_DEVICE("--qy", INFINI_DEVICE_QY)
4747
else PARSE_DEVICE("--kunlun", INFINI_DEVICE_KUNLUN)
4848
else PARSE_DEVICE("--hygon", INFINI_DEVICE_HYGON)
49+
else PARSE_DEVICE("--ali", INFINI_DEVICE_ALI)
4950
else {
5051
printUsage();
5152
}

src/infiniccl/cuda/infiniccl_cuda.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "../infiniccl_impl.h"
55

66
// Windows does not support CUDA
7-
#if (defined(ENABLE_NVIDIA_API) || defined(ENABLE_ILUVATAR_API) || defined(ENABLE_QY_API) || defined(ENABLE_HYGON_API)) && defined(ENABLE_CCL) && !defined(_WIN32)
7+
#if (defined(ENABLE_NVIDIA_API) || defined(ENABLE_ILUVATAR_API) || defined(ENABLE_QY_API) || defined(ENABLE_HYGON_API)) || defined(ENABLE_ALI_API) && defined(ENABLE_CCL) && !defined(_WIN32)
88
INFINICCL_DEVICE_API_IMPL(cuda)
99
#else
1010
INFINICCL_DEVICE_API_NOOP(cuda)

src/infiniccl/infiniccl.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ __C infiniStatus_t infinicclCommInitAll(
2727
COMM_INIT_ALL(INFINI_DEVICE_METAX, metax);
2828
COMM_INIT_ALL(INFINI_DEVICE_MOORE, moore);
2929
COMM_INIT_ALL(INFINI_DEVICE_KUNLUN, kunlun);
30+
COMM_INIT_ALL(INFINI_DEVICE_ALI, cuda);
3031
default:
3132
return INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
3233
}
@@ -53,6 +54,7 @@ __C infiniStatus_t infinicclCommDestroy(infinicclComm_t comm) {
5354
COMM_DESTROY(INFINI_DEVICE_METAX, metax);
5455
COMM_DESTROY(INFINI_DEVICE_MOORE, moore);
5556
COMM_DESTROY(INFINI_DEVICE_KUNLUN, kunlun);
57+
COMM_DESTROY(INFINI_DEVICE_ALI, cuda);
5658
default:
5759
return INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED;
5860
}
@@ -86,6 +88,7 @@ __C infiniStatus_t infinicclAllReduce(
8688
ALL_REDUCE(INFINI_DEVICE_METAX, metax);
8789
ALL_REDUCE(INFINI_DEVICE_MOORE, moore);
8890
ALL_REDUCE(INFINI_DEVICE_KUNLUN, kunlun);
91+
ALL_REDUCE(INFINI_DEVICE_ALI, cuda);
8992

9093
default:
9194
return INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED;

src/infinicore-test/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ xmake build infinicore-test
6666
./infinicore-test --qy
6767
./infinicore-test --kunlun
6868
./infinicore-test --hygon
69+
./infinicore-test --ali
6970
```
7071

7172
### Customize Test Parameters

src/infinicore-test/main.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void printUsage() {
4242
<< " qy" << std::endl
4343
<< " kunlun" << std::endl
4444
<< " hygon" << std::endl
45+
<< " ali" << std::endl
4546
<< std::endl
4647
<< "Available tests:" << std::endl
4748
<< " basic - Basic memory allocation and deallocation tests" << std::endl
@@ -84,6 +85,8 @@ ParsedArgs parseArgs(int argc, char *argv[]) {
8485
args.device_type = INFINI_DEVICE_KUNLUN;
8586
} else if (arg == "--hygon") {
8687
args.device_type = INFINI_DEVICE_HYGON;
88+
} else if (arg == "--ali") {
89+
args.device_type = INFINI_DEVICE_ALI;
8790
} else if (arg == "--test") {
8891
if (i + 1 >= argc) {
8992
std::cerr << "Error: --test requires a test name" << std::endl;

src/infinicore/device.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ std::string Device::toString(const Type &type) {
4141
return "KUNLUN";
4242
case Type::HYGON:
4343
return "HYGON";
44+
case Type::ALI:
45+
return "ALI";
4446
case Type::COUNT:
4547
return "COUNT";
4648
default:

src/infinicore/nn/embedding.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Embedding::Embedding(size_t num_embeddings,
4545
Tensor Embedding::forward(const Tensor &indices) const {
4646
// TODO: Implement on-device embedding for all devices, then remove the condition and the classic approach
4747
auto device_type = device_.getType();
48-
if (device_type == Device::Type::NVIDIA || device_type == Device::Type::ILUVATAR || device_type == Device::Type::METAX || device_type == Device::Type::MOORE) {
48+
if (device_type == Device::Type::NVIDIA || device_type == Device::Type::ILUVATAR || device_type == Device::Type::METAX || device_type == Device::Type::MOORE || device_type == Device::Type::KUNLUN || device_type == Device::Type::HYGON || device_type == Device::Type::QY || device_type == Device::Type::ALI) {
4949
// Use op::embedding which supports device-side input and batch dimension
5050
return op::embedding(indices->contiguous()->to(device_), weight_);
5151
}

0 commit comments

Comments
 (0)