#NPU
Datadog/Toto-2.0-2.5B-FThttps://huggingface.co/Datadog/Toto-2.0-2.5B-FTmain (b4f030fb09ba0fe3f61dd11cf730539bda568eb1)本仓库为昇腾 910 (Ascend910) NPU 适配,基于 toto2 (Toto 2.0) 推理管线,真实权重在 npu:0 完成验证。
[batch, n_variate, time] 浮点张量,非图像、非表格分类/回归
batch=1, n_variate=3, context=512[B, C, T] (batch, variate, time),内部 patch_size=32, 需 ctx % 32 ==0PatchedCausalStdScaler 因果标准化,输出已逆缩放为分位数quantiles 形状 [9, batch, n_variate, horizon] (horizon=96)
torch.manual_seed(42) 固定,eval mode,dtype float32pip install -r requirements.txt
# 或
pip install torch torch-npu einops safetensors huggingface-hub jaxtyping dd-unit-scaling unit-scaling toto-2python inference.py默认从本地 /tmp/toto-model 加载,若不存在则从 Datadog/Toto-2.0-2.5B-FT 自动下载 (依赖 HF_ENDPOINT=https://hf-mirror.com,已配置代理直连)。
torch.npu.is_available(),显式迁移到 npu:0cpu_output.npy, npu_output.npy (原始 quantiles)target shape (1,3,512) 随机正态,horizon=96, seed=42shape [9,1,3,96] mean -0.008316 time 15284.4ms (2.5B-FT 实测)shape [9,1,3,96] mean -0.008316 time 226.5ms (npu:0, 67x 加速)[-1.2060, -1.2198, -1.2208, -1.2203, -1.2227] CPU vs [-1.2060, -1.2198, -1.2208, -1.2203, -1.2227] NPU (max_abs 6.9e-06)SUCCESS 退出码 0, 一致性 PASSED.npy 后比较scripts/compare_outputs.py --task quantile --atol 1e-3 --rtol 1e-3max_abs 6.91e-06 mean_abs 7.2e-07 passed=True (2.5B-FT 实测, 9分位数)atol=1e-3 rtol=1e-3,分位数单调性 CPU True NPU Truetorch.npu.synchronize()avg 219.8ms min 216.3 max 221.9 p50 220.2 p90 220.9 p95 221.4 (NPU) vs 15284ms CPU (69x 加速)4.55 windows/s, batch=1 n_var=3 ctx=512 horizon=96 dtype float329784.6 MB (NPU HBM), 吞吐量单位 windows/sassets/agent_workflow.png: 侦察、下载、加载、NPU 推理、一致性、benchmark、校验全流程assets/npu_device_call.png: npu-smi info + torch.npu 可用性 + 模型参数 device/dtype + 输入输出 deviceassets/model_result.png: python inference.py 真实完整输出 (schema、预测、耗时、状态)图片由 scripts/render_xterm_evidence.mjs --style raw 基于本次真实日志生成,深灰背景、白色等宽字体,提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$。
python 3.12+ 为官方推荐,本仓在 3.11 验证通过 (仅需 unit_scaling 补丁)has_missing_values=False 启用 Flash Attention,NPU 上自动回退为标准 attention,无精度损失decode_block_size=768 分块解码,短 horizon 用 None 单次前向更快@misc{khwaja2026toto20timeseries,
title={Toto 2.0: Time Series Forecasting Enters the Scaling Era},
author={Emaad Khwaja et al.},
year={2026},
eprint={2605.20119},
archivePrefix={arXiv},
url={https://arxiv.org/abs/2605.20119}
}