diff --git a/MindIE/LLM/Llama3.2/Llama3.2-1B-Instruct-OrangePi/README.md b/MindIE/LLM/Llama3.2/Llama3.2-1B-Instruct-OrangePi/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2bdadd82320d7f5535071d55708d307da4a87388 --- /dev/null +++ b/MindIE/LLM/Llama3.2/Llama3.2-1B-Instruct-OrangePi/README.md @@ -0,0 +1,173 @@ +# Llama3.2-1B-Instruct-OrangePi + +## 约束条件 +* 在OrangePi AIpro(20T)上部署Llama3.2-1B-Instruct模型 +* 需要修改权重目录下的config.json文件,"torch_dtype"字段改为"float16", "max_position_embedding"字段改为4096 +* 由于此硬件为单卡,仅支持TP=1 + +## 权重 + +**权重下载** + +- [Llama3.2-1B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-1B-Instruct/tree/main) + +## 新建环境 + +### 1.1 安装CANN +- CANN-kernels[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-kernels-310b_8.1.RC1_linux-aarch64.run) +- CANN-toolkit[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-toolkit_8.1.RC1_linux-aarch64.run) +- 安装顺序:先安装toolkit 再安装kernel + +#### 1.1.1 安装toolkit + +- 下载 + +| cpu | 包名(其中`${version}`为实际版本) | +| ------- | ------------------------------------------------ | +| aarch64 | Ascend-cann-toolkit_${version}_linux-aarch64.run | + +- 安装 + ```bash + # 安装toolkit 以arm为例 + chmod +x Ascend-cann-toolkit_${version}_linux-aarch64.run + ./Ascend-cann-toolkit_${version}_linux-aarch64.run --install + source /usr/local/Ascend/ascend-toolkit/set_env.sh + ``` + +#### 1.1.2 安装kernel + +- 下载 + +| 包名 | +| ------------------------------------------ | +| Ascend-cann-kernels*_${version}_linux.run | + + - 根据芯片型号选择对应的安装包 + +- 安装 + ```bash + chmod +x Ascend-cann-kernels-*_${version}_linux.run + ./Ascend-cann-kernels-*_${version}_linux.run --install + ``` + +#### 1.1.3 安装加速库 +- 下载加速库 + - [下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-nnal_8.1.RC1_linux-aarch64.run)。 + + | 包名(其中`${version}`为实际版本) | + | -------------------------------------------- | + | Ascend-cann-nnal_${version}_linux-aarch64.run | + | ... | + + - 将文件放置在\${working_dir}路径下 + +- 安装 + ```shell + chmod +x Ascend-cann-nnal_*_linux-*.run + ./Ascend-cann-nnal_*_linux-*.run --install --install-path=${working_dir} + source ${working_dir}/nnal/atb/set_env.sh + ``` +- 可以使用`uname -a`指令查看服务器是x86还是aarch架构 +- 可以使用以下指令查看abi是0还是1 + ```shell + python -c "import torch; print(torch.compiled_with_cxx11_abi())" + ``` + - 若输出结果为True表示abi1,False表示abi0 + +### 1.2 安装PytorchAdapter + +先安装torch 再安装torch_npu + +#### 1.2.1 安装torch + +- 下载 + + | 包名 | + | -------------------------------------------- | + | torch-2.1.0-cp310-cp10-linux_aarch64.whl | + | ... | + + - 根据所使用的环境中的python版本以及cpu类型,选择对应版本的torch安装包。 + +- 安装 + ```bash + # 安装torch 2.1.0 的python 3.10 的arm版本为例 + pip install torch-2.1.0-cp310-cp310-linux_aarch64.whl + ``` + +#### 1.2.2 安装torch_npu + +[下载PyTorch Adapter](https://www.hiascend.com/developer/download/community/result?module=pt),安装方法: + +| 包名 | +| --------------------------- | +| pytorch_v2.1.0_py38.tar.gz | +| pytorch_v2.1.0_py39.tar.gz | +| pytorch_v2.1.0_py310.tar.gz | +| ... | + +- 安装选择与torch版本以及python版本一致的npu_torch版本 + +```bash +# 安装 torch_npu,以 torch 2.1.0,python 3.10 的版本为例 +tar -zxvf pytorch_v2.1.0_py310.tar.gz +pip install torch*_aarch64.whl +``` +### 1.3 安装开源软件依赖 +| 默认依赖 | [requirement.txt](./requirements.txt) | +- 开源软件依赖请使用下述命令进行安装: + ```bash + pip install -r ./requirements.txt + ``` + +### 1.4 安装模型仓 +使用编译好的包进行安装 + - 下载编译好的包 + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi0.tar.gz) + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi1.tar.gz) + + | 包名 | + | ------------------------------------------------------------ | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch1.11.0-abi0.tar.gz | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch2.1.0-abi1.tar.gz | + | ... | + + - 将文件放置在\${working_dir}路径下 + - 解压 + ```shell + cd ${working_dir} + mkdir MindIE-LLM + cd MindIE-LLM + tar -zxvf ../Ascend-mindie-atb-models_*_linux-*_torch*-abi*.tar.gz + ``` + - 安装atb_llm whl包 + ``` + cd ${working_dir}/MindIE-LLM + # 首次安装 + pip install atb_llm-0.0.1-py3-none-any.whl + # 更新 + pip install atb_llm-0.0.1-py3-none-any.whl --force-reinstall + ``` + + +## 纯模型推理 + +### 对话测试 +进入llm_model路径 + +```shell +cd $ATB_SPEED_HOME_PATH +``` + +执行对话测试 +-非量化场景 +```shell +python -m examples.run_fa_edge \ + --model_path ${权重路径} \ + --input_text 'What is deep learning?' \ + --max_output_length 20 \ + --is_chat_model \ +``` +## 声明 +- 本代码仓提到的数据集和模型仅作为示例,这些数据集和模型仅供您用于非商业目的,如您使用这些数据集和模型来完成示例,请您特别注意应遵守对应数据集和模型的License,如您因使用数据集或模型而产生侵权纠纷,华为不承担任何责任。 +- 如您在使用本代码仓的过程中,发现任何问题(包括但不限于功能问题、合规问题),请在本代码仓提交issue,我们将及时审视并解答。 \ No newline at end of file diff --git a/MindIE/LLM/Llama3.2/Llama3.2-3B-Instruct-OrangePi/README.md b/MindIE/LLM/Llama3.2/Llama3.2-3B-Instruct-OrangePi/README.md new file mode 100644 index 0000000000000000000000000000000000000000..896bee4ea45a49a23e79644bf123505af07ee783 --- /dev/null +++ b/MindIE/LLM/Llama3.2/Llama3.2-3B-Instruct-OrangePi/README.md @@ -0,0 +1,173 @@ +# Llama3.2-3B-Instruct-OrangePi + +## 约束条件 +* 在OrangePi AIpro(20T)上部署Llama3.2-3B-Instruct模型 +* 需要修改权重目录下的config.json文件,"torch_dtype"字段改为"float16", "max_position_embedding"字段改为4096 +* 由于此硬件为单卡,仅支持TP=1 + +## 权重 + +**权重下载** + +- [Llama3.2-3B-Instruct](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct/tree/main) + +## 新建环境 + +### 1.1 安装CANN +- CANN-kernels[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-kernels-310b_8.1.RC1_linux-aarch64.run) +- CANN-toolkit[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-toolkit_8.1.RC1_linux-aarch64.run) +- 安装顺序:先安装toolkit 再安装kernel + +#### 1.1.1 安装toolkit + +- 下载 + +| cpu | 包名(其中`${version}`为实际版本) | +| ------- | ------------------------------------------------ | +| aarch64 | Ascend-cann-toolkit_${version}_linux-aarch64.run | + +- 安装 + ```bash + # 安装toolkit 以arm为例 + chmod +x Ascend-cann-toolkit_${version}_linux-aarch64.run + ./Ascend-cann-toolkit_${version}_linux-aarch64.run --install + source /usr/local/Ascend/ascend-toolkit/set_env.sh + ``` + +#### 1.1.2 安装kernel + +- 下载 + +| 包名 | +| ------------------------------------------ | +| Ascend-cann-kernels*_${version}_linux.run | + + - 根据芯片型号选择对应的安装包 + +- 安装 + ```bash + chmod +x Ascend-cann-kernels-*_${version}_linux.run + ./Ascend-cann-kernels-*_${version}_linux.run --install + ``` + +#### 1.1.3 安装加速库 +- 下载加速库 + - [下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-nnal_8.1.RC1_linux-aarch64.run)。 + + | 包名(其中`${version}`为实际版本) | + | -------------------------------------------- | + | Ascend-cann-nnal_${version}_linux-aarch64.run | + | ... | + + - 将文件放置在\${working_dir}路径下 + +- 安装 + ```shell + chmod +x Ascend-cann-nnal_*_linux-*.run + ./Ascend-cann-nnal_*_linux-*.run --install --install-path=${working_dir} + source ${working_dir}/nnal/atb/set_env.sh + ``` +- 可以使用`uname -a`指令查看服务器是x86还是aarch架构 +- 可以使用以下指令查看abi是0还是1 + ```shell + python -c "import torch; print(torch.compiled_with_cxx11_abi())" + ``` + - 若输出结果为True表示abi1,False表示abi0 + +### 1.2 安装PytorchAdapter + +先安装torch 再安装torch_npu + +#### 1.2.1 安装torch + +- 下载 + + | 包名 | + | -------------------------------------------- | + | torch-2.1.0-cp310-cp10-linux_aarch64.whl | + | ... | + + - 根据所使用的环境中的python版本以及cpu类型,选择对应版本的torch安装包。 + +- 安装 + ```bash + # 安装torch 2.1.0 的python 3.10 的arm版本为例 + pip install torch-2.1.0-cp310-cp310-linux_aarch64.whl + ``` + +#### 1.2.2 安装torch_npu + +[下载PyTorch Adapter](https://www.hiascend.com/developer/download/community/result?module=pt),安装方法: + +| 包名 | +| --------------------------- | +| pytorch_v2.1.0_py38.tar.gz | +| pytorch_v2.1.0_py39.tar.gz | +| pytorch_v2.1.0_py310.tar.gz | +| ... | + +- 安装选择与torch版本以及python版本一致的npu_torch版本 + +```bash +# 安装 torch_npu,以 torch 2.1.0,python 3.10 的版本为例 +tar -zxvf pytorch_v2.1.0_py310.tar.gz +pip install torch*_aarch64.whl +``` +### 1.3 安装开源软件依赖 +| 默认依赖 | [requirement.txt](./requirements.txt) | +- 开源软件依赖请使用下述命令进行安装: + ```bash + pip install -r ./requirements.txt + ``` + +### 1.4 安装模型仓 +使用编译好的包进行安装 + - 下载编译好的包 + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi0.tar.gz) + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi1.tar.gz) + + | 包名 | + | ------------------------------------------------------------ | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch1.11.0-abi0.tar.gz | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch2.1.0-abi1.tar.gz | + | ... | + + - 将文件放置在\${working_dir}路径下 + - 解压 + ```shell + cd ${working_dir} + mkdir MindIE-LLM + cd MindIE-LLM + tar -zxvf ../Ascend-mindie-atb-models_*_linux-*_torch*-abi*.tar.gz + ``` + - 安装atb_llm whl包 + ``` + cd ${working_dir}/MindIE-LLM + # 首次安装 + pip install atb_llm-0.0.1-py3-none-any.whl + # 更新 + pip install atb_llm-0.0.1-py3-none-any.whl --force-reinstall + ``` + + +## 纯模型推理 + +### 对话测试 +进入llm_model路径 + +```shell +cd $ATB_SPEED_HOME_PATH +``` + +执行对话测试 +-非量化场景 +```shell +python -m examples.run_fa_edge \ + --model_path ${权重路径} \ + --input_text 'What is deep learning?' \ + --max_output_length 20 \ + --is_chat_model \ +``` +## 声明 +- 本代码仓提到的数据集和模型仅作为示例,这些数据集和模型仅供您用于非商业目的,如您使用这些数据集和模型来完成示例,请您特别注意应遵守对应数据集和模型的License,如您因使用数据集或模型而产生侵权纠纷,华为不承担任何责任。 +- 如您在使用本代码仓的过程中,发现任何问题(包括但不限于功能问题、合规问题),请在本代码仓提交issue,我们将及时审视并解答。 \ No newline at end of file diff --git a/MindIE/LLM/Qwen3/Qwen3-0.6B-OrangePi/README.md b/MindIE/LLM/Qwen3/Qwen3-0.6B-OrangePi/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0a995767c16a462bcfc2884a34ae217c1e2a6d90 --- /dev/null +++ b/MindIE/LLM/Qwen3/Qwen3-0.6B-OrangePi/README.md @@ -0,0 +1,181 @@ +# Qwen3-0.6B-OrangePi +## 简介 +Qwen3是Qwen系列中最新一代的大型语言模型,提供了密集和混合专家(MoE)模型的全面套件。基于广泛的训练,Qwen3在推理、指令遵循、代理功能和多语言支持方面取得了很大的进展,主要具有以下功能: + +- **思维模式**(用于复杂的逻辑推理、数学和编码)和**非思维模式**(用于高效、通用的对话)在单个模型内无缝切换,确保跨各种场景的最佳性能。 +- **增强了推理能力**在数学、代码生成和常识逻辑推理方面超过了之前的QwQ(思维模式)和Qwen2.5(非思维模式)。 +- **人类偏好调整**,擅长创意写作、角色扮演、多轮对话和指令跟随,提供更自然、更吸引人、更沉浸式的对话体验。 +- **在代理能力方面的专业知识**,能够在思考模式和非思考模式下与外部工具精确集成,在基于代理的复杂任务中实现开源模型中的领先性能。 +- **支持100多种语言和方言***具有强大多语言教学能力和翻译能力。 + +## 约束条件 +* 在OrangePi AIpro(20T)上部署Qwen3-0.6B模型 +* 需要修改权重目录下的config.json文件,"torch_dtype"字段改为"float16", "max_position_embedding"字段改为4096, 删除“rope_scaling”字段 +* 由于此硬件为单卡,仅支持TP=1 + +## 权重 + +**权重下载** + +- [Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B/tree/main) + +## 新建环境 + +### 1.1 安装CANN +- CANN-kernels[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-kernels-310b_8.1.RC1_linux-aarch64.run) +- CANN-toolkit[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-toolkit_8.1.RC1_linux-aarch64.run) +- 安装顺序:先安装toolkit 再安装kernel + +#### 1.1.1 安装toolkit + +- 下载 + +| cpu | 包名(其中`${version}`为实际版本) | +| ------- | ------------------------------------------------ | +| aarch64 | Ascend-cann-toolkit_${version}_linux-aarch64.run | + +- 安装 + ```bash + # 安装toolkit 以arm为例 + chmod +x Ascend-cann-toolkit_${version}_linux-aarch64.run + ./Ascend-cann-toolkit_${version}_linux-aarch64.run --install + source /usr/local/Ascend/ascend-toolkit/set_env.sh + ``` + +#### 1.1.2 安装kernel + +- 下载 + +| 包名 | +| ------------------------------------------ | +| Ascend-cann-kernels*_${version}_linux.run | + + - 根据芯片型号选择对应的安装包 + +- 安装 + ```bash + chmod +x Ascend-cann-kernels-*_${version}_linux.run + ./Ascend-cann-kernels-*_${version}_linux.run --install + ``` + +#### 1.1.3 安装加速库 +- 下载加速库 + - [下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-nnal_8.1.RC1_linux-aarch64.run)。 + + | 包名(其中`${version}`为实际版本) | + | -------------------------------------------- | + | Ascend-cann-nnal_${version}_linux-aarch64.run | + | ... | + + - 将文件放置在\${working_dir}路径下 + +- 安装 + ```shell + chmod +x Ascend-cann-nnal_*_linux-*.run + ./Ascend-cann-nnal_*_linux-*.run --install --install-path=${working_dir} + source ${working_dir}/nnal/atb/set_env.sh + ``` +- 可以使用`uname -a`指令查看服务器是x86还是aarch架构 +- 可以使用以下指令查看abi是0还是1 + ```shell + python -c "import torch; print(torch.compiled_with_cxx11_abi())" + ``` + - 若输出结果为True表示abi1,False表示abi0 + +### 1.2 安装PytorchAdapter + +先安装torch 再安装torch_npu + +#### 1.2.1 安装torch + +- 下载 + + | 包名 | + | -------------------------------------------- | + | torch-2.1.0-cp310-cp10-linux_aarch64.whl | + | ... | + + - 根据所使用的环境中的python版本以及cpu类型,选择对应版本的torch安装包。 + +- 安装 + ```bash + # 安装torch 2.1.0 的python 3.10 的arm版本为例 + pip install torch-2.1.0-cp310-cp310-linux_aarch64.whl + ``` + +#### 1.2.2 安装torch_npu + +[下载PyTorch Adapter](https://www.hiascend.com/developer/download/community/result?module=pt),安装方法: + +| 包名 | +| --------------------------- | +| pytorch_v2.1.0_py38.tar.gz | +| pytorch_v2.1.0_py39.tar.gz | +| pytorch_v2.1.0_py310.tar.gz | +| ... | + +- 安装选择与torch版本以及python版本一致的npu_torch版本 + +```bash +# 安装 torch_npu,以 torch 2.1.0,python 3.10 的版本为例 +tar -zxvf pytorch_v2.1.0_py310.tar.gz +pip install torch*_aarch64.whl +``` +### 1.3 安装开源软件依赖 +| 默认依赖 | [requirement.txt](./requirements.txt) | +- 开源软件依赖请使用下述命令进行安装: + ```bash + pip install -r ./requirements.txt + ``` + +### 1.4 安装模型仓 +使用编译好的包进行安装 + - 下载编译好的包 + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi0.tar.gz) + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi1.tar.gz) + + | 包名 | + | ------------------------------------------------------------ | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch1.11.0-abi0.tar.gz | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch2.1.0-abi1.tar.gz | + | ... | + + - 将文件放置在\${working_dir}路径下 + - 解压 + ```shell + cd ${working_dir} + mkdir MindIE-LLM + cd MindIE-LLM + tar -zxvf ../Ascend-mindie-atb-models_*_linux-*_torch*-abi*.tar.gz + ``` + - 安装atb_llm whl包 + ``` + cd ${working_dir}/MindIE-LLM + # 首次安装 + pip install atb_llm-0.0.1-py3-none-any.whl + # 更新 + pip install atb_llm-0.0.1-py3-none-any.whl --force-reinstall + ``` + + +## 纯模型推理 + +### 对话测试 +进入llm_model路径 + +```shell +cd $ATB_SPEED_HOME_PATH +``` + +执行对话测试 +-非量化场景 +```shell +python -m examples.run_fa_edge \ + --model_path ${权重路径} \ + --input_text 'What is deep learning?' \ + --max_output_length 20 \ + --is_chat_model \ +``` +## 声明 +- 本代码仓提到的数据集和模型仅作为示例,这些数据集和模型仅供您用于非商业目的,如您使用这些数据集和模型来完成示例,请您特别注意应遵守对应数据集和模型的License,如您因使用数据集或模型而产生侵权纠纷,华为不承担任何责任。 +- 如您在使用本代码仓的过程中,发现任何问题(包括但不限于功能问题、合规问题),请在本代码仓提交issue,我们将及时审视并解答。 \ No newline at end of file diff --git a/MindIE/LLM/Qwen3/Qwen3-1.7B-OrangePi/README.md b/MindIE/LLM/Qwen3/Qwen3-1.7B-OrangePi/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e637d949811f6f5ca062abe9752d158689aa226d --- /dev/null +++ b/MindIE/LLM/Qwen3/Qwen3-1.7B-OrangePi/README.md @@ -0,0 +1,181 @@ +# Qwen3-1.7B-OrangePi +## 简介 +Qwen3是Qwen系列中最新一代的大型语言模型,提供了密集和混合专家(MoE)模型的全面套件。基于广泛的训练,Qwen3在推理、指令遵循、代理功能和多语言支持方面取得了很大的进展,主要具有以下功能: + +- **思维模式**(用于复杂的逻辑推理、数学和编码)和**非思维模式**(用于高效、通用的对话)在单个模型内无缝切换,确保跨各种场景的最佳性能。 +- **增强了推理能力**在数学、代码生成和常识逻辑推理方面超过了之前的QwQ(思维模式)和Qwen2.5(非思维模式)。 +- **人类偏好调整**,擅长创意写作、角色扮演、多轮对话和指令跟随,提供更自然、更吸引人、更沉浸式的对话体验。 +- **在代理能力方面的专业知识**,能够在思考模式和非思考模式下与外部工具精确集成,在基于代理的复杂任务中实现开源模型中的领先性能。 +- **支持100多种语言和方言***具有强大多语言教学能力和翻译能力。 + +## 约束条件 +* 在OrangePi AIpro(20T)上部署Qwen3-1.7B模型 +* 需要修改权重目录下的config.json文件,"torch_dtype"字段改为"float16", "max_position_embedding"字段改为4096, 删除“rope_scaling”字段 +* 由于此硬件为单卡,仅支持TP=1 + +## 权重 + +**权重下载** + +- [Qwen3-1.7B](https://huggingface.co/Qwen/Qwen3-1.7B/tree/main) + +## 新建环境 + +### 1.1 安装CANN +- CANN-kernels[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-kernels-310b_8.1.RC1_linux-aarch64.run) +- CANN-toolkit[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-toolkit_8.1.RC1_linux-aarch64.run) +- 安装顺序:先安装toolkit 再安装kernel + +#### 1.1.1 安装toolkit + +- 下载 + +| cpu | 包名(其中`${version}`为实际版本) | +| ------- | ------------------------------------------------ | +| aarch64 | Ascend-cann-toolkit_${version}_linux-aarch64.run | + +- 安装 + ```bash + # 安装toolkit 以arm为例 + chmod +x Ascend-cann-toolkit_${version}_linux-aarch64.run + ./Ascend-cann-toolkit_${version}_linux-aarch64.run --install + source /usr/local/Ascend/ascend-toolkit/set_env.sh + ``` + +#### 1.1.2 安装kernel + +- 下载 + +| 包名 | +| ------------------------------------------ | +| Ascend-cann-kernels*_${version}_linux.run | + + - 根据芯片型号选择对应的安装包 + +- 安装 + ```bash + chmod +x Ascend-cann-kernels-*_${version}_linux.run + ./Ascend-cann-kernels-*_${version}_linux.run --install + ``` + +#### 1.1.3 安装加速库 +- 下载加速库 + - [下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-nnal_8.1.RC1_linux-aarch64.run)。 + + | 包名(其中`${version}`为实际版本) | + | -------------------------------------------- | + | Ascend-cann-nnal_${version}_linux-aarch64.run | + | ... | + + - 将文件放置在\${working_dir}路径下 + +- 安装 + ```shell + chmod +x Ascend-cann-nnal_*_linux-*.run + ./Ascend-cann-nnal_*_linux-*.run --install --install-path=${working_dir} + source ${working_dir}/nnal/atb/set_env.sh + ``` +- 可以使用`uname -a`指令查看服务器是x86还是aarch架构 +- 可以使用以下指令查看abi是0还是1 + ```shell + python -c "import torch; print(torch.compiled_with_cxx11_abi())" + ``` + - 若输出结果为True表示abi1,False表示abi0 + +### 1.2 安装PytorchAdapter + +先安装torch 再安装torch_npu + +#### 1.2.1 安装torch + +- 下载 + + | 包名 | + | -------------------------------------------- | + | torch-2.1.0-cp310-cp10-linux_aarch64.whl | + | ... | + + - 根据所使用的环境中的python版本以及cpu类型,选择对应版本的torch安装包。 + +- 安装 + ```bash + # 安装torch 2.1.0 的python 3.10 的arm版本为例 + pip install torch-2.1.0-cp310-cp310-linux_aarch64.whl + ``` + +#### 1.2.2 安装torch_npu + +[下载PyTorch Adapter](https://www.hiascend.com/developer/download/community/result?module=pt),安装方法: + +| 包名 | +| --------------------------- | +| pytorch_v2.1.0_py38.tar.gz | +| pytorch_v2.1.0_py39.tar.gz | +| pytorch_v2.1.0_py310.tar.gz | +| ... | + +- 安装选择与torch版本以及python版本一致的npu_torch版本 + +```bash +# 安装 torch_npu,以 torch 2.1.0,python 3.10 的版本为例 +tar -zxvf pytorch_v2.1.0_py310.tar.gz +pip install torch*_aarch64.whl +``` +### 1.3 安装开源软件依赖 +| 默认依赖 | [requirement.txt](./requirements.txt) | +- 开源软件依赖请使用下述命令进行安装: + ```bash + pip install -r ./requirements.txt + ``` + +### 1.4 安装模型仓 +使用编译好的包进行安装 + - 下载编译好的包 + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi0.tar.gz) + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi1.tar.gz) + + | 包名 | + | ------------------------------------------------------------ | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch1.11.0-abi0.tar.gz | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch2.1.0-abi1.tar.gz | + | ... | + + - 将文件放置在\${working_dir}路径下 + - 解压 + ```shell + cd ${working_dir} + mkdir MindIE-LLM + cd MindIE-LLM + tar -zxvf ../Ascend-mindie-atb-models_*_linux-*_torch*-abi*.tar.gz + ``` + - 安装atb_llm whl包 + ``` + cd ${working_dir}/MindIE-LLM + # 首次安装 + pip install atb_llm-0.0.1-py3-none-any.whl + # 更新 + pip install atb_llm-0.0.1-py3-none-any.whl --force-reinstall + ``` + + +## 纯模型推理 + +### 对话测试 +进入llm_model路径 + +```shell +cd $ATB_SPEED_HOME_PATH +``` + +执行对话测试 +-非量化场景 +```shell +python -m examples.run_fa_edge \ + --model_path ${权重路径} \ + --input_text 'What is deep learning?' \ + --max_output_length 20 \ + --is_chat_model \ +``` +## 声明 +- 本代码仓提到的数据集和模型仅作为示例,这些数据集和模型仅供您用于非商业目的,如您使用这些数据集和模型来完成示例,请您特别注意应遵守对应数据集和模型的License,如您因使用数据集或模型而产生侵权纠纷,华为不承担任何责任。 +- 如您在使用本代码仓的过程中,发现任何问题(包括但不限于功能问题、合规问题),请在本代码仓提交issue,我们将及时审视并解答。 \ No newline at end of file diff --git a/MindIE/LLM/Qwen3/Qwen3-4B-OrangePi/README.md b/MindIE/LLM/Qwen3/Qwen3-4B-OrangePi/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1d39b06303813138764ad0b744ee8a4bf2e406fd --- /dev/null +++ b/MindIE/LLM/Qwen3/Qwen3-4B-OrangePi/README.md @@ -0,0 +1,181 @@ +# Qwen3-4B-OrangePi +## 简介 +Qwen3是Qwen系列中最新一代的大型语言模型,提供了密集和混合专家(MoE)模型的全面套件。基于广泛的训练,Qwen3在推理、指令遵循、代理功能和多语言支持方面取得了很大的进展,主要具有以下功能: + +- **思维模式**(用于复杂的逻辑推理、数学和编码)和**非思维模式**(用于高效、通用的对话)在单个模型内无缝切换,确保跨各种场景的最佳性能。 +- **增强了推理能力**在数学、代码生成和常识逻辑推理方面超过了之前的QwQ(思维模式)和Qwen2.5(非思维模式)。 +- **人类偏好调整**,擅长创意写作、角色扮演、多轮对话和指令跟随,提供更自然、更吸引人、更沉浸式的对话体验。 +- **在代理能力方面的专业知识**,能够在思考模式和非思考模式下与外部工具精确集成,在基于代理的复杂任务中实现开源模型中的领先性能。 +- **支持100多种语言和方言***具有强大多语言教学能力和翻译能力。 + +## 约束条件 +* 在OrangePi AIpro(20T)上部署Qwen3-4B模型 +* 需要修改权重目录下的config.json文件,"torch_dtype"字段改为"float16", "max_position_embedding"字段改为4096, 删除“rope_scaling”字段 +* 由于此硬件为单卡,仅支持TP=1 + +## 权重 + +**权重下载** + +- [Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B/tree/main) + +## 新建环境 + +### 1.1 安装CANN +- CANN-kernels[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-kernels-310b_8.1.RC1_linux-aarch64.run) +- CANN-toolkit[下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-toolkit_8.1.RC1_linux-aarch64.run) +- 安装顺序:先安装toolkit 再安装kernel + +#### 1.1.1 安装toolkit + +- 下载 + +| cpu | 包名(其中`${version}`为实际版本) | +| ------- | ------------------------------------------------ | +| aarch64 | Ascend-cann-toolkit_${version}_linux-aarch64.run | + +- 安装 + ```bash + # 安装toolkit 以arm为例 + chmod +x Ascend-cann-toolkit_${version}_linux-aarch64.run + ./Ascend-cann-toolkit_${version}_linux-aarch64.run --install + source /usr/local/Ascend/ascend-toolkit/set_env.sh + ``` + +#### 1.1.2 安装kernel + +- 下载 + +| 包名 | +| ------------------------------------------ | +| Ascend-cann-kernels*_${version}_linux.run | + + - 根据芯片型号选择对应的安装包 + +- 安装 + ```bash + chmod +x Ascend-cann-kernels-*_${version}_linux.run + ./Ascend-cann-kernels-*_${version}_linux.run --install + ``` + +#### 1.1.3 安装加速库 +- 下载加速库 + - [下载链接](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-cann-nnal_8.1.RC1_linux-aarch64.run)。 + + | 包名(其中`${version}`为实际版本) | + | -------------------------------------------- | + | Ascend-cann-nnal_${version}_linux-aarch64.run | + | ... | + + - 将文件放置在\${working_dir}路径下 + +- 安装 + ```shell + chmod +x Ascend-cann-nnal_*_linux-*.run + ./Ascend-cann-nnal_*_linux-*.run --install --install-path=${working_dir} + source ${working_dir}/nnal/atb/set_env.sh + ``` +- 可以使用`uname -a`指令查看服务器是x86还是aarch架构 +- 可以使用以下指令查看abi是0还是1 + ```shell + python -c "import torch; print(torch.compiled_with_cxx11_abi())" + ``` + - 若输出结果为True表示abi1,False表示abi0 + +### 1.2 安装PytorchAdapter + +先安装torch 再安装torch_npu + +#### 1.2.1 安装torch + +- 下载 + + | 包名 | + | -------------------------------------------- | + | torch-2.1.0-cp310-cp10-linux_aarch64.whl | + | ... | + + - 根据所使用的环境中的python版本以及cpu类型,选择对应版本的torch安装包。 + +- 安装 + ```bash + # 安装torch 2.1.0 的python 3.10 的arm版本为例 + pip install torch-2.1.0-cp310-cp310-linux_aarch64.whl + ``` + +#### 1.2.2 安装torch_npu + +[下载PyTorch Adapter](https://www.hiascend.com/developer/download/community/result?module=pt),安装方法: + +| 包名 | +| --------------------------- | +| pytorch_v2.1.0_py38.tar.gz | +| pytorch_v2.1.0_py39.tar.gz | +| pytorch_v2.1.0_py310.tar.gz | +| ... | + +- 安装选择与torch版本以及python版本一致的npu_torch版本 + +```bash +# 安装 torch_npu,以 torch 2.1.0,python 3.10 的版本为例 +tar -zxvf pytorch_v2.1.0_py310.tar.gz +pip install torch*_aarch64.whl +``` +### 1.3 安装开源软件依赖 +| 默认依赖 | [requirement.txt](./requirements.txt) | +- 开源软件依赖请使用下述命令进行安装: + ```bash + pip install -r ./requirements.txt + ``` + +### 1.4 安装模型仓 +使用编译好的包进行安装 + - 下载编译好的包 + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi0.tar.gz) + - [下载链接-abi0](https://mindie.obs.cn-north-4.myhuaweicloud.com/xiangchengpai_20250211/Ascend-mindie-atb-models_2.0.RC1_linux-aarch64_py310_torch2.1.0-abi1.tar.gz) + + | 包名 | + | ------------------------------------------------------------ | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch1.11.0-abi0.tar.gz | + | Ascend-mindie-atb-models_1.0.RC1_linux-aarch64_torch2.1.0-abi1.tar.gz | + | ... | + + - 将文件放置在\${working_dir}路径下 + - 解压 + ```shell + cd ${working_dir} + mkdir MindIE-LLM + cd MindIE-LLM + tar -zxvf ../Ascend-mindie-atb-models_*_linux-*_torch*-abi*.tar.gz + ``` + - 安装atb_llm whl包 + ``` + cd ${working_dir}/MindIE-LLM + # 首次安装 + pip install atb_llm-0.0.1-py3-none-any.whl + # 更新 + pip install atb_llm-0.0.1-py3-none-any.whl --force-reinstall + ``` + + +## 纯模型推理 + +### 对话测试 +进入llm_model路径 + +```shell +cd $ATB_SPEED_HOME_PATH +``` + +执行对话测试 +-非量化场景 +```shell +python -m examples.run_fa_edge \ + --model_path ${权重路径} \ + --input_text 'What is deep learning?' \ + --max_output_length 20 \ + --is_chat_model \ +``` +## 声明 +- 本代码仓提到的数据集和模型仅作为示例,这些数据集和模型仅供您用于非商业目的,如您使用这些数据集和模型来完成示例,请您特别注意应遵守对应数据集和模型的License,如您因使用数据集或模型而产生侵权纠纷,华为不承担任何责任。 +- 如您在使用本代码仓的过程中,发现任何问题(包括但不限于功能问题、合规问题),请在本代码仓提交issue,我们将及时审视并解答。 \ No newline at end of file diff --git a/MindIE/MultiModal/Janus-Pro-1B-OrangePi/ LICENSE-MODEL b/MindIE/MultiModal/Janus-Pro-1B-OrangePi/ LICENSE-MODEL new file mode 100644 index 0000000000000000000000000000000000000000..8072f462d268178ef095af3493ab64369092e776 --- /dev/null +++ b/MindIE/MultiModal/Janus-Pro-1B-OrangePi/ LICENSE-MODEL @@ -0,0 +1,91 @@ +DEEPSEEK LICENSE AGREEMENT + +Version 1.0, 23 October 2023 + +Copyright (c) 2023 DeepSeek + +Section I: PREAMBLE + +Large generative models are being widely adopted and used, and have the potential to transform the way individuals conceive and benefit from AI or ML technologies. + +Notwithstanding the current and potential benefits that these artifacts can bring to society at large, there are also concerns about potential misuses of them, either due to their technical limitations or ethical considerations. + +In short, this license strives for both the open and responsible downstream use of the accompanying model. When it comes to the open character, we took inspiration from open source permissive licenses regarding the grant of IP rights. Referring to the downstream responsible use, we added use-based restrictions not permitting the use of the model in very specific scenarios, in order for the licensor to be able to enforce the license in case potential misuses of the Model may occur. At the same time, we strive to promote open and responsible research on generative models for content generation. + +Even though downstream derivative versions of the model could be released under different licensing terms, the latter will always have to include - at minimum - the same use-based restrictions as the ones in the original license (this license). We believe in the intersection between open and responsible AI development; thus, this agreement aims to strike a balance between both in order to enable responsible open-science in the field of AI. + +This License governs the use of the model (and its derivatives) and is informed by the model card associated with the model. + +NOW THEREFORE, You and DeepSeek agree as follows: + +1. Definitions +"License" means the terms and conditions for use, reproduction, and Distribution as defined in this document. +"Data" means a collection of information and/or content extracted from the dataset used with the Model, including to train, pretrain, or otherwise evaluate the Model. The Data is not licensed under this License. +"Output" means the results of operating a Model as embodied in informational content resulting therefrom. +"Model" means any accompanying machine-learning based assemblies (including checkpoints), consisting of learnt weights, parameters (including optimizer states), corresponding to the model architecture as embodied in the Complementary Material, that have been trained or tuned, in whole or in part on the Data, using the Complementary Material. +"Derivatives of the Model" means all modifications to the Model, works based on the Model, or any other model which is created or initialized by transfer of patterns of the weights, parameters, activations or output of the Model, to the other model, in order to cause the other model to perform similarly to the Model, including - but not limited to - distillation methods entailing the use of intermediate data representations or methods based on the generation of synthetic data by the Model for training the other model. +"Complementary Material" means the accompanying source code and scripts used to define, run, load, benchmark or evaluate the Model, and used to prepare data for training or evaluation, if any. This includes any accompanying documentation, tutorials, examples, etc, if any. +"Distribution" means any transmission, reproduction, publication or other sharing of the Model or Derivatives of the Model to a third party, including providing the Model as a hosted service made available by electronic or other remote means - e.g. API-based or web access. +"DeepSeek" (or "we") means Beijing DeepSeek Artificial Intelligence Fundamental Technology Research Co., Ltd., Hangzhou DeepSeek Artificial Intelligence Fundamental Technology Research Co., Ltd. and/or any of their affiliates. +"You" (or "Your") means an individual or Legal Entity exercising permissions granted by this License and/or making use of the Model for whichever purpose and in any field of use, including usage of the Model in an end-use application - e.g. chatbot, translator, etc. +"Third Parties" means individuals or legal entities that are not under common control with DeepSeek or You. + +Section II: INTELLECTUAL PROPERTY RIGHTS + +Both copyright and patent grants apply to the Model, Derivatives of the Model and Complementary Material. The Model and Derivatives of the Model are subject to additional terms as described in Section III. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, DeepSeek hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare, publicly display, publicly perform, sublicense, and distribute the Complementary Material, the Model, and Derivatives of the Model. + +3. Grant of Patent License. Subject to the terms and conditions of this License and where and as applicable, DeepSeek hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this paragraph) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Model and the Complementary Material, where such license applies only to those patent claims licensable by DeepSeek that are necessarily infringed by its contribution(s). If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Model and/or Complementary Material constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for the Model and/or works shall terminate as of the date such litigation is asserted or filed. + + +Section III: CONDITIONS OF USAGE, DISTRIBUTION AND REDISTRIBUTION + +4. Distribution and Redistribution. You may host for Third Party remote access purposes (e.g. software-as-a-service), reproduce and distribute copies of the Model or Derivatives of the Model thereof in any medium, with or without modifications, provided that You meet the following conditions: +a. Use-based restrictions as referenced in paragraph 5 MUST be included as an enforceable provision by You in any type of legal agreement (e.g. a license) governing the use and/or distribution of the Model or Derivatives of the Model, and You shall give notice to subsequent users You Distribute to, that the Model or Derivatives of the Model are subject to paragraph 5. This provision does not apply to the use of Complementary Material. +b. You must give any Third Party recipients of the Model or Derivatives of the Model a copy of this License; +c. You must cause any modified files to carry prominent notices stating that You changed the files; +d. You must retain all copyright, patent, trademark, and attribution notices excluding those notices that do not pertain to any part of the Model, Derivatives of the Model. +e. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions - respecting paragraph 4.a. – for use, reproduction, or Distribution of Your modifications, or for any such Derivatives of the Model as a whole, provided Your use, reproduction, and Distribution of the Model otherwise complies with the conditions stated in this License. + +5. Use-based restrictions. The restrictions set forth in Attachment A are considered Use-based restrictions. Therefore You cannot use the Model and the Derivatives of the Model for the specified restricted uses. You may use the Model subject to this License, including only for lawful purposes and in accordance with the License. Use may include creating any content with, finetuning, updating, running, training, evaluating and/or reparametrizing the Model. You shall require all of Your users who use the Model or a Derivative of the Model to comply with the terms of this paragraph (paragraph 5). + +6. The Output You Generate. Except as set forth herein, DeepSeek claims no rights in the Output You generate using the Model. You are accountable for the Output you generate and its subsequent uses. No use of the output can contravene any provision as stated in the License. + +Section IV: OTHER PROVISIONS + +7. Updates and Runtime Restrictions. To the maximum extent permitted by law, DeepSeek reserves the right to restrict (remotely or otherwise) usage of the Model in violation of this License. + +8. Trademarks and related. Nothing in this License permits You to make use of DeepSeek’ trademarks, trade names, logos or to otherwise suggest endorsement or misrepresent the relationship between the parties; and any rights not expressly granted herein are reserved by DeepSeek. + +9. Personal information, IP rights and related. This Model may contain personal information and works with IP rights. You commit to complying with applicable laws and regulations in the handling of personal information and the use of such works. Please note that DeepSeek's license granted to you to use the Model does not imply that you have obtained a legitimate basis for processing the related information or works. As an independent personal information processor and IP rights user, you need to ensure full compliance with relevant legal and regulatory requirements when handling personal information and works with IP rights that may be contained in the Model, and are willing to assume solely any risks and consequences that may arise from that. + +10. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, DeepSeek provides the Model and the Complementary Material on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Model, Derivatives of the Model, and the Complementary Material and assume any risks associated with Your exercise of permissions under this License. + +11. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall DeepSeek be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Model and the Complementary Material (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if DeepSeek has been advised of the possibility of such damages. + +12. Accepting Warranty or Additional Liability. While redistributing the Model, Derivatives of the Model and the Complementary Material thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of DeepSeek, and only if You agree to indemnify, defend, and hold DeepSeek harmless for any liability incurred by, or claims asserted against, DeepSeek by reason of your accepting any such warranty or additional liability. + +13. If any provision of this License is held to be invalid, illegal or unenforceable, the remaining provisions shall be unaffected thereby and remain valid as if such provision had not been set forth herein. + +14. Governing Law and Jurisdiction. This agreement will be governed and construed under PRC laws without regard to choice of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this agreement. The courts located in the domicile of Hangzhou DeepSeek Artificial Intelligence Fundamental Technology Research Co., Ltd. shall have exclusive jurisdiction of any dispute arising out of this agreement. + +END OF TERMS AND CONDITIONS + +Attachment A + +Use Restrictions + +You agree not to use the Model or Derivatives of the Model: + +- In any way that violates any applicable national or international law or regulation or infringes upon the lawful rights and interests of any third party; +- For military use in any way; +- For the purpose of exploiting, harming or attempting to exploit or harm minors in any way; +- To generate or disseminate verifiably false information and/or content with the purpose of harming others; +- To generate or disseminate inappropriate content subject to applicable regulatory requirements; +- To generate or disseminate personal identifiable information without due authorization or for unreasonable use; +- To defame, disparage or otherwise harass others; +- For fully automated decision making that adversely impacts an individual’s legal rights or otherwise creates or modifies a binding, enforceable obligation; +- For any use intended to or which has the effect of discriminating against or harming individuals or groups based on online or offline social behavior or known or predicted personal or personality characteristics; +- To exploit any of the vulnerabilities of a specific group of persons based on their age, social, physical or mental characteristics, in order to materially distort the behavior of a person pertaining to that group in a manner that causes or is likely to cause that person or another person physical or psychological harm; +- For any use intended to or which has the effect of discriminating against individuals or groups based on legally protected characteristics or categories.