Skip to content

Commit 54a7fdf

Browse files
authored
Merge pull request #213 from InfiniTensor/issue/208d
issue/208 - adapt to ali ppu
2 parents 4340dff + 033af1b commit 54a7fdf

5 files changed

Lines changed: 23 additions & 3 deletions

File tree

examples/bench.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ def get_args():
157157
action="store_true",
158158
help="Run cambricon test",
159159
)
160+
parser.add_argument(
161+
"--ali",
162+
action="store_true",
163+
help="Run alippu test",
164+
)
160165
parser.add_argument(
161166
"--model",
162167
type=str,
@@ -351,6 +356,8 @@ def run(
351356
device_str = "cuda"
352357
elif args.cambricon:
353358
device_str = "mlu"
359+
elif args.ali:
360+
device_str = "cuda"
354361
else:
355362
print(
356363
"python examples/bench.py --nvidia --model=~/TinyLlama-1.1B-Chat-v1.0/ --batch-size=2 --tp=1 --input-len=50 --output-len=50"

examples/jiuge.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ def get_args():
4747
action="store_true",
4848
help="Run cambricon test",
4949
)
50+
parser.add_argument(
51+
"--ali",
52+
action="store_true",
53+
help="Run alippu test",
54+
)
5055
parser.add_argument(
5156
"--model_path",
5257
type=str,
@@ -252,9 +257,11 @@ def test(
252257
device_str = "cuda"
253258
elif args.cambricon:
254259
device_str = "mlu"
260+
elif args.ali:
261+
device_str = "cuda"
255262
else:
256263
print(
257-
"Usage: python examples/jiuge.py [--cpu | --nvidia | --metax | --moore | --iluvatar] --model_path=<path/to/model_dir>\n"
264+
"Usage: python examples/jiuge.py [--cpu | --nvidia | --metax | --moore | --iluvatar | --cambricon | --ali] --model_path=<path/to/model_dir>\n"
258265
"such as, python examples/jiuge.py --nvidia --model_path=~/TinyLlama-1.1B-Chat-v1.0"
259266
)
260267
sys.exit(1)

python/infinilm/server/inference_server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ def parse_args():
414414
parser.add_argument("--moore", action="store_true", help="Use Moore device")
415415
parser.add_argument("--iluvatar", action="store_true", help="Use Iluvatar device")
416416
parser.add_argument("--cambricon", action="store_true", help="Use Cambricon device")
417+
parser.add_argument("--ali", action="store_true", help="Use Ali PPU device")
417418
parser.add_argument(
418419
"--enable-graph",
419420
action="store_true",
@@ -447,9 +448,11 @@ def main():
447448
device = "cuda"
448449
elif args.cambricon:
449450
device = "mlu"
451+
elif args.ali:
452+
device = "cuda"
450453
else:
451454
print(
452-
"Usage: python infinilm.server.inference_server [--cpu | --nvidia | --metax | --moore | --iluvatar | --cambricon] "
455+
"Usage: python infinilm.server.inference_server [--cpu | --nvidia | --metax | --moore | --iluvatar | --cambricon | --ali] "
453456
"--model_path=<path/to/model_dir> --max_tokens=MAX_TOKENS --max_batch_size=MAX_BATCH_SIZE"
454457
"\n"
455458
"Example: python infinilm.server.inference_server --nvidia --model_path=/data/shared/models/9G7B_MHA/ "

scripts/jiuge.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,9 +860,11 @@ def test():
860860
device_type = DeviceType.DEVICE_TYPE_KUNLUN
861861
elif sys.argv[1] == "--hygon":
862862
device_type = DeviceType.DEVICE_TYPE_HYGON
863+
elif sys.argv[1] == "--ali":
864+
device_type = DeviceType.DEVICE_TYPE_ALI
863865
else:
864866
print(
865-
"Usage: python jiuge.py [--cpu | --nvidia| --qy| --cambricon | --ascend | --metax | --moore | --iluvatar | --kunlun | --hygon] <path/to/model_dir> [n_device] [--verbose]"
867+
"Usage: python jiuge.py [--cpu | --nvidia| --qy| --cambricon | --ascend | --metax | --moore | --iluvatar | --kunlun | --hygon | --ali] <path/to/model_dir> [n_device] [--verbose]"
866868
)
867869
sys.exit(1)
868870

scripts/libinfinicore_infer/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class DeviceType(ctypes.c_int):
3737
DEVICE_TYPE_KUNLUN = 7
3838
DEVICE_TYPE_HYGON = 8
3939
DEVICE_TYPE_QY = 9
40+
DEVICE_TYPE_ALI = 10
4041

4142

4243
class KVCacheCStruct(ctypes.Structure):

0 commit comments

Comments
 (0)