jsjs1258/Datadog-Toto-2.0-4m-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Datadog/Toto-2.0-4m — Ascend NPU

#NPU

Datadog/Toto-2.0-4m is a 4.14M 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.

模型简介

  • Model: Datadog/Toto-2.0-4m (revision 8306a9801cf98c0f5ffe4b2dcc8f496e616d84d9)
  • Task: multivariate time-series forecasting (probabilistic, 9 quantile levels [0.1, 0.2, ..., 0.9])
  • Architecture: alternating time/variate attention transformer, patch size 32, 4 layers, d_model 256, unit scaling (u-μP)
  • Parameters: 4,144,128 (4.144M)
  • Output: quantiles (9, batch, n_variates, horizon) — identical to the official HuggingFace API contract
  • License: Apache-2.0
  • Reference: DataDog/toto · Model Card

数据契约

Default 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_length512 (最后 512 个观测)
prediction_length / horizon96
频率hourly
缩放模型内置 PatchedCausalStdScaler + asinh,输出已反缩放回真实量纲
缺失值本样例无缺失 (has_missing_values=False)

模型权重新先下载到工作区再从本地加载,正式推理不隐式联网下载权重。

环境

  • Ascend 910 NPU (Ascend910_9362, SOC_VERSION=ascend910_9391)
  • CANN 8.5.1, torch 2.9.0 + torch_npu 2.9.0
  • Python 3.11
  • 单卡 npu:0,峰值显存约 63.5 MiB

安装

pip install -r requirements.txt

如需运行默认评测,先把 ETTh1.csv 放到 data/ETTh1.csv(或在命令行用 --data 指定)。

NPU 推理

默认命令(无需任何参数):

python inference.py

脚本会从 HuggingFace 镜像下载权重到本地缓存并加载到 npu:0。使用本地权重目录时可显式指定:

python inference.py --model-dir /path/to/Datadog/Toto-2.0-4m --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)9.3436
中位数预测 min/max8.5272 / 10.9569
分位数单调性True(9 个分位点单调递增)

前 8 步分位数预测(0.1→0.9):

step 1: [ 8.795  9.026  9.146  9.233  9.308  9.382  9.455  9.550  9.704]
step 2: [ 8.407  8.731  8.905  9.023  9.124  9.220  9.322  9.450  9.652]
step 3: [ 8.169  8.538  8.753  8.908  9.039  9.169  9.310  9.484  9.746]
step 4: [ 8.009  8.411  8.658  8.846  9.006  9.162  9.325  9.528  9.832]
step 5: [ 7.871  8.305  8.577  8.792  8.973  9.149  9.329  9.548  9.870]
step 6: [ 7.683  8.154  8.443  8.670  8.867  9.052  9.244  9.477  9.828]
step 7: [ 7.535  8.042  8.353  8.596  8.811  9.016  9.226  9.482  9.863]
step 8: [ 7.318  7.873  8.211  8.467  8.700  8.922  9.151  9.424  9.827]

一致性

CPU 与 NPU 使用完全相同的权重、数据切片、预处理、seed(42)、eval 模式和 dtype(float32),分别保存原始分位数组后对比:

指标值
输出 shape(9, 1, 1, 96)(CPU 与 NPU 一致)
max_abs_error2.00e-05
mean_abs_error4.93e-06
atol / rtol1e-4 / 1e-3
CPU 分位数单调True
NPU 分位数单调True
结果PASS(smoke consistency,单窗口)

阈值说明:模型以 float32 推理,分位数输出量纲为真实温度(约 3–15), atol=1e-4, rtol=1e-3 远高于浮点误差,NPU 与 CPU 在 1e-5 量级内一致。

性能

单卡 npu:0,context=512,horizon=96,batch=1,channel=1,dtype=float32。 计时前后均调用 torch.npu.synchronize()。

指标值
首次运行(含编译)236.0 ms
稳定 avg23.8 ms
min / max23.1 / 24.8 ms
p50 / p90 / p9524.0 / 24.3 / 24.6 ms
吞吐41.97 windows/s
峰值显存63.5 MiB
迭代次数1(编译)+ 10(稳定)

预处理(CSV 读取、窗口切片)不计入推理耗时;显存为 torch.npu.max_memory_allocated() 峰值。

证据图

以下三张图由 xterm.js 根据本次真实日志生成(非手工绘制),仅展示真实命令输出:

图片说明
assets/agent_workflow.png侦察、数据检查、下载、加载、NPU 推理、一致性、benchmark 与提交校验完整工作流
assets/npu_device_call.pngnpu-smi、NPU 可用性、设备名、模型参数 device/dtype、输入输出 Tensor device
assets/model_result.png默认 python inference.py 的真实完整输出(schema/窗口摘要、真实预测、同步耗时、状态)

限制

  • 本仓为单窗口 smoke consistency 与推理验证,不构成完整 benchmark 排名(官方 BOOM/GIFT-Eval 排行见模型卡)。
  • 默认仅验证单变量(channel=1);多变量(n_variates>1)与缺失值场景为同一推理路径,但未在此验证。
  • 输出为概率分位数,中位数以外的分位点用于不确定性区间估计。
  • 模型权重约 16.6 MB,需自行下载;本仓不提交权重文件。