gcw_6a3w2yXz/Datadog-Toto-2.0-2.5B-FT-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Datadog/Toto-2.0-2.5B-FT NPU 适配

#NPU

本仓库将 HuggingFace 上的 Datadog/Toto-2.0-2.5B-FT(Toto 2.0 时间序列基础模型的 2.5B 概率预测微调版,finetuned on GIFT-Eval train split for benchmarking, 2.45B 参数,patch 32, d_model 2048, 48 层 Transformer,9 分位数概率预测)适配为可在单卡昇腾 Ascend 910B(npu:0)上真实运行的 GitCode AI model 仓库。支持多变量时序的零样本概率预测,输出 9 个分位数(0.1~0.9)与中位数点预测。

  • 模型原始仓库:https://huggingface.co/Datadog/Toto-2.0-2.5B-FT
  • 权重:model.safetensors 约 9.82 GB(2,454,281,792 参数, float32, safetensors),config.json patch_size 32, d_model 2048, num_heads 32, num_layers 48, d_ff 5464, num_groups 32, layer_group_size 48, use_xpos True, per_dim_scale True
  • 源实现:https://github.com/DataDog/toto(toto2.model.Toto2Model, 论文 https://arxiv.org/abs/2605.20119),基于 Datadog/Toto-2.0-2.5B 基座微调 10k steps
  • Revision:b4f030fb09ba0fe3f61dd11cf730539bda568eb1(pipeline_tag time-series-forecasting, 9 quantiles 0.1-0.9)

[!WARNING] Benchmarking checkpoint, not general-purpose: 官方说明此权重为在 GIFT-Eval train split 上微调的复现版本,仅用于 benchmark。真实业务请使用 base Datadog/Toto-2.0-2.5B。本仓验证该 FT 权重的 NPU 真实推理与一致性。

任务与路由

项值
模型Datadog/Toto-2.0-2.5B-FT(revision b4f030fb, 2.454B params, 9.82 GB fp32)
架构Toto2Model (PatchedCausalStdScaler + PatchProj + 48×TransformerBlock 含交替 time/variate attention + Quantile Head, use_xpos, per_dim_scale)
任务时间序列概率预测 probabilistic forecasting(9 分位数)
输入target shape [batch, n_variates, time](本仓 batch 2, n_variates 1, time 512, float32),target_mask bool, series_ids long, horizon=96
输出quantiles shape [9, batch, n_variates, horizon](本例 [9,2,1,96])分位数预测,median 为 q=0.5
数据契约轴顺序 [batch, n_variates, time] 输入 -> [quantile, batch, n_variates, horizon] 输出;context 512(patch 32, 16 patches),horizon 96,频率隐式,缩放经 PatchedCausalStdScaler,缺失值以 mask 标记,dtype float32
路由time-series 概率预测,验收 quantile monotonic 与数值一致性

表格数据类型关联:适用于表格数据(CSV/Parquet)中多列数值时序的零样本预测,任务映射为 forecasting,验收指标为 quantile 单调性、forecast 数值一致性与性能。

环境

  • 操作系统:Linux aarch64,昇腾 910B(Ascend910_9362),CANN 8.5.1,npu-smi 25.5.5
  • Python 3.11,torch 2.9.0+cpu + torch_npu 2.9.0.post1+gitee7ba04,transformers 4.57.6,einops 0.8.2,safetensors, huggingface_hub, jaxtyping 0.3.11, unit-scaling 0.3.5
  • 依赖见 requirements.txt

安装

pip install -r requirements.txt
pip install jaxtyping unit_scaling
git clone https://github.com/DataDog/toto.git /tmp/toto_git
pip install /tmp/toto_git/dd_unit_scaling --no-build-isolation --ignore-requires-python || python -c "import sys; sys.path.insert(0, '/tmp/toto_git/dd_unit_scaling')"
pip install /tmp/toto_git/toto2 --no-build-isolation --ignore-requires-python --no-deps

NPU 推理

inference.py 为自包含脚本,默认使用合成可复现时序(seed 0)在 npu:0 上完成 CPU 基线、NPU 推理、一致性与性能基准。核心 forward 的所有参数与参与计算的 Tensor 均显式位于 npu:0。计时前后均调用 torch.npu.synchronize()。

python inference.py
MODEL_DIR=/path/to/Datadog-Toto-2.0-2.5B-FT python inference.py

设备选择固定为 npu:0,输入输出均校验 device 均为 npu:0,无 CPU fallback。

