From 8bf2c4b0344aa176dca437771249e771450308dc Mon Sep 17 00:00:00 2001 From: vigney-young Date: Mon, 18 Dec 2023 17:45:42 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9python=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=EF=BC=8C=E5=A2=9E=E5=8A=A0compile=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foundation/ChatGLM2-6B/compile_model.py | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py index ae09673c85..23b56da2cc 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py @@ -16,6 +16,8 @@ import sys from transformers import AutoTokenizer, AutoModel import torch +import torch_aie +from torch_aie import _enums import numpy as np import argparse @@ -28,14 +30,18 @@ def main(): required=False, help='npu device') parser.add_argument('--need_trace', default="true", required=False, help='If you have traced the model before then set false') + parser.add_argument('--need_compile', default="true", + required=False, help='If you have compiled the model before then set false') args = parser.parse_args() device = args.device model_path = args.pretrained_model need_trace = args.need_trace + need_compile = args.need_compile model = AutoModel.from_pretrained(model_path, trust_remote_code=True, torchscript=True).float() model.eval() + torch_aie.set_device(device) # stage1: model trace if need_trace == "true": print("===================== start to trace model ==========================") @@ -54,6 +60,46 @@ def main(): torch.jit.save(traced_model, traced_model_path) print("===================== model trace success ==========================") + # stage2: model compile + if need_compile == "true": + ## load origin traced model + traced_model_path = "./chatglm2_6b_batch_1_traced.pt" + try: + traced_model = torch.jit.load(traced_model_path) + except Exception as e: + print("load model failed, please trace first.") + + ## set compile config + inputs = [] + max_seqlen = 10000 + input0_min_shape = (1, 1) + input0_max_shape = (1, max_seqlen) + input1_min_shape = (1, 1) + input1_max_shape = (1, max_seqlen) + input2_min_shape = (1, 1) + input2_max_shape = (1, max_seqlen) + input3_min_shape = (1, 2, 0, 1, 2, 128) + input3_max_shape = (1, 2, max_seqlen, 1, 2, 128) + + inputs.append(torch_aie.Input(min_shape = input0_min_shape, max_shape = input0_max_shape, dtype = torch.int64)) + inputs.append(torch_aie.Input(min_shape = input1_min_shape, max_shape = input1_max_shape, dtype = torch.int64)) + inputs.append(torch_aie.Input(min_shape = input2_min_shape, max_shape = input2_max_shape, dtype = torch.int64)) + inputs.append(torch_aie.Input(min_shape = input3_min_shape, max_shape = input3_max_shape, dtype = torch.float32)) + + ## compile + print("===================== start to compile model ==========================") + compiled_module = torch_aie.compile( + traced_model, + inputs=inputs, + precision_policy=_enums.PrecisionPolicy.FP32, + allow_tensor_replace_int=True, + soc_version="Ascend910B4" + ) + print("===================== model compile success ==========================") + ## save compiled result + aie_model_path = "./chatglm2_6b_batch_1_compiled.ts" + compiled_module.save(aie_model_path) + print("===================== save compiled model success ======================") if __name__ == '__main__': -- Gitee From 74c202e95510b184d52dc97a59abd18af697267f Mon Sep 17 00:00:00 2001 From: vigney-young Date: Mon, 18 Dec 2023 19:59:57 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84readme=E9=83=A8=E5=88=86=EF=BC=8C=E5=8C=85=E6=8B=ACpyt?= =?UTF-8?q?hon=E8=84=9A=E6=9C=AC=E5=8F=82=E6=95=B0=E5=92=8Cpython=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../built-in/foundation/ChatGLM2-6B/readme.md | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md index 7a3e8117c8..9f5eb15b24 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md @@ -39,7 +39,7 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, | ------------------------------------------------------------ | ------- | ------------------------------------------------------------ | | 固件与驱动 | 23.0.0| | CANN | 7.0.0 B050 | - | - | Python | 3.9.0 | - | + | Python | 3.10.0 | - | | PyTorch | 2.1.0 | - | | Torch_AIE | 6.3.rc2 | @@ -66,7 +66,7 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, 参考: https://gitee.com/ascend/ascend-inference-ptplugin.git - 这个时候我们可以通过命令`pip show torch`找到torch的目录, 比如'/usr/local/python3/lib/python3.9/site-packages/torch', 这个路径我们定义为${TORCH_ROOT_PATH}, 后续C++编译中需要用到。 + 这个时候我们可以通过命令`pip show torch`找到torch的目录, 比如'/usr/local/python3/lib/python3.10/site-packages/torch', 这个路径我们定义为${TORCH_ROOT_PATH}, 后续C++编译中需要用到。 #### 安装推理引擎统一接口 @@ -84,7 +84,7 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, tar -zxvf Ascend-cann-torch-aie-${version}-linux_aarch64.tar.gz pip3 install torch-aie-${version}-linux_aarch64.whl ``` - 这个时候我们可以通过`pip show torch_aie`找到torch_aie的目录, 比如'/usr/local/python3/lib/python3.9/site-packages/torch_aie', 这个路径我们定义为${TORCH_AIE_PATH}, 后续C++编译中需要用到。 + 这个时候我们可以通过`pip show torch_aie`找到torch_aie的目录, 比如'/usr/local/python3/lib/python3.10/site-packages/torch_aie', 这个路径我们定义为${TORCH_AIE_PATH}, 后续C++编译中需要用到。 @@ -122,30 +122,14 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, 使用torch aie将模型源码,trace为pt文件。 ``` - python3.9 compile_model.py --device 0 + python3.10 compile_model.py --device 0 ``` compile_model的参数和默认值如下 ``` --device 0 \ # 环境使用的device_id --pretrained_model ./model/ # 源码和权重文件落盘位置 --need_trace true # 是否需要trace - ``` - 模型编译`compile`文件夹内容如下: - ```shell - ├── compile - ├──build.sh - ├──chatglm2_test.cpp - ├──CMakeLists - ├──run.sh - ``` - - 进行 C++编译,进入compile目录。 修改CMakeLists中17行的`${TORCH_AIE_PATH}`修改为 快速上手/安装torch_aie里提到的 - `${TORCH_AIE_PATH}`, 将20行`${TORCH_ROOT_PATH}`替换为 快速上手/安装依赖中的`${TORCH_ROOT_PATH}`。 - 将模型编译为ts文件。 - ``` - source /usr/local/Ascend/ascend-toolkit/set_env.sh - bash build.sh - bash run.sh + --need_compile true # 是否需要compile ``` -- Gitee From 5a0bfdf06fafa268e88ca0288f4115e15807224c Mon Sep 17 00:00:00 2001 From: vigney-young Date: Mon, 18 Dec 2023 20:08:48 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9input3=E7=9A=84shape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py index 23b56da2cc..d079272438 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py @@ -79,7 +79,7 @@ def main(): input2_min_shape = (1, 1) input2_max_shape = (1, max_seqlen) input3_min_shape = (1, 2, 0, 1, 2, 128) - input3_max_shape = (1, 2, max_seqlen, 1, 2, 128) + input3_max_shape = (28, 2, max_seqlen, 1, 2, 128) inputs.append(torch_aie.Input(min_shape = input0_min_shape, max_shape = input0_max_shape, dtype = torch.int64)) inputs.append(torch_aie.Input(min_shape = input1_min_shape, max_shape = input1_max_shape, dtype = torch.int64)) -- Gitee From 7c6053384abb22318a17ba07a464149cad379ad8 Mon Sep 17 00:00:00 2001 From: vigney-young Date: Mon, 18 Dec 2023 20:14:55 +0800 Subject: [PATCH 04/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9example.py,=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E5=8E=9F=E6=9C=AC=E7=9A=84cpu/npu=E9=80=89=E9=A1=B9?= =?UTF-8?q?=EF=BC=8C=E9=BB=98=E8=AE=A4=E9=83=BD=E8=B7=91aie,=E5=8F=AA?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=9B=B4=E6=8E=A5=E6=8C=87=E5=AE=9A=E7=B1=BB?= =?UTF-8?q?=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../built-in/foundation/ChatGLM2-6B/example.py | 12 +++++------- .../built-in/foundation/ChatGLM2-6B/readme.md | 8 ++++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py index ac1b0be2ed..41ab15b250 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py @@ -34,7 +34,7 @@ def signal_handler(signal, frame): def parse_arg(): parser = argparse.ArgumentParser() - parser.add_argument("--device", default="npu", help="cpu/npu") + parser.add_argument("--device", default=0, help="npu device") args = parser.parse_args() return args @@ -44,12 +44,10 @@ def main(): args = parse_arg() device = args.device print("device:", device) - aie_model = None - if device == "npu": - torch_aie.set_device(0) - aie_model_path = "./chatglm2_6b_batch_1_compiled.ts" - aie_model = torch.jit.load(aie_model_path) - aie_model.eval() + torch_aie.set_device(device) + aie_model_path = "./chatglm2_6b_batch_1_compiled.ts" + aie_model = torch.jit.load(aie_model_path) + aie_model.eval() print("欢迎使用 ChatGLM2-6B 模型,输入内容即可进行对话,clear 清空对话历史,stop 终止程序") while True: diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md index 9f5eb15b24..387bdad9f9 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md @@ -115,8 +115,8 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, 注意:如果设置的device_id不为0, 那么需要做一下操作。 ``` 1 `sed -i 's/npu:0/npu:${device_id}/' model/modeling_chatglm.py ` 将device_id换成自己定义的id. -2 将 run.sh里头的 `./sample 0` 替换为 `./sample ${device_id}` -3. 将 example.py中49行set_device(0)改为具体的device_id. +2 跑 compile_model中加入 --device {device_id}` +3. 跑example.py加入 --device ${device_id}. ``` 1. trace模型与模型编译。 @@ -138,6 +138,10 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, ``` python3 example.py ``` + example.py的参数和默认值如下 + ``` + --device 0 \ # 环境使用的device_id + ``` 3. 最后对话的效果如下 ``` -- Gitee From d7e2ce63543add2a61cd3d1c08a74935365ce912 Mon Sep 17 00:00:00 2001 From: vigney-young Date: Tue, 19 Dec 2023 12:01:05 +0800 Subject: [PATCH 05/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9device=5Fid=E7=9A=84?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py index 41ab15b250..e9658ec688 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py @@ -44,7 +44,7 @@ def main(): args = parse_arg() device = args.device print("device:", device) - torch_aie.set_device(device) + torch_aie.set_device(int(device)) aie_model_path = "./chatglm2_6b_batch_1_compiled.ts" aie_model = torch.jit.load(aie_model_path) aie_model.eval() -- Gitee From 444a417d4eaf8bec20886145faa5720673fd320d Mon Sep 17 00:00:00 2001 From: vigney-young Date: Tue, 19 Dec 2023 12:02:40 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9device=5Fid=E7=9A=84?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py index e9658ec688..d25f2e9863 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/example.py @@ -34,7 +34,7 @@ def signal_handler(signal, frame): def parse_arg(): parser = argparse.ArgumentParser() - parser.add_argument("--device", default=0, help="npu device") + parser.add_argument("--device", default=0, type=int, help="npu device") args = parser.parse_args() return args @@ -44,7 +44,7 @@ def main(): args = parse_arg() device = args.device print("device:", device) - torch_aie.set_device(int(device)) + torch_aie.set_device(device) aie_model_path = "./chatglm2_6b_batch_1_compiled.ts" aie_model = torch.jit.load(aie_model_path) aie_model.eval() -- Gitee From be3fcc3a0e5f4e08c2b97d82225cade5c614f052 Mon Sep 17 00:00:00 2001 From: vigney-young Date: Tue, 19 Dec 2023 15:50:42 +0800 Subject: [PATCH 07/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E5=BB=BA=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foundation/ChatGLM2-6B/compile_model.py | 2 +- .../built-in/foundation/ChatGLM2-6B/readme.md | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py index d079272438..459ce1aa28 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/compile_model.py @@ -93,7 +93,7 @@ def main(): inputs=inputs, precision_policy=_enums.PrecisionPolicy.FP32, allow_tensor_replace_int=True, - soc_version="Ascend910B4" + soc_version="Ascend910B4" # 可以为Ascend910B3或者Asend910B4,具体根据使用的环境决定。 ) print("===================== model compile success ==========================") ## save compiled result diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md index 387bdad9f9..39277eaf36 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md @@ -42,6 +42,8 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, | Python | 3.10.0 | - | | PyTorch | 2.1.0 | - | | Torch_AIE | 6.3.rc2 | + - | + | 芯片类型 | Ascend910B3/ Ascend910B4 | # 快速上手 @@ -120,7 +122,10 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, ``` 1. trace模型与模型编译。 - 使用torch aie将模型源码,trace为pt文件。 + 使用torch aie将模型源码,trace为pt文件,再通过pt插件转换为ts模型。 + 我们可选直接用python进行一体化配置,或者结合python和C++进行编译。 + 1.1 python一体化流程: + ``` python3.10 compile_model.py --device 0 ``` @@ -132,6 +137,27 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, --need_compile true # 是否需要compile ``` + 1.2 结合C++的方式进行compile,步骤如下: + 1) trace模型 + `python3.10 compile_model.py --need_compile=false` + 2)用C++compile 模型。 + ``` + 模型编译`compile`文件夹内容如下: + ```shell + ├── compile + ├──build.sh + ├──chatglm2_test.cpp + ├──CMakeLists + ├──run.sh + ``` + + 进行 C++编译,进入compile目录。 修改CMakeLists中17行的`${TORCH_AIE_PATH}`修改为 快速上手/安装torch_aie里提到的 + `${TORCH_AIE_PATH}`, 将20行`${TORCH_ROOT_PATH}`替换为 快速上手/安装依赖中的`${TORCH_ROOT_PATH}`。 + 将模型编译为ts文件。 + ``` + source /usr/local/Ascend/ascend-toolkit/set_env.sh + bash build.sh + bash run.sh 2. 开始对话验证。 -- Gitee From 9710a0763a405d0cca4f0063340757af837ead20 Mon Sep 17 00:00:00 2001 From: vigney-young Date: Tue, 19 Dec 2023 15:53:26 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9readme=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md index 39277eaf36..c2671cda59 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md @@ -42,7 +42,6 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, | Python | 3.10.0 | - | | PyTorch | 2.1.0 | - | | Torch_AIE | 6.3.rc2 | - - | | 芯片类型 | Ascend910B3/ Ascend910B4 | -- Gitee From 4f4e8062c23b4aca88d4b976d0ca7c91d7acbcfb Mon Sep 17 00:00:00 2001 From: vigney-young Date: Tue, 19 Dec 2023 15:55:33 +0800 Subject: [PATCH 09/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9readme=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../built-in/foundation/ChatGLM2-6B/readme.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md index c2671cda59..1c5e432c3d 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md @@ -119,11 +119,11 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, 2 跑 compile_model中加入 --device {device_id}` 3. 跑example.py加入 --device ${device_id}. ``` -1. trace模型与模型编译。 +### trace模型与模型编译。 使用torch aie将模型源码,trace为pt文件,再通过pt插件转换为ts模型。 我们可选直接用python进行一体化配置,或者结合python和C++进行编译。 - 1.1 python一体化流程: + #### python一体化流程 ``` python3.10 compile_model.py --device 0 @@ -136,10 +136,12 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, --need_compile true # 是否需要compile ``` - 1.2 结合C++的方式进行compile,步骤如下: - 1) trace模型 - `python3.10 compile_model.py --need_compile=false` - 2)用C++compile 模型。 + #### 结合C++的方式进行compile + 1. trace模型 + ``` + python3.10 compile_model.py --need_compile=false + ``` + 2. 用C++compile 模型。 ``` 模型编译`compile`文件夹内容如下: ```shell -- Gitee From 77a98164d764891b659faea6e9fbaad3c42bcb64 Mon Sep 17 00:00:00 2001 From: vigney-young Date: Tue, 19 Dec 2023 15:56:48 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9chatglm=E6=A0=B7?= =?UTF-8?q?=E4=BE=8B=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md index 1c5e432c3d..c0d8b90a73 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md @@ -142,7 +142,7 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, python3.10 compile_model.py --need_compile=false ``` 2. 用C++compile 模型。 - ``` + 模型编译`compile`文件夹内容如下: ```shell ├── compile @@ -159,6 +159,7 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, source /usr/local/Ascend/ascend-toolkit/set_env.sh bash build.sh bash run.sh + ``` 2. 开始对话验证。 -- Gitee From 6a7cc33c0ccaf8faeecfff4b23d17b2f294ef2c9 Mon Sep 17 00:00:00 2001 From: vigney-young Date: Tue, 19 Dec 2023 15:59:41 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E4=BF=AE=E6=94=B9chatglm=20readme?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md index c0d8b90a73..8e92f335f3 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md @@ -162,7 +162,7 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, ``` -2. 开始对话验证。 + ### 对话验证。 ``` python3 example.py ``` @@ -171,7 +171,7 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, --device 0 \ # 环境使用的device_id ``` -3. 最后对话的效果如下 + 最后对话的效果如下 ``` 欢迎使用 ChatGLM2-6B 模型,输入内容即可进行对话,clear 清空对话历史,stop 终止程序 -- Gitee From 2f8c55766e8b683e3c051ee4d2ed469bfeb3618d Mon Sep 17 00:00:00 2001 From: vigney-young Date: Wed, 20 Dec 2023 17:19:04 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E5=88=A0=E6=8E=89readme=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=AD=E6=9C=89=E5=85=B3=E8=93=9D=E5=8C=BAgit?= =?UTF-8?q?=E4=BB=93=E7=9A=84=E9=83=A8=E5=88=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md index 8e92f335f3..ffcd112788 100644 --- a/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md +++ b/AscendIE/TorchAIE/built-in/foundation/ChatGLM2-6B/readme.md @@ -63,9 +63,6 @@ ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本, ``` pip3 install -r requirement.txt ``` - 需要安装pt插件的python wheel(可根据代码仓中的readme.md操作) 和统一接口的run包。 - 参考: - https://gitee.com/ascend/ascend-inference-ptplugin.git 这个时候我们可以通过命令`pip show torch`找到torch的目录, 比如'/usr/local/python3/lib/python3.10/site-packages/torch', 这个路径我们定义为${TORCH_ROOT_PATH}, 后续C++编译中需要用到。 -- Gitee