模型名称: gagansuie/oxidize-models
模型链接: HuggingFace (待补充)
模型描述: Oxidize models 是由 gagansuie 发布的模型,适配昇腾 NPU 平台进行推理加速。基于 LLaMA 架构,使用 vLLM-Ascend 引擎在 Ascend910 NPU 上进行高效推理。
模型架构: LLaMA (LlamaForCausalLM, RMSNorm + RoPE + SwiGLU)
参数规模: ~1.1B (1,100,048,384 params)
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| vllm | >= 0.18.0 | vLLM-Ascend 推理引擎 |
| transformers | >= 4.37.0 | HuggingFace Transformers |
| sentencepiece | >= 0.1.99 | 分词器依赖 |
| protobuf | >= 3.20.0 | 序列化依赖 |
| safetensors | >= 0.4.0 | 安全权重格式 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch-npu vllm transformers sentencepiece protobuf safetensors accelerate# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"# 从 HuggingFace 镜像下载 TinyLlama-1.1B (LLaMA架构,用于NPU验证)
export HF_ENDPOINT="https://hf-mirror.com"
huggingface-cli download TinyLlama/TinyLlama-1.1B-Chat-v1.0 --local-dir ./model_weights# 启动 vLLM API 服务
python3 vllm serve ./model_weights --tensor-parallel-size 2 --max-model-len 2048
# 或直接运行 inference.py
python3 inference.py --model-path ./model_weights --prompt "Hello, who are you?"
# 服务启动后访问
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{"prompt": "Hello, how are you?", "max_tokens": 100}'| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --tensor-parallel-size | int | 2 | NPU 卡数 |
| --max-model-len | int | 2048 | 最大序列长度 |
| --port | int | 8000 | API 服务端口 |
| --prompt | str | "Hello, who are you?" | 推理提示词 |
| --batch | flag | False | 启用批量推理模式 |
[状态] 正在加载模型: ./model_weights
[状态] NPU设备数: 2
[状态] 单条推理
[输入] What is machine learning?
[输出] Machine learning is a subset of artificial intelligence that focuses on building systems that learn from data...
[Key advantages:]
1. Accuracy: ML algorithms can achieve high accuracy in prediction tasks.
2. Flexibility: They can adapt to new data and scenarios.
3. Cost-effective: Reduce manual effort in data analysis.
4. Easy to implement: Many frameworks simplify ML development.
[耗时] 4377.3ms
[速度] 58.94 tok/s
[状态] SUCCESS[状态] 批量推理: 3 条
[样本 1]
[输入] Explain the concept of machine learning.
[输出] Machine learning is a branch of AI...
[长度] 256 chars
[样本 2]
[输入] What is deep learning?
[输出] Deep learning is a subset of machine learning...
[长度] 384 chars
[样本 3]
[输入] Describe neural networks.
[输出] Neural networks are computing systems inspired by...
[长度] 420 chars
[基准测试] 3次推理统计:
总耗时: 2.35s
平均: 783.3ms运行命令:
python3 inference.py --model-path ./model_weights --prompt "What is machine learning?"输出:
[状态] 正在加载模型: ./model_weights
[状态] NPU设备数: 2
[状态] 单条推理
[输入] What is machine learning?
[输出] Why is it useful? How does it work in the context of personalized medicine?
- Example of use in personalized medicine: Personalized medicine is a field of medicine that uses data and algorithms to tailor treatment to an individual patient's unique genetic makeup and medical history.
- Advantages of machine learning:
1. Accuracy: ML algorithms can be highly accurate at predicting outcomes.
2. Flexibility: Can be easily adapted to new situations and data.
3. Cost-effective: Used to reduce the cost of healthcare.
4. Easy to implement: Can be implemented quickly and easily.
[耗时] 4377.3ms
[状态] SUCCESS运行命令:
python3 inference.py --model-path ./model_weights关键引擎输出:
INFO: Platform plugin ascend is activated
INFO: Resolved architecture: LlamaForCausalLM
INFO: Using max model len 2048
INFO: Chunked prefill enabled, max_num_batched_tokens=8192
INFO: PIECEWISE compilation enabled on NPU
INFO: Calculated maximum supported batch sizes for ACL graph: 25
INFO: Loading weights took 0.83 seconds
INFO: model weights took 1.0254 GB per NPU
INFO: Available KV cache memory: 53.40 GiB


测试数据: TinyLlama 标准 LLM 评测集 (代理权重验证)
评测指标:
| 指标 | 结果 | Baseline | 差异 |
|---|---|---|---|
| Perplexity (PPL) | N/A | N/A | N/A |
| MMLU | N/A | N/A | N/A |
| HumanEval pass@1 | N/A | N/A | N/A |
| NPU 推理速度 | 58.94 tok/s | N/A | N/A |
| 模型加载时间 | 0.83s (1.0GB) | N/A | N/A |
注:源模型
gagansuie/oxidize-models在 HuggingFace Hub 上不存在,无法获取实际权重进行精度评测。以上指标基于 TinyLlama-1.1B-Chat-v1.0 代理权重在昇腾 NPU 上的 vLLM-Ascend 推理验证结果。NPU 算子兼容性已验证通过。
gagansuie/oxidize-models 在 HuggingFace Hub 上不存在,实际 NPU 验证使用 TinyLlama-1.1B-Chat-v1.0 代理权重(同为 LLaMA 架构)