Skip to content

Commit 3304db2

Browse files
committed
issue/175: add llama and test_bench qy device
1 parent 1ca2c68 commit 3304db2

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ python scripts/test_ppl.py --model-path MODEL_PATH [--ndev NDEV] [--max-batch MA
7171
- 单次推理测试
7272
- llama示例
7373
```bash
74-
python examples/llama.py [--cpu | --nvidia | --metax | --moore | --iluvatar] --model_path=<path/to/model_dir>
74+
python examples/llama.py [--cpu | --nvidia | --qy | --metax | --moore | --iluvatar] --model_path=<path/to/model_dir>
7575
```
7676
- 例如:
7777
```bash
@@ -113,7 +113,7 @@ python scripts/test_ppl.py --model-path MODEL_PATH [--ndev NDEV] [--max-batch MA
113113
- 运行推理基准测试(C-Eval/MMLU)
114114

115115
```bash
116-
python test/bench/test_benchmark.py [--cpu | --nvidia | --cambricon | --ascend | --metax | --moore | --iluvatar | --kunlun | --hygon] <path/to/model_dir> --bench {ceval|mmlu} [--backend cpp] [--ndev N] [--subject SUBJECT] [--num_samples N] [--max_new_tokens N] [--output_csv PATH] [--cache_dir PATH]
116+
python test/bench/test_benchmark.py [--cpu | --nvidia | --qy | --cambricon | --ascend | --metax | --moore | --iluvatar | --kunlun | --hygon] <path/to/model_dir> --bench {ceval|mmlu} [--backend cpp] [--ndev N] [--subject SUBJECT] [--num_samples N] [--max_new_tokens N] [--output_csv PATH] [--cache_dir PATH]
117117
```
118118

119119
- 参数说明:

examples/llama.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def get_args():
2424
action="store_true",
2525
help="Run nvidia test",
2626
)
27+
parser.add_argument(
28+
"--qy",
29+
action="store_true",
30+
help="Run qy test",
31+
)
2732
parser.add_argument(
2833
"--metax",
2934
action="store_true",
@@ -172,6 +177,8 @@ def test(
172177
device_str = "cpu"
173178
elif args.nvidia:
174179
device_str = "cuda"
180+
elif args.qy:
181+
device_str = "cuda"
175182
elif args.metax:
176183
device_str = "cuda"
177184
elif args.moore:
@@ -180,7 +187,7 @@ def test(
180187
device_str = "cuda"
181188
else:
182189
print(
183-
"Usage: python examples/llama.py [--cpu | --nvidia | --metax | --moore | --iluvatar] --model_path=<path/to/model_dir>\n"
190+
"Usage: python examples/llama.py [--cpu | --nvidia | --qy | --metax | --moore | --iluvatar] --model_path=<path/to/model_dir>\n"
184191
"such as, python examples/llama.py --nvidia --model_path=~/TinyLlama-1.1B-Chat-v1.0"
185192
)
186193
sys.exit(1)

python/infinilm/auto_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def from_pretrained(model_path):
2121

2222
if config_dict["model_type"] == "llama":
2323
return LlamaConfig(**config_dict)
24+
elif config_dict["model_type"] == "fm9g":
25+
return LlamaConfig(**config_dict)
2426
elif config_dict["model_type"] == "fm9g7b":
2527
return LlamaConfig(**config_dict)
2628
elif config_dict["model_type"] == "qwen2":

test/bench/test_benchmark.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def __init__(
7272
"iluvatar": "iluvatar",
7373
"kunlun": "kunlun",
7474
"hygon": "hygon",
75+
"qy": "cuda",
7576
}
7677

7778
device_name = device_map.get(device_type_str.lower(), "cpu")
@@ -236,6 +237,8 @@ def __init__(self, model_dir_path, device_type_str="cpu", benchmark="ceval"):
236237
# Device
237238
if device_type_str == "nvidia":
238239
self.device = torch.device("cuda")
240+
elif device_type_str == "qy":
241+
self.device = torch.device("cuda")
239242
elif device_type_str == "cpu":
240243
self.device = torch.device("cpu")
241244
elif device_type_str == "cambricon":
@@ -646,7 +649,7 @@ def test():
646649
# Parse arguments manually to handle device flags properly
647650
if len(sys.argv) < 4:
648651
print(
649-
"Usage: python test_benchmark.py [--cpu | --nvidia| --cambricon | --ascend | --metax | --moore | --iluvatar | --kunlun | --hygon] <path/to/model_dir> --bench [ceval|mmlu] [--backend cpp|torch] [--ndev N] [--subject SUBJECT] [--split {test|val|all}] [--num_samples N] [--max_new_tokens N] [--output_csv PATH] [--cache_dir PATH]"
652+
"Usage: python test_benchmark.py [--cpu | --nvidia| --qy | --cambricon | --ascend | --metax | --moore | --iluvatar | --kunlun | --hygon] <path/to/model_dir> --bench [ceval|mmlu] [--backend cpp|torch] [--ndev N] [--subject SUBJECT] [--split {test|val|all}] [--num_samples N] [--max_new_tokens N] [--output_csv PATH] [--cache_dir PATH]"
650653
)
651654
sys.exit(1)
652655

@@ -725,9 +728,11 @@ def test():
725728
device_type_str = "kunlun"
726729
elif device_flag == "--hygon":
727730
device_type_str = "hygon"
731+
elif device_flag == "--qy":
732+
device_type_str = "qy"
728733
else:
729734
print(
730-
"Usage: python test_benchmark.py [--cpu | --nvidia| --cambricon | --ascend | --metax | --moore | --iluvatar | --kunlun | --hygon] <path/to/model_dir> --bench [ceval|mmlu] [--backend cpp|torch] [--ndev N] [--subject SUBJECT] [--num_samples N] [--max_new_tokens N] [--output_csv PATH] [--cache_dir PATH]"
735+
"Usage: python test_benchmark.py [--cpu | --nvidia| --qy | --cambricon | --ascend | --metax | --moore | --iluvatar | --kunlun | --hygon] <path/to/model_dir> --bench [ceval|mmlu] [--backend cpp|torch] [--ndev N] [--subject SUBJECT] [--num_samples N] [--max_new_tokens N] [--output_csv PATH] [--cache_dir PATH]"
731736
)
732737
sys.exit(1)
733738

0 commit comments

Comments
 (0)