| 属性 | 值 |
|---|---|
| 模型名称 | CognitiveFusion2-4x7B-BF16 |
| 架构 | MixtralForCausalLM (MoE) |
| 总参数量 | ~28B |
| 激活参数量 | ~14B (top-2 of 4 experts) |
| 精度 | BF16 |
| 上下文长度 | 32,768 |
| Attention | GQA (32 heads, 8 KV heads) |
| Ascend 支持 | 原生支持,零代码改动 |
| 配置 | 要求 |
|---|---|
| NPU | Ascend 910 × 2(推荐)或 Ascend 910B × 2 |
| HBM | 每卡 64GB(共 128GB) |
| CANN | >= 8.5.1 |
| 驱动 | 支持 BF16 |
# 基础环境
CANN >= 8.5.1
torch >= 2.5.0
torch_npu >= 2.9.0
# vLLM-Ascend
vLLM >= 0.18.0
vllm-ascend >= 0.18.0rc1方式一:从 ModelScope 下载(仅获取 config.json)
modelscope download --model huangjingwang/CognitiveFusion2-4x7B-BF16 \
--local_dir ./models/CognitiveFusion2-4x7B-BF16方式二:从 gitcode sparse-checkout 获取 config.json(权重需其他途径)
GIT_TERMINAL_PROMPT=1 git clone \
--depth=1 \
--filter=blob:none \
https://gitcode.com/hf_mirrors/huangjingwang/CognitiveFusion2-4x7B-BF16.git \
./models/CognitiveFusion2-4x7B-BF16
cd ./models/CognitiveFusion2-4x7B-BF16
git sparse-checkout set config.json tokenizer.model注意:如 ModelScope/gitcode 均无法下载权重,请使用 HuggingFace Token:
huggingface-cli login --token <YOUR_TOKEN> huggingface-cli download huangjingwang/CognitiveFusion2-4x7B-BF16 \ --local-dir ./models/CognitiveFusion2-4x7B-BF16
pip install torch==2.5.0
pip install torch_npu==2.9.0
pip install vllm==0.18.0
pip install vllm-ascend==0.18.0rc1vllm serve ./models/CognitiveFusion2-4x7B-BF16 \
--dtype bfloat16 \
--tensor-parallel-size 2 \
--gpu-memory-utilization 0.45 \
--max-model-len 4096 \
--host 0.0.0.0 \
--port 8000curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "./models/CognitiveFusion2-4x7B-BF16",
"messages": [{"role": "user", "content": "Hello, how are you?"}],
"max_tokens": 256,
"temperature": 0.7
}'python inference.py \
--model-path ./models/CognitiveFusion2-4x7B-BF16 \
--prompt "Hello, how are you?" \
--max-tokens 256 \
--temperature 0.7 \
--tp 2| 参数 | 默认值 | 说明 |
|---|---|---|
--model-path | 必需 | 模型目录路径 |
--prompt | "Hello" | 输入提示词 |
--max-tokens | 256 | 最大生成 token 数 |
--temperature | 0.0 | 采样温度(0=贪婪) |
--tp | 2 | 张量并行数(2×Ascend910) |
--gpu-memory-utilization | 0.45 | GPU 显存利用率 |
--max-model-len | 4096 | 最大模型上下文长度 |
--dtype | bfloat16 | 模型精度 |
--save-output | None | 输出结果保存路径 |
--num-prompts | 1 | 批量推理时的提示词数量 |
CognitiveFusion2-4x7B-BF16 (MixtralForCausalLM) 完全适配 vLLM-Ascend,无需任何代码改动:
mixtral.py)基于 synthetic 权重的 CPU vs NPU 对比验证(调试性质):
| 指标 | 结果 | 判定 |
|---|---|---|
| Top-1 Token 一致性 | 100% | ✅ |
| Top-5 Token Set | 5/5 匹配 | ✅ |
| Spearman 排序相关性 | 0.9996 | ✅ |
| 精度误差(offset-corrected) | 0.0037% | ✅ < 1% |
说明:当前精度验证基于 synthetic 权重。官方权重获取受阻(ModelScope 404, gitcode LFS 404, HuggingFace 401)。若能获取官方权重,推荐进行完整的 NPU vs GPU 端到端精度对比。
--tensor-parallel-size 2 --gpu-memory-utilization 0.45# 从兼容的 Mistral 模型复制 tokenizer
cp Mistral-7B-Instruct-v0.2/tokenizer* ./models/CognitiveFusion2-4x7B-BF16/确保 CANN 版本 >= 8.5.1,且已正确安装 torch_npu。
| 指标 | 参考值 |
|---|---|
| 初始化时间 | ~30-60s(含 ACL Graph 编译) |
| 首次推理延迟 | ~200-500ms(warmup 后) |
| 生成吞吐量 | 取决于输入长度和硬件 |
文档版本: 2026-05-20 适配版本: vLLM 0.18.0 + vllm-ascend 0.18.0rc1 + torch_npu 2.9.0