atlasleong/dolphin-2.9.1-yi-1.5-34b-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Dolphin 2.9.1 Yi 1.5 34B — Ascend 双 NPU 张量并行推理适配

交付目录:dolphin-2.9.1-yi-1.5-34b-npu/ 模型标识:dphn/dolphin-2.9.1-yi-1.5-34b 固定版本(pinned revision):0141cba238d0faad09bc240ea7af14c9ea5aec44 许可证:Apache-2.0 硬件:Ascend 910B4(物理设备 npu:4 + npu:7,两卡张量并行)


模型简介 / Model Introduction

Dolphin 2.9.1 Yi 1.5 34B 由 Eric Hartford、Lucas Atkins、Fernando Fernandes 与 Cognitive Computations 团队训练,是 Cognitive Computations 系列中最受关注的成果之一。 模型基于 01-ai/Yi-1.5-34B 全参数(FFT)微调,权重为 16-bit,在 34B 规模上达到 77.4 MMLU,对话能力出色。模型使用 ChatML 提示模板,具备指令跟随、对话、代码与 初步 agent 能力,并支持 function calling。许可证为 Apache-2.0,允许商用。

本交付将其适配到 Ascend 910B4 环境。由于 34B bf16 检查点(约 74 GB)超过单张 910B4 的 HBM 预算(约 64 GB),本适配使用 物理双卡 npu:4 + npu:7 张量并行 执行真实推理:

  • 引擎:显式 torch.distributed 张量并行(backend=hccl,world_size=2)
  • 切分:q/k/v_proj、gate/up_proj 行切分;o_proj、down_proj 列切分; embed_tokens、lm_head 词表切分;RMSNorm 复制
  • 通信:行并行投影后 all_reduce;词表并行 logits 使用 all_gather

说明:vllm-ascend==0.23.0 已先行评估但被拒绝,原因见下文“已知限制 / Limitations”。

模型核心配置(来自 config.json):

项目值
architecturesLlamaForCausalLM
hidden_size7168
num_hidden_layers60
num_attention_heads56
num_key_value_heads8
intermediate_size20480
vocab_size64000
rope_theta5000000.0
torch_dtypebfloat16
max_position_embeddings8192

环境依赖清单 / Dependencies

容器内已提供与 CANN 8.5.1 匹配的 torch / torch_npu 对,本交付禁止替换为普通 PyPI 轮子:

  • torch==2.9.0+cpu(容器自带)
  • torch_npu==2.9.0(容器自带)
  • CANN:/usr/local/Ascend/cann-8.5.1(ASCEND_HOME_PATH)

仅需通过 阿里云 PyPI 镜像 安装以下非 torch 依赖(见 requirements.txt):

transformers==4.40.1
safetensors==0.8.0
sentencepiece==0.2.2
numpy==1.26.4

安装命令:

export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
export PIP_TRUSTED_HOST=mirrors.aliyun.com
python3 -m pip install -r requirements.txt

请勿执行 pip install torch torch_npu 或 pip install vllm-ascend==0.23.0, 它们会替换容器内已匹配的 torch/torch_npu,破坏 NPU 运行环境。


分步推理操作流程 / Step-by-step dual-NPU inference

以下操作均在交付目录内完成:

