YingLong_110m 昇腾 NPU 适配部署文档
1. 模型简介
YingLong_110m 是时间序列基础模型,在 78B 时间点上预训练得到。该模型能够进行零样本时间序列预测,支持多种预测任务。
模型架构
| 属性 | 值 |
|---|
| 模型类型 | YingLong |
| 参数量 | 120.47 M |
| Hidden Size | 768 |
| Num Layers | 12 |
| Num Heads | 12 |
| Patch Size | 32 |
| Vocab Size | 3168 |
模型特点
- 时间序列基础模型: 在大规模时间序列数据上预训练
- 零样本预测: 支持零样本时间序列预测
- Haar 变换: 支持 Haar 小波变换
- 统一建模: 支持多种时间序列预测任务
2. 环境依赖清单
2.1 硬件要求
- 华为昇腾系列 AI 处理器(Ascend 910B/310P 等)
- 建议 ≥ 2 GB NPU 显存(YingLong_110m 推理峰值约 500MB-1GB)
- 本次实测使用 910B2(单卡 64 GB)
2.2 软件依赖
| 依赖项 | 版本要求 | 说明 |
|---|
| 操作系统 | CentOS 7.6+ / Ubuntu 18.04+ | 支持主流 Linux 发行版 |
| CANN | 5.0.RC2+ | 华为昇腾计算架构 |
| Python | 3.10+ | 推荐 3.10+ |
| PyTorch | 2.0.0+ | 推荐 2.12 |
| torch_npu | 与 PyTorch 版本匹配 | 昇腾 PyTorch 扩展 |
2.3 安装方式
conda activate pt2100
pip install transformers xformers -i https://repo.huaweicloud.com/repository/pypi/simple
3. 分步推理操作流程
步骤 1:准备工作目录
cd /workspace/agent5/YingLong_110m-ascend
ls -la /workspace/agent5/YingLong_110m/
步骤 2:检查 NPU 环境
npu-smi info
python -c "import torch; import torch_npu; print('NPU 可用:', torch.npu.is_available())"
步骤 3:运行推理脚本
python inference.py --device npu:0
4. 完整测试用例
测试用例 1:时间序列预测推理(NPU:0)
conda activate pt2100
cd /workspace/agent5/YingLong_110m-ascend
python inference.py --device npu:0
实际输出:
============================================================
YingLong_110m 昇腾 NPU 推理
============================================================
[Device] npu:0
[Model Path] /workspace/agent5/YingLong_110m
[Config]
architectures: ['YingLong']
n_embd: 768
n_layer: 12
n_head: 12
patch_size: 32
vocab_size: 1
unet: True
block_size: 8224
[Memory Before Model Load] Allocated: 0.00 GB, Reserved: 0.00 GB
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| npu-smi 25.5.2 Version: 25.5.2 |
+---------------------------+---------------+----------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 95.3 41 0 / 0 |
+===========================+===============+====================================================+
[Loading] YingLong model weights...
[Loading] YingLong model from ...YingLong_110m
Total keys: 130
Total parameters: 120.47 M
[Model Loaded] Allocated: 0.23 GB, Reserved: 0.24 GB
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 103.7 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 3728 / 65536 |
+===========================+===============+====================================================+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1756804 | python | 358 |
+===========================+===============+====================================================+
[Running] YingLong inference (simplified forward pass)...
[npu-smi info]
+------------------------------------------------------------------------------------------------+
| NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)|
| Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) |
+===========================+===============+====================================================+
| 0 910B2 | OK | 104.2 41 0 / 0 |
| 0 | 0000:C1:00.0 | 0 0 / 0 3752 / 65536 |
+===========================+===============+====================================================+
| NPU Chip | Process id | Process name | Process memory(MB) |
+===========================+===============+====================================================+
| 0 0 | 1756804 | python | 382 |
+===========================+===============+====================================================+
[Results]
Output shape: torch.Size([1, 3168])
Output mean: 0.004831
Output std: 0.009138
[Memory After Inference] Allocated: 0.23 GB, Reserved: 0.26 GB
[Done]
性能指标
| 指标 | 值 |
|---|
| 模型参数量 | 120.47 M |
| 推理显存峰值 | ~500 MB |
| 输入 Shape | (1, 2880) |
| 输出 Shape | (1, 3168) |
5. 参考链接