openPangu-R-72B-2512-Int8与Ascend A3硬件完美融合:部署最佳实践

【免费下载链接】openPangu-R-72B-2512-Int8 昇腾原生的openPangu-R-72B-2512语言模型量化版本 【免费下载链接】openPangu-R-72B-2512-Int8 项目地址: https://ai.gitcode.com/ascend-tribe/openPangu-R-72B-2512-Int8

openPangu-R-72B-2512-Int8是昇腾原生的语言模型量化版本,采用动态per-token量化技术,能减少约50%显存占用,提升超20%吞吐,同时保持综合精度损失小于1%。本文将详细介绍如何在Ascend A3硬件上高效部署这一强大模型。

为什么选择openPangu-R-72B-2512-Int8与Ascend A3组合?

openPangu-R-72B-2512-Int8作为基于昇腾集群训练的MoE模型,总参数量74B,激活参数量15B,采用80选8的专家选择机制,支持128k长序列处理。其量化版本特别优化了与昇腾硬件的兼容性,而Ascend A3作为新一代AI加速卡,提供了强大的计算能力和能效比,两者结合可实现高性能、低延迟的AI推理服务。

核心优势概览

  • 高效量化技术:动态per-token量化减少显存占用,提升吞吐
  • 深度优化:在注意力机制中引入参数式Sink Token技术,训练中最大激活值从$10^3$降至$10^2$量级
  • 灵活推理模式:支持快慢思考两种模式切换,慢思考模式下还支持"低"和"高"两种推理深度

硬件环境准备

部署openPangu-R-72B-2512-Int8仅需1台Atlas 800T A3机器中的4个die,实现了高效的PD混部方案。这种配置既保证了模型运行所需的计算资源,又避免了硬件资源的浪费。

部署步骤详解

1. 环境准备与镜像拉取

首先需要获取Omni-Infer推理框架和配套镜像。Omni-Infer代码版本应选择release_v0.7.0,配套镜像可从官方仓库获取。以A3硬件和arm架构为例,使用以下命令拉取镜像:

docker pull swr.cn-east-4.myhuaweicloud.com/omni/omniinfer-a3-arm:release_v0.7.0-vllm

2. 启动容器环境

使用以下命令启动容器,确保模型权重和项目代码可在容器中访问:

IMAGE=swr.cn-east-4.myhuaweicloud.com/omni/omniinfer-a3-arm:release_v0.7.0-vllm
NAME=omniinfer-v0.7.0  # 自定义docker名称
NPU_NUM=16  # A3节点die数
DEVICE_ARGS=$(for i in $(seq 0 $((NPU_NUM-1))); do echo -n "--device /dev/davinci${i} "; done)

docker run -itd \
  --name=${NAME} \
  --network host \
  --privileged \
  --ipc=host \
  $DEVICE_ARGS \
  --device=/dev/davinci_manager \
  --device=/dev/devmm_svm \
  --device=/dev/hisi_hdc \
  -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
  -v /usr/local/Ascend/firmware:/usr/local/Ascend/firmware \
  -v /usr/local/sbin/npu-smi:/usr/local/sbin/npu-smi \
  -v /etc/ascend_install.info:/etc/ascend_install.info \
  -v /mnt/:/mnt/ \
  -v /data:/data \
  -v /home/work:/home/work \
  --entrypoint /bin/bash \
  swr.cn-east-4.myhuaweicloud.com/omni/omniinfer-a3-arm:release_v0.7.0-vllm

启动后,使用以下命令进入容器:

docker exec -it $NAME /bin/bash

3. 配置Omni-Infer框架

下载Omni-Infer代码并配置模型参数:

git clone -b release_v0.7.0 https://gitcode.com/ascend-tribe/openPangu-R-72B-2512-Int8

在omniinfer/omni/models/configs/best_practice_configs.json中增加如下配置:

{
      "model": "pangu_pro_moe_v2",
      "hardware": "A3",
      "precision": "w8a8",
      "prefill_node_num": 1,
      "decode_node_num": 1,
      "pd_disaggregation": false,
      "prefill_config_file": "pangu_pro_moe_v2_bf16_a3_hybrid.json",
      "decode_config_file": "pangu_pro_moe_v2_bf16_a3_hybrid.json"
}