DELIVERY=/work/pipeline/jobs/other40/dolphin-2.9.1-yi-1.5-34b/dolphin-2.9.1-yi-1.5-34b-npu
MODEL=/work/pipeline/models/other40/dolphin-2.9.1-yi-1.5-34b
cd "$DELIVERY"
  1. 加载 CANN 环境

    source /usr/local/Ascend/ascend-toolkit/set_env.sh
  2. 确认 NPU 可见性与双卡隔离

    npu-smi info

    期望 910B4-1 共 8 个物理设备;本次任务使用物理 npu:4 与 npu:7。

  3. 安装依赖(仅非 torch 依赖)

    export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
    export PIP_TRUSTED_HOST=mirrors.aliyun.com
    python3 -m pip install -r requirements.txt
  4. 语法自检

    python3 -m py_compile inference.py && echo "SYNTAX OK"
  5. 执行真实双 NPU 推理(torchrun,world_size=2)

    source /usr/local/Ascend/ascend-toolkit/set_env.sh
    ASCEND_RT_VISIBLE_DEVICES=4,7 \
      torchrun --nproc_per_node=2 --log-dir=logs/torchrun \
      inference.py \
        --model-path "$MODEL" \
        --prompt "Explain in one clear sentence what a tensor-parallel inference engine does on two NPUs." \
        --max-new-tokens 64 \
        --output-json logs/npu_result.json
    • --smi-hold-seconds 15 可在模型加载完成后暂停 15 秒,便于并行执行 npu-smi info 抓取物理设备上的 worker PID(本交付已据此生成 logs/npu_smi_capture.txt)。
    • 推理日志写入 logs/npu_inference.log,结果写入 logs/npu_result.json。
  6. 查看结果

    python3 -m json.tool logs/npu_result.json

完整测试用例 / Complete test case

测试输入(可再分发,英文原文,按 ChatML 模板包裹)

<|im_start|>system
You are Dolphin, a helpful AI assistant.<|im_end|>
<|im_start|>user
Explain in one clear sentence what a tensor-parallel inference engine does on two NPUs.<|im_end|>
<|im_start|>assistant
  • 提示来源:本交付撰写的原始英文 benchmark prompt,包裹进上游模型卡文档化的 ChatML 模板(Apache-2.0 模型卡),未再分发任何外部数据集。
  • 实际 prompt_len = 44。

执行命令(真实验收运行)

source /usr/local/Ascend/ascend-toolkit/set_env.sh
ASCEND_RT_VISIBLE_DEVICES=4,7 \
  torchrun --nproc_per_node=2 --log-dir=logs/torchrun \
  inference.py --model-path /work/pipeline/models/other40/dolphin-2.9.1-yi-1.5-34b \
  --prompt "Explain in one clear sentence what a tensor-parallel inference engine does on two NPUs." \
  --max-new-tokens 64 --smi-hold-seconds 15 --output-json logs/npu_result.json
echo "EXIT=$?"

真实输出(模型生成,42 个新 token)

A tensor-parallel inference engine on two NPUs splits the model's layers across the two devices, allowing them to process different parts of the input data simultaneously, thereby improving overall performance and efficiency.

exit_code = 0。


输出结果 / Output results

来自 logs/npu_result.json(真实运行,退出码 0):

字段值
enginetorch_npu
parallel_enginetorch.distributed tensor parallel
dist_backendhccl
world_size2
npu_availabletrue
npu_device_nameAscend 910B4-1 x2
input_device / model_device / output_devicenpu:4,npu:7
hardwareAscend910B4
torch_version / torch_npu_version2.9.0+cpu / 2.9.0
transformers_version4.40.1
weight_shards_loaded15
weight_total_bytes68778931137
prompt_len44
new_tokens42
elapsed_seconds5.52
prefill_seconds1.22
decode_seconds4.16
decode_steps41
tokens_per_second7.61
exit_code0

双卡驻留证据(logs/npu_smi_capture.txt,npu-smi 真实抓取):物理 npu:4 与 npu:7 同时各占用约 33752 MB HBM,进程号分别为 661328 与 661329 (宿主机 PID namespace;推理日志中的 worker PID 为容器内 PID,二者不要求数值相同)。


权重证据 / Weight inventory & revision

  • 来源:https://huggingface.co/dphn/dolphin-2.9.1-yi-1.5-34b
  • 固定版本:0141cba238d0faad09bc240ea7af14c9ea5aec44
  • LFS 总字节:68,778,931,137 = 15 个 safetensors 分片 68,777,898,032 字节 + tokenizer.model 1,033,105 字节
  • 15 个分片 + tokenizer 的 SHA256(来自 Git LFS 元数据 oid sha256):
