DeepSeek在昇騰上的模型部署——優秀實踐

OSCHINA
↑點選藍字 關注我們
2024年12月26日,DeepSeek-V3橫空出世,以其卓越效能備受矚目。該模型釋出即支援昇騰,使用者可在昇騰硬體和MindIE推理引擎上實現高效推理,但在實際操作中,部署流程與常見問題困擾著不少開發者。
本文將為你詳細闡述昇騰DeepSeek模型部署的優秀實踐。
昇騰DeepSeek模型部署的常見問題及解決方案見:

DeepSeek在昇騰上的模型部署 – 常見問題及解決方案https://modelers.cn/updates/zh/modelers/20250226-deepseek-bestpractice-acend-deploy-part2/

01 硬體要求及組網

推薦參考配置如下,部署DeepSeek-V3/R1量化模型至少需要多節點Atlas 800I A2(8*64G)伺服器。
本方案以DeepSeek-R1為主進行介紹,DeepSeek-V3與R1的模型結構和引數量一致,部署方式與R1相同。

02 執行環境準備 

推薦使用映象部署
1、映象部署
昇騰官方在Ascend hub提供環境示例映象,含推理部署配套軟體以及模型執行指令碼,使用者可參考構建執行環境映象進行部署。
映象部署及啟動參照ModelZoo指南中“載入映象”章節,該指南中還包含“容器啟動”等指引: 

https://gitee.com/ascend/ModelZoo-PyTorch/tree/master/MindIE/LLM/DeepSeek/DeepSeek-R1#載入映象

映象申請/下載(含於上述指南):

https://www.hiascend.com/developer/ascendhub/detail/af85b724a7e5469ebd7ea13c3439d48f

2、裸機部署
根據MindIE安裝指南安裝軟體包和執行依賴軟體。
安裝指南:
根據指南安裝全部軟體包和環境

https://www.hiascend.com/document/detail/zh/mindie/100/envdeployment/instg/mindie_instg_0001.html

模型獲取:

https://modelers.cn/models/MindIE/DeepSeek-R1

03 權重檔案準備 

BF16權重下載:https://modelers.cn/models/State_Cloud/DeepSeek-V3-BF16
INT8量化後權重下載:https://modelers.cn/models/State_Cloud/DeepSeek-R1-W8A8/tree/main
如已下載BF16模型,也可採用以下步驟進行模型量化,權重BF16->INT8轉換預計7~8小時。
Step1:安裝ModelSlim

git clone https://gitee.com/ascend/msit.git
cd msit/msmodelslim
bash install.sh
Step2: 執行量化命令
cd msit/msmodelslim/example/DeepSeek/
python3 quant_deepseek_w8a8.py \
                –model_path {浮點權重路徑} \
                –save_path {W8A8量化權重路徑}
更多詳細量化教程請參考 DeepSeek量化文件 

https://gitee.com/ascend/msit/tree/br_noncom_MindStudio_8.0.0_POC_20251231/msmodelslim/example/DeepSeek

Msmodelslim 程式碼倉 

https://gitee.com/ascend/msit/tree/br_noncom_MindStudio_8.0.0_POC_20251231/msmodelslim

04 執行前檢查 

伺服器檢查:https://gitee.com/ascend/ModelZoo-PyTorch/tree/master/MindIE/LLM/DeepSeek/DeepSeek-R1#前置準備
軟體版本配套檢查,含:HDK、CANN、PTA、MindIE、MindStudio
1、檢查組網連結狀態
a) 檢查物理連結for i in {0..7}; do hccn_tool -i $i -lldp -g | grep Ifname; done
b) 檢查連結情況for i in {0..7}; do hccn_tool -i $i -link -g ; done
c) 檢查網路健康情況for i in {0..7}; do hccn_tool -i $i -net_health -g ; done
d) 檢視偵測ip的配置是否正確for i in {0..7}; do hccn_tool -i $i -netdetect -g ; done
e) 檢視閘道器是否配置正確for i in {0..7}; do hccn_tool -i $i -gateway -g ; done
f) 檢查NPU底層tls校驗行為一致性,建議全0for i in {0..7}; do hccn_tool -i $i -tls -g ; done | grep switch
g)  # NPU底層tls校驗行為置0操作for i in {0..7};do hccn_tool -i $i -tls -s enable 0;done
2、根據組網設定準備rank_table_file.json
使用多節點推理時,需要將包含裝置ip,伺服器ip等資訊的json檔案地址傳遞給底層通訊運算元。參考如下格式,配置rank_table_file.json:

05 模型部署與配置 

獨立模型:

https://modelers.cn/models/MindIE/DeepSeek-R1

服務化部署:
1、執行指南 

https://modelers.cn/models/MindIE/DeepSeek-R1/blob/main/README.md(服務化測試)

2、服務啟動 

https://www.hiascend.com/document/detail/zh/mindie/100/mindieservice/servicedev/mindie_service0004.html

3、介面指引 

https://www.hiascend.com/document/detail/zh/mindie/100/mindieservice/servicedev/mindie_service0062.html

06 模型執行

1、純模型測試 
模型指令碼已預製在映象中,參照以下連結即可拉起精度測試及模型測試https://modelers.cn/models/MindIE/DeepSeek-R1/blob/main/README.md (純模型測試部分)

2、服務化測試 

1. 執行指南 

https://gitee.com/ascend/ModelZoo-PyTorch/tree/master/MindIE/LLM/DeepSeek/DeepSeek-R1#服務化測試

2. 服務啟動 

https://www.hiascend.com/document/detail/zh/mindie/100/mindieservice/servicedev/mindie_service0004.html

3. 常用介面指引 

https://www.hiascend.com/document/detail/zh/mindie/100/mindieservice/servicedev/mindie_service0062.html

END
熱門文章
分享在看點贊~Orz

相關文章