ggg_0963/CodeFuse-Mixtral-8x7B
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

CodeFuse-Mixtral-8x7B NPU 适配验证

#+NPU

1. 简介

本仓库记录 CodeFuse-Mixtral-8x7B 模型在 Ascend NPU 上的适配和验证结果。

  • 模型说明: CodeFuse-Mixtral-8x7B 是基于 Mixtral 架构的 MoE 代码模型,包含 8 个专家,每次激活 2 个,总参数量约 46.7B。
  • 权重地址: ModelScope: codefuse-ai/CodeFuse-Mixtral-8x7B
  • 参考文档: 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 codefuse-ai/CodeFuse-Mixtral-8x7B

4. 模型架构

参数值
架构MixtralForCausalLM
Hidden Size4096
Layers32
Attention Heads32 (KV Heads: 8)
Intermediate Size14336
Experts8 (激活 2)
Vocab Size32000
总参数量~46.7B (激活 ~12.9B)

5. 基础推理验证

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

MODEL_PATH = "/home/openmind/volume/modelscope/hub/models/codefuse-ai/CodeFuse-Mixtral-8x7B"

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)

Smoke Test 结果 (4/4 通过)

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

6. 精度评测

ARC-Challenge 25-shot

指标hardware: NPU (vLLM-Ascend tp=4)基线 (GPU)误差
准确率25.68% (301/1172)26.20%-0.52%
评测时间537s--
吞吐量2.18 samples/s--

7. 注意事项

  • 模型为 MoE 架构(8 专家),需 4 卡 TP 加载(每卡 ~12.8GB)
  • gpu_memory_utilization=0.8 避免 OOM
  • enforce_eager=True 确保在 NPU 上使用 eager 模式