对固定版本模型 theforecastingcompany/t0-alpha(revision
31fae62d01db93a48d6922e015bca56f666e84d2,官方门控权重
model.safetensors,406601492 字节,SHA256
16c030d3fd70f06dc4238e9a8356e9b5a631d07f80f1bc76ba539991aed5897f)
在 Ascend NPU(torch_npu,npu:3,Ascend910B4-1) 上的离线推理适配包。
time-series-forecasting(概率多步时间序列预测,分位数输出)torch_npu 2.9.0 + torch 2.9.0+cpu + CANN 8.5.1 + npu-smi 25.5.1npu:3(本包不允许 CPU 静默回退;CPU 仅限文件 IO 与必需的预处理)tfc-t0==0.3.0(Apache-2.0,The Forecasting Company 官方包;wheel
SHA256 0f2c8350562ef11cd8caf1587a8cfdfa6f56f4f65d09900ccc610dae389c7e06
已固定,记录于 requirements.txt / SHA256SUMS / logs/npu_result.json)/work/pipeline/models/tabular16/t0-alpha,运行时通过 --model-dir 指定/work/pipeline/runtime/model-venvs/t0-alpha(继承容器匹配的
torch/torch_npu)LICENSE / NOTICE)注意:本交付为离线公开可用包,未向任何远端发布;不含任何凭据。
t0-alpha 是 The Forecasting Company 发布的开放权重时间序列预测基础模型
(t0 家族的第一个公开迭代)。t0 是基于 decoder-style patch transformer 的
模型,原生支持概率多步预测(分位数输出)与多协变量条件。
架构要点(来自模型卡与 t0 源码):
TimeAwareRotaryEmbedding,
xPos);variate-axis group self-attention;scaler_use_arcsinh=True;0.1,0.25,0.5,0.75,0.9;推理请求的分位点(如
0.1,0.5,0.9)由插值得到;horizon ≤ 1024 一次前向解码;101,641,536)。本包不改写、不替换上游 t0 架构:直接安装官方
tfc-t0==0.3.0(Apache-2.0),逐张量严格加载官方权重,在 npu:3 上运行
原生 T0Forecaster.predict() 完整路径。
tfc-t0==0.3.0,wheel SHA256
0f2c8350562ef11cd8caf1587a8cfdfa6f56f4f65d09900ccc610dae389c7e06;missing=[],unexpected=[],complete=true;npu:3;384 个子模块前向钩子验证,
intermediate_off_device=0;[4,64,3](batch, horizon, 3 分位),median [4,64],
float32,位于 npu:3;finite_ok=true,monotonic_quantiles=true(q0.1 ≤ q0.5 ≤ q0.9 全通过,
单调比例 1.0);npu-smi PID 1289195(NPU 3,666 MB)。运行环境(本包实测):
| 组件 | 版本 |
|---|---|
| Python | 3.11.14 |
| torch | 2.9.0+cpu(容器自带,勿替换) |
| torch_npu | 2.9.0(容器自带,勿替换) |
| CANN | 8.5.1(/usr/local/Ascend/cann-8.5.1) |
| npu-smi | 25.5.1 |
| 硬件 | Ascend 910B4-1(npu:3) |
非 torch 依赖(经 Aliyun pip 镜像安装,见 requirements.txt):
| 包 | 版本 | 说明 |
|---|---|---|
| tfc-t0 | 0.3.0 | 官方 T0 架构包(Apache-2.0),wheel SHA256 已固定 |
| jaxtyping | 0.3.11 | tfc-t0 运行期依赖 |
| rotary-embedding-torch | 0.9.1 | tfc-t0 运行期依赖 |
| wadler-lindig | 0.1.7 | tfc-t0 运行期依赖 |
| einops / huggingface-hub / numpy / safetensors | 系统自带 | 继承自容器 |
关键约束:必须使用容器内已匹配的
torch+torch_npu组合, 绝不通过普通 PyPI wheel 安装或替换 torch/torch_npu。本包通过python -m venv --system-site-packages继承系统 torch/torch_npu。
t0-alpha-npu/
├── inference.py # NPU 推理入口(torch_npu,npu:3,--model-dir)
├── requirements.txt # 非 torch 依赖(Aliyun 镜像,tfc-t0 已固定)
├── SHA256SUMS # 交付物逐文件 SHA256 清单
├── README.md / readme.md # 本说明(内容完全一致)
├── scripts/
│ ├── run_inference_npu.sh # 一键运行 + npu-smi PID 捕获
│ └── render_assets.py # 从真实日志渲染 4 张截图
├── logs/
│ ├── npu_result.json # 结构化结果
│ ├── npu_inference.log # 最终真实调用的推理日志(sanitized)
│ ├── npu-smi-info.txt # npu-smi 全量(hold 期间捕获)
│ ├── npu-smi-proc-mem-i3.txt # npu-smi proc-mem(NPU 3)
│ ├── npu_device_call.log # 设备调用记录
│ └── agent_workflow_runner.log# 运行器工作流日志
└── assets/
├── agent_workflow.png
├── modelagent_live_session.png
├── npu_device_call.png
└── model_result.png模型权重与可复用环境均不在本交付目录内:权重在
/work/pipeline/models/tabular16/t0-alpha,venv 在/work/pipeline/runtime/model-venvs/t0-alpha。
/usr/local/python3.11.14/bin/python3 -m venv --system-site-packages \
/work/pipeline/runtime/model-venvs/t0-alphaexport PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
export PIP_TRUSTED_HOST=mirrors.aliyun.com
/work/pipeline/runtime/model-venvs/t0-alpha/bin/pip install -r requirements.txt/work/pipeline/runtime/model-venvs/t0-alpha/bin/python -c \
"import torch, torch_npu; print(torch.__version__, torch_npu.__version__, torch.npu.device_count())"/work/pipeline/runtime/model-venvs/t0-alpha/bin/python -m py_compile inference.py./scripts/run_inference_npu.sh --model-dir /work/pipeline/models/tabular16/t0-alpha \
--device npu:3 --hold 20等价于直接调用:
/work/pipeline/runtime/model-venvs/t0-alpha/bin/python inference.py \
--model-dir /work/pipeline/models/tabular16/t0-alpha \
--device npu:3 \
--context-len 512 --horizon 64 --batch 4 --quantiles 0.1,0.5,0.9 --seed 0 \
--hold 20 --monitor \
--output-json logs/npu_result.json脚本在前向结束后保留 NPU 上下文 --hold 秒,期间并行执行
npu-smi info 与 npu-smi info -t proc-mem -i 3,从而把真实 Python PID
关联到 npu:3。
cat logs/npu_result.json # 结构化结果
cat logs/npu_device_call.log # 设备调用与 PID 关联记录命令(exit code = 0):
/work/pipeline/runtime/model-venvs/t0-alpha/bin/python \
/work/pipeline/jobs/tabular16/t0-alpha/t0-alpha-npu/inference.py \
--model-dir /work/pipeline/models/tabular16/t0-alpha \
--device npu:3 --context-len 512 --horizon 64 --batch 4 \
--quantiles 0.1,0.5,0.9 --seed 0 --hold 20 --monitor \
--output-json /work/pipeline/jobs/tabular16/t0-alpha/t0-alpha-npu/logs/npu_result.json真实输出(来自 logs/npu_result.json):
engine : torch_npu exit_code: 0
npu_available : true device: npu:3 npu_device_name: Ascend910B4-1
model_device : npu:3 input_device: npu:3 output_device: npu:3
strict_load : 303 keys, missing=[], unexpected=[], complete=true
param_count : 101641536 (torch.float32)
output shape : quantiles=[4, 64, 3] median=[4, 64]
quantile levels : [0.1, 0.5, 0.9]
monotonic_quantiles: true finite: true intermediate modules off device: 0
latency_s : 0.582643 wall_time_s: 6.158 pid: 312467
forecast stats : mean=0.00909 std=0.47250 min=-0.95622 max=0.98464sample quantiles 前 8 步(row 0,[q0.1, q0.5, q0.9]):
[0.0555, 0.1145, 0.1764]
[0.0474, 0.1423, 0.2396]
[0.0014, 0.1202, 0.2394]
[-0.0088, 0.1109, 0.2365]
[0.0183, 0.1344, 0.2650]
[0.0558, 0.1811, 0.3125]
[0.1336, 0.2691, 0.3978]
[0.2250, 0.3681, 0.5069]sample median 前 8 步(row 0):
[0.1145, 0.1423, 0.1202, 0.1109, 0.1344, 0.1811, 0.2691, 0.3681]NPU PID 关联(npu-smi,hold 期间 NPU 3 唯一进程):
NPU ID: 3 Process id: 1289195 Process memory(MB): 666theforecastingcompany/t0-alpha,
revision 31fae62d01db93a48d6922e015bca56f666e84d2)。tfc-t0==0.3.0:Apache-2.0(The Forecasting Company;含 Datadog
Toto 与 Amazon Chronos-2 的 Apache-2.0 代码级署名,见包内 NOTICE)。inference.py、requirements.txt、scripts/):Apache-2.0。