#NPU
Datadog/Toto-2.0-1B is a 1.04B parameter multivariate time-series foundation
model (Toto 2.0 family) built by Datadog. It is a u-μP-scaled transformer with
alternating time/variate attention and quantile-based probabilistic
forecasting. This repository adapts the model to run on a single Ascend 910
NPU (npu:0) via torch_npu.
1604e1a5242884fb9848f88c4ced14f4dc62d9d3)[0.1, 0.2, ..., 0.9])quantiles (9, batch, n_variates, horizon) — identical to the official HuggingFace API contractDefault evaluation data is the real traceable ETTh1 hourly series from
ETDataset (zhouhaoyi)
(ETT-small/ETTh1.csv, 17,420 rows, hourly, 2016-07-01 00:00 to 2018-06-26 19:00).
| 项 | 值 |
|---|---|
| 数据源 | https://github.com/zhouhaoyi/ETDataset (ETTh1.csv) |
| 时间列 | date (hourly, UTC) |
| 通道 | OT (oil temperature) |
| 轴顺序 | (batch, n_variates, time) |
| context_length | 512 (最后 512 个观测) |
| prediction_length / horizon | 96 |
| 频率 | hourly |
| 缩放 | 模型内置 PatchedCausalStdScaler + asinh,输出已反缩放回真实量纲 |
| 缺失值 | 本样例无缺失 (has_missing_values=False) |
模型权重新先下载到工作区再从本地加载,正式推理不隐式联网下载权重。
Ascend910_9362, SOC_VERSION=ascend910_9391)npu:0,峰值显存约 4493 MiBpip install -r requirements.txt如需运行默认评测,先把 ETTh1.csv 放到 data/ETTh1.csv(或在命令行用 --data 指定)。
默认命令(无需任何参数):
python inference.py脚本会从 HuggingFace 镜像下载权重到本地缓存并加载到 npu:0。使用本地权重目录时可显式指定:
python inference.py --model-dir /path/to/Datadog/Toto-2.0-1B --data /path/to/ETTh1.csv --context 512 --prediction-length 96输出 9 个分位点(0.1–0.9)的未来 96 小时预测,并打印同步耗时、分位数单调性检查与 [STATUS] NPU inference PASS。
数据:ETTh1 OT 通道最后 512 个观测,预测未来 96 小时(context=512, horizon=96, channel=1, dtype=float32)。
| 指标 | 值 |
|---|---|
| 中位数预测均值 (96h) | 8.7157 |
| 中位数预测 min/max | 7.4065 / 10.4501 |
| 分位数单调性 | True(9 个分位点单调递增) |
前 8 步分位数预测(0.1→0.9):
step 1: [ 8.872 9.006 9.092 9.168 9.236 9.305 9.378 9.469 9.611]
step 2: [ 8.482 8.662 8.773 8.875 8.966 9.057 9.153 9.275 9.462]
step 3: [ 8.281 8.482 8.608 8.723 8.823 8.925 9.033 9.168 9.379]
step 4: [ 8.124 8.350 8.492 8.617 8.724 8.834 8.952 9.102 9.333]
step 5: [ 8.039 8.284 8.440 8.574 8.691 8.810 8.940 9.099 9.338]
step 6: [ 7.948 8.209 8.378 8.520 8.646 8.772 8.906 9.073 9.328]
step 7: [ 7.852 8.139 8.312 8.466 8.600 8.736 8.880 9.053 9.317]
step 8: [ 7.728 8.044 8.237 8.398 8.543 8.686 8.835 9.020 9.304]CPU 与 NPU 使用完全相同的权重、数据切片、预处理、eval 模式和 dtype(float32),分别保存原始分位数组后对比:
| 指标 | 值 |
|---|---|
| 输出 shape | (9, 1, 1, 96)(CPU 与 NPU 一致) |
| max_abs_error | 1.24e-05 |
| mean_abs_error | 2.86e-06 |
| atol / rtol | 1e-3 / 1e-2 |
| CPU 分位数单调 | True |
| NPU 分位数单调 | True |
| 结果 | PASS(smoke consistency,单窗口) |
阈值说明:模型以 float32 推理,分位数输出量纲为真实温度(约 3–15),
atol=1e-3, rtol=1e-2 远高于浮点误差,NPU 与 CPU 在 1e-5 量级内一致。
单卡 npu:0,context=512,horizon=96,batch=1,channel=1,dtype=float32。
计时前后均调用 torch.npu.synchronize()。
| 指标 | 值 |
|---|---|
| 首次运行(含编译) | 373.0 ms |
| 稳定 avg | 172.1 ms |
| min / max | 170.7 / 173.4 ms |
| p50 / p90 / p95 | 172.1 / 173.0 / 173.2 ms |
| 吞吐 | 5.81 windows/s |
| 峰值显存 | 4493.4 MiB |
| 迭代次数 | 1(编译)+ 9(稳定) |
预处理(CSV 读取、窗口切片)不计入推理耗时;显存为 torch.npu.max_memory_allocated() 峰值。
以下三张图由 xterm.js 根据本次真实日志生成(非手工绘制),仅展示真实命令输出:
| 图片 | 说明 |
|---|---|
assets/agent_workflow.png | 侦察、数据检查、下载、加载、NPU 推理、一致性、benchmark 与提交校验完整工作流 |
assets/npu_device_call.png | npu-smi、NPU 可用性、设备名、模型参数 device/dtype、输入输出 Tensor device |
assets/model_result.png | 默认 python inference.py 的真实完整输出(schema/窗口摘要、真实预测、同步耗时、状态) |