文件字节SHA256
model-00001-of-00015.safetensors47931307609a10cac63db6cee2460c3a0a46731598feafc6248e8ad7ad8529d80be2be6cc7
model-00002-of-00015.safetensors4756459720cb759e4d3baf4e3387b824cc58c9f709805f4ed63e045f5cec8d9f80333af8a3
model-00003-of-00015.safetensors49913701363abc572986748e7b60c4e8db1599e29c1dd700270271d59d40b80f54fbc00345
model-00004-of-00015.safetensors47564597609f36d3cbe5ecff5d1f87f91611fde3fde0b93aac9b63959827462d7772793704
model-00005-of-00015.safetensors4756459760fea9b665977a970c72a81bd839be31ce39d8241b37b3c130d6bf98f083ea489d
model-00006-of-00015.safetensors499137016063dc988a58eb3a29dbc15368eff600723a73a6370ee284816fa90161f31e6af9
model-00007-of-00015.safetensors4756459760ef1f23365c3272e3486ab00ea9f68207ca10d7fe8d88465ba258b190de318910
model-00008-of-00015.safetensors47564597609cf2b792a6776a2bc887968e9d38d445769820124d50152457b93ed3bdd059a6
model-00009-of-00015.safetensors49913701604cfec1f95efb0be45b21c49fe0ab9b08ce7f2431903fb49d866e2bde508409f4
model-00010-of-00015.safetensors475645976003ea735146264304c5a9c94ec9c2dce77eb5ab924537125eebb6a32a8102a0ef
model-00011-of-00015.safetensors475645976023ab68eb8de3f1c36ecd979edf4738ec04e7da2175b6277c939f0bf4f84afec9
model-00012-of-00015.safetensors499137016008f6cf39245af974bca8db2d3695086f9de869cc6937df119e79af1e113a9f56
model-00013-of-00015.safetensors47564597607e400169e476f7b6d91571db8406a86a9495d3f75ca228dd5e18ee905c7c74da
model-00014-of-00015.safetensors4756459760474880d9ef9c40a73d25ba4ee066012a1a179b0a72fc0f3fea34c618281abf60
model-00015-of-00015.safetensors121114885648c76af5810f7b9cb92ab93b9a7a2d819004eb15e10b57fef7c6f136fb848ba3
tokenizer.model1033105386c49cf943d71aa110361135338c50e38beeff0a66593480421f37b319e1a39

推理脚本会在加载时严格打开全部 15 个分片并校验 weight_map 完整性(assert len(weight_map) == 3 + 9 * num_hidden_layers,每 rank 本地参数约 17.19B)。


资产图 / Assets

以下四张图均由真实会话/日志渲染(非虚构 UI):

Agent workflow

ModelAgent live session

npu-smi device capture

Model result


已知限制 / Limitations

  • vllm-ascend 不可用:pip install vllm-ascend==0.23.0 会替换容器内已匹配的 torch 2.9.0→2.10.0 与 torch_npu 2.9.0→2.10.0.post4(本项目禁止替换匹配对),且 镜像缺少 triton-ascend==3.2.2 导致安装失败。故采用文档化的回退方案——显式 torch.distributed 张量并行。
  • 不替换 torch/torch_npu:任何普通 PyPI 轮子的 torch/torch_npu 安装均为非法操作。
  • 单卡无法容纳 34B bf16 权重:必须使用 npu:4 + npu:7 双卡张量并行。
  • 不发布:本仓库由外部编排器在严格审计后发布,并执行匿名 exact-commit 公共双 NPU 复验。

交付文件清单 / Delivery files

dolphin-2.9.1-yi-1.5-34b-npu/
├── README.md
├── readme.md
├── inference.py
├── requirements.txt
├── .gitignore
├── SHA256SUMS
├── assets/
│   ├── agent_workflow.png
│   ├── modelagent_live_session.png
│   ├── npu_device_call.png
│   └── model_result.png
└── logs/
    ├── npu_inference.log
    ├── npu_result.json
    ├── npu_smi_capture.txt
    └── acceptance_run.log