4. 启动服务

将examples/start_serving_openpangu_r_72b_2512.sh脚本放入omniinfer/tools/scripts路径并执行:

cd omniinfer/tools/scripts
# 需修改serving脚本中model-path模型路径、master-ip机器IP地址和PYTHONPATH
bash start_serving_openpangu_r_72b_2512.sh

启动脚本中包含了针对Ascend A3优化的环境变量配置,如:

export ASCEND_RT_VISIBLE_DEVICES=0,1,2,3
export VLLM_USE_V1=1
export VLLM_WORKER_MULTIPROC_METHOD=fork
export OMNI_USE_PANGU=1
export ENABLE_PREFILL_TND=1

5. 测试服务

服务启动后,可发送测试请求验证部署是否成功:

curl http://0.0.0.0:8000/v1/chat/completions \
    -H "Content-Type: application/json" \
    -d '{
        "model": "openpangu_r_72b_2512",
        "messages": [
            {
                "role": "user",
                "content": "Who are you?"
            }
        ],
        "temperature": 1.0,
        "top_p": 0.8,
        "top_k": -1,
        "vllm_xargs": {"top_n_sigma": 0.05},
        "chat_template_kwargs": {"think": true, "reasoning_effort": "low"}
    }'

高级功能与优化建议

模式切换与性能调优

openPangu-R-72B-2512-Int8支持快慢思考两种模式切换,通过设置请求体中的"chat_template_kwargs"字段实现:

  • 慢思考模式(默认):"chat_template_kwargs": {"think": true}
  • 快思考模式:"chat_template_kwargs": {"think": false}

在慢思考模式下,还可通过"reasoning_effort"参数调整推理深度:

  • 高精度模式:"reasoning_effort": "high"
  • 高效率模式:"reasoning_effort": "low"

工具调用能力

模型支持工具调用功能,可通过API请求实现复杂任务处理:

curl http://0.0.0.0:8000/v1/chat/completions \
   -H "Content-Type: application/json" \
   -d '{
        "model": "openpangu_r_72b_2512",
        "messages": [
            {"role": "system", "content": "你是华为公司开发的盘古模型。\n现在是2025年7月30日"},
            {"role": "user", "content": "深圳明天的天气如何?"}
        ],
        "tools": [
                    {
                        "type": "function",
                        "function": {
                            "name": "get_current_weather",
                            "description": "获取指定城市的当前天气信息,包括温度、湿度、风速等数据。",
                            "parameters": {
                                "type": "object",
                                "properties": {
                                    "location": {
                                        "type": "string",
                                        "description": "城市名称,例如:北京、深圳。支持中文或拼音输入。"
                                    },
                                    "date": {
                                        "type": "string",
                                        "description": "查询日期,格式为 YYYY-MM-DD(遵循 ISO 8601 标准)。例如:2023-10-01。"
                                    }
                                },
                                "required": ["location", "date"],
                                "additionalProperties": "false"
                            }
                        }
                    }
                ],
        "temperature": 1.0,
        "top_p": 0.8,
        "top_k": -1,
        "vllm_xargs": {"top_n_sigma": 0.05},
        "chat_template_kwargs": {"think": true, "reasoning_effort": "high"}
    }'

总结

通过本文介绍的步骤,您可以在Ascend A3硬件上轻松部署openPangu-R-72B-2512-Int8模型,充分发挥昇腾硬件的计算优势和模型的高效推理能力。无论是企业级AI服务还是科研实验,这一组合都能提供卓越的性能和可靠性。

如需更详细的技术文档,可参考项目中的doc/omniinfer_for_openpangu_r_72b_2512.md文件,其中包含了更深入的配置选项和优化建议。

【免费下载链接】openPangu-R-72B-2512-Int8 昇腾原生的openPangu-R-72B-2512语言模型量化版本 【免费下载链接】openPangu-R-72B-2512-Int8 项目地址: https://ai.gitcode.com/ascend-tribe/openPangu-R-72B-2512-Int8

Logo

昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链

更多推荐