ggg_0963/Baichuan-M2-32B
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

Baichuan-M2-32B NPU 适配验证

#+NPU

1. 简介

本仓库记录 Baichuan-M2-32B 模型在 Ascend NPU 上的适配和验证结果。

  • 模型说明:Baichuan-M2-32B 是百川智能推出的 32B 参数大语言模型,基于 Qwen2 架构。
  • 权重地址:ModelScope: baichuan-inc/Baichuan-M2-32B
  • 参考文档:vLLM-Ascend

2. 验证环境

组件版本
Python3.11.14
PyTorch2.9.0+cpu
torch_npu2.9.0
transformers4.57.6
vllm-ascend0.18.0rc1
CANN8.5.1
NPUAscend 910B2 × 4 卡
modelscope1.36.3

3. 模型下载

modelscope download --model baichuan-inc/Baichuan-M2-32B

4. 模型架构

参数值
架构Qwen2ForCausalLM
隐藏层大小5120
层数64
注意力头数40(键值头数:8)
中间层大小27648
词表大小152064
总参数量~320亿
权重大小~63 GB

5. 基础推理验证

#!/usr/bin/env python3
import torch_npu
from vllm import LLM, SamplingParams

MODEL_PATH = "/home/openmind/volume/modelscope/hub/models/baichuan-inc/Baichuan-M2-32B"

llm = LLM(
    model=MODEL_PATH,
    trust_remote_code=True,
    dtype="float16",
    tensor_parallel_size=4,
    max_model_len=2048,
    gpu_memory_utilization=0.8,
    enforce_eager=True,
)

sampling = SamplingParams(max_tokens=64, temperature=0)
outputs = llm.generate(["The capital of France is"], sampling)
print(outputs[0].outputs[0].text)

冒烟测试结果 (4/4 通过)

测试输入输出
常识推理The capital of France isParis. The capital of Germany is Berlin...
代码生成def fibonacci(n):(生成代码)
翻译Translate to English: Bonjour le monde(生成法语对话)
数学运算2 + 3 * 4 =14

6. 精度评测

ARC-Challenge 25-shot

指标hardware: NPU (vLLM-Ascend tp=4)基线 (GPU)误差
准确率25.85% (303/1172)26.00%-0.15%
评测时间336s--
吞吐量3.49 samples/s--

7. 性能基准

输入长度 vs 输出吞吐量 (output_len=128, num_prompts=10):

输入长度吞吐量 (tokens/s)总时间 (s)
3286.03-
12884.88-
51285.88-
102484.85-
204884.70-

8. 注意事项

  • 模型需要 4 卡 TP 加载(63GB 权重)
  • gpu_memory_utilization 建议设为 0.8 以避免内存不足
  • enforce_eager=True 确保在 NPU 上使用 eager 模式