模型适配 · 表格/时序数据预测 (Time Series Foundation Model) · 昇腾 NPU
Beta 版本头信息
{hardware NPU}Cisco Time Series Model 是一个多分辨率(multiresolution)零样本单变量时序预测基础模型,基于 TimesFM 2.0 架构改进:以 decoder-only transformer 为核心,新增分辨率嵌入(Resolution Embeddings)与特殊分隔 Token(Special Token), 支持 (粗粒度, 细粒度) 双分辨率上下文输入,实现长上下文高效预测。
本项目将其适配到华为昇腾 NPU(Ascend 910 系列),通过 torch_npu 直接加载官方权重完成
NPU 推理,CPU / NPU 输出逐位对比一致(cosine = 1.000000)。
| 项目 | 说明 |
|---|---|
| 任务类型 | 单变量时序零样本预测(forecasting) |
| 输入 | 细粒度上下文 x_f(≤512 点)+ 粗粒度上下文 x_c(≤512 点,聚合因子 60) |
| 输出 | 128 步预测均值 + 9 个分位数(0.1 ~ 0.9) |
| 架构 | 多分辨率 Patched 时序 Decoder(TimesFM2.0 变体) |
| 权重格式 | torch_model.pt / model.safetensors(约 1.99GB) |
cisco-time-series-model-1.0-preview/
├── inference.py # NPU 推理脚本(必选)
├── README.md # 部署说明文档(必选)
├── requirements.txt # 环境依赖清单
├── modeling/ # vendor 的官方建模代码(自包含,适配 NPU)
│ ├── __init__.py
│ ├── cisco_tsm_mr.py
│ └── patched_decoder_multi_resolution.py
└── assets/ # 截图素材文件夹
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png| 组件 | 版本 |
|---|---|
| 硬件 | Ascend 910 系列(1 卡) |
| CANN | 8.5.1 |
| Python | 3.11 |
| PyTorch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| timesfm | 1.3.0 |
| numpy | 1.26.4 |
# 1. 安装依赖(国内镜像)
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
# 2. 下载权重(官方 HF,或使用 hf-mirror 加速)
HF_ENDPOINT=https://hf-mirror.com huggingface-cli download \
cisco-ai/cisco-time-series-model-1.0-preview torch_model.pt --local-dir .
# 3. 验证 NPU 可用
python -c "import torch, torch_npu; print(torch.npu.is_available())"# 默认在 npu:0 上推理
python inference.py --device npu:0
# 指定权重路径与预测步数
python inference.py --device npu:0 --weights /path/to/torch_model.pt --horizon 128
# 运行 CPU-NPU 精度对比验证
python inference.py --device npu:0 --run-validation推理脚本会自动生成 30720 步的合成时序信号,构建 (粗粒度, 细粒度) 多分辨率上下文,
输出 128 步预测均值与 9 个分位数,结果保存至 assets/forecast_result.npz。
Device: npu:0
Forecast horizon: 128
Mean (first 10): [162.87, 164.54, 166.26, 167.42, 168.22, 168.94, 169.22, 169.58, 169.28, 168.73]
CPU vs NPU: max_diff=6.1e-05 cosine=1.000000
✓ Validation PASSED — NPU results match CPU该模型为时序预测模型,不使用 vLLM-Ascend 服务化,直接通过 torch_npu 加载推理:
TimesFmCheckpoint 从 HF 拉取,适配后支持直接指定本地
torch_model.pt 路径加载(TimesFmCheckpoint(path=...)),避免网络依赖。__post_init__ 中 _device 判定从 cuda/cpu 扩展为支持
npu:N,通过 model._device = torch.device("npu:0") 注入。timesfm 1.3.0 的 TimesFmHparams/TimesFmCheckpoint 位于
timesfm.timesfm_base 子模块,vendor 的 modeling 代码已改为从正确路径导入。@misc{gou2025ciscotimeseriesmodel,
title={Cisco Time Series Model Technical Report},
author={Liang Gou and Archit Khare and Praneet Pabolu and Prachi Patel and Joseph Ross
and Hercy Shen and Yuhan Song and Jingze Sun and Kristal Curtis
and Vedant Dharnidharka and Abhinav Mathur and Hao Yang},
year={2025},
eprint={2511.19841},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2511.19841},
}