eardoi/t0-alpha-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

t0-alpha(昇腾 NPU 适配)

t0-alpha 是 The Forecasting Company 的开源概率时序预测基础模型 (transformer 架构,101.6M 参数),基于 patch 与 factorized attention, 原生支持多协变量,输出多分位点概率预测。

本项目完成其在**华为昇腾 NPU(Ascend 910B)**上的推理适配与验证。

模型规格

项目说明
网络T0Forecaster(transformer encoder)
参数量101.6M
输入context(batch × time,固定窗口 512)
输出多分位点预测 quantiles(batch × horizon × n_quantiles)
权重格式safetensors(model.safetensors)

环境准备

pip install tfc-t0

推理

cd /workspace/theforecastingcompany_t0-alpha
/usr/local/python3.11.14/bin/python3 inference.py \
    --model_path /workspace/theforecastingcompany_t0-alpha_src \
    --device npu:0

参数

参数说明默认值
--model_path权重目录.../theforecastingcompany_t0-alpha_src
--batch序列条数4
--context输入上下文长度512
--horizon预测步长64
--quantiles分位点(逗号分隔)0.1,0.5,0.9
--device推理设备(npu:0 / cpu)npu:0
--output结果保存文件(可选,npy)stdout

验证结果(Ascend 910B, npu:0)

输入:context (4, 512),horizon=64,quantiles=[0.1, 0.5, 0.9]

[info] model on npu:0: 101.6M params
[info] input: context (4, 512)  horizon=64  quantiles=[0.1, 0.5, 0.9]
============================================================
[info] 输出 quantiles 形状: (4, 64, 3) (batch, horizon, n_quantiles)
[info] 输出 median 形状:    (4, 64)
============================================================

t0-alpha 在 NPU 上完成概率时序预测(输出 (4,64,3) 多分位点预测), NPU 推理链路完整跑通。

适配说明

  • 正确库名为 tfc-t0(注意 pip install t0 会装到 CERN 的 Tier-0 无关包)。
  • T0Forecaster.from_pretrained(path) 加载权重后 .to('npu:0') 迁移。
  • 输入为 context 张量(batch × time),predict(context, horizon, quantiles) 输出分位点预测。
  • 设备解析 resolve_device():NPU 可用性检测,失败自动回退 CPU。
  • 模型权重不推送到仓库:*.safetensors 已加入 .gitignore。

目录结构

.
├── README.md          # 模型卡片(本文件)
├── inference.py       # NPU 推理脚本
└── assets/            # 适配过程截图素材

引用

  • 模型:https://huggingface.co/theforecastingcompany/t0-alpha
  • 代码:https://github.com/theforecastingcompany/tfc-t0