真实结果(Ascend 910B 单卡,npu:0,2026-08-21)

以合成时序 batch=2, n_variates=1, ctx=512, horizon=96, 9 quantiles 为例(seed 0,torch.randn):

  • 输入:target shape (2,1,512),均值 0.0322,标准差 1.0280,范围 [-3.1537, 4.1015];target_mask 全 True;series_ids [0]
  • CPU 基线:quantiles shape (9,2,1,96) 均值 0.002417,标准差 0.817731,最值 [-1.419487, 1.405172],horizon0 9 分位数 [-1.314498, -0.846157, -0.518020, -0.237040, 0.026027, 0.288734, 0.568743, 0.899142, 1.355247],单调性 True,median 前5 [0.026027, 0.019438, 0.023716, 0.026022, 0.024541]
  • NPU 输出:相同输入在 npu:0 上 quantiles shape (9,2,1,96) 均值 0.0024,标准差 0.8177,最值 [-1.4195, 1.4052],horizon0 9 分位数 [-1.314501, -0.846155, -0.518020, -0.237040, 0.026027, 0.288735, 0.568744, 0.899143, 1.355246],单调性 True,median 前5 [0.026027, 0.019438, 0.023716, 0.026023, 0.024541]
  • 推理状态:[STATUS] SUCCESS - NPU inference completed without CPU fallback,[MODEL] all param devices: {'npu:0'},total params 2454281792

完整输出见 model_result.png。

CPU-NPU 一致性

使用相同权重(通过 deepcopy)、相同数据切片(seed 0)、相同预处理、相同随机种子与 float32 精度,分别在 CPU 与 npu:0 上运行并保存原始输出,用 scripts/compare_outputs.py 比较:

python scripts/compare_outputs.py --cpu /tmp/toto_cpu.npy --npu /tmp/toto_npu.npy --task forecasting --atol 1e-4 --rtol 1e-3
  • 分位数:shape (9,2,1,96) 一致,max_abs 7.27e-06,mean_abs 7.82e-07,atol=1e-4 rtol=1e-3 PASS,有限值 True,单调性 CPU True / NPU True
  • 阈值:atol=1e-4 rtol=1e-3(FP32 跨硬件正常波动)

结果:PASS。

性能基准

在 npu:0、float32 下,预热 3 次后正式计时 10 次(batch=2, ctx=512, horizon=96, n_variates=1, 9 quantiles):

指标值
warmup 3 runs600.47 ms / 267.70 ms / 238.04 ms
compile/first-run236.78 ms
avg / min / max224.86 / 216.26 / 236.99 ms
p50 / p90 / p95223.95 / 236.80 / 236.90 ms
throughput8.89 windows/s(batch 2)
batch / ctx / horizon / n_variates / quantiles / dtype2 / 512 / 96 / 1 / 9 / float32
权重显存约 9.82 GB(model.safetensors 9817176960 bytes, 2.454B params)
峰值 NPU 显存约 14 GB(权重 9.82GB + 激活 + 编译),npu-smi 空载 3113 MB -> 未 OOM

计时均含 torch.npu.synchronize() 前后同步。

证据图

三图由 scripts/render_xterm_evidence.mjs --style raw 根据本次真实日志生成,深灰背景、等宽字体,提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$:

  • assets/agent_workflow.png:侦察、环境采集、模型检查、NPU 推理、一致性、性能与提交校验
  • assets/npu_device_call.png:npu-smi、NPU 可用性、设备名、模型参数 device/dtype、输入与输出 Tensor device
  • assets/model_result.png:默认 python inference.py 的真实完整输出

agent workflow npu device call model result

限制

  • 当前为零样本推理 + GIFT-Eval finetune 权重验证,未在 GIFT-Eval 全量评测;仅提供单窗口 smoke consistency
  • 输入仅支持数值型时序,target 为 float32,文本/分类列需自行编码
  • 模型最大 context 受 patch_size 32 限制,当前固定 512+96 安全;超长序列需分段
  • 概率预测为 9 分位数(0.1~0.9),点预测取 median(0.5)
  • 仅适配推理(npu:0),训练仍需 GPU/CPU
  • 2.5B-FT 权重 9.82 GB,峰值显存 ~14 GB,需单卡 64GB HBM 的 Ascend 910B
  • 许可证 apache-2.0

许可

  • 权重许可:apache-2.0,详见 HuggingFace 模型卡
  • 代码许可:Apache-2.0