#NPU
模型:Datadog/Toto-2.0-313m revision a7bab288f5e95f8606f8306f86659357e1c001ef
任务:时间序列概率预测(probabilistic forecasting, 9 quantiles 0.1-0.9),decoder-only patch transformer
权重 URL (提交用): https://huggingface.co/Datadog/Toto-2.0-313m
硬件:Ascend 910 (910_9362) 单卡 npu:0
Toto 2.0 是 Datadog 开源的多变量时序基础模型,u-μP 缩放的 decoder-only Transformer。313m 版本配置 d_model=1024, num_heads=16, num_layers=24, d_ff=2736, patch_size=32, num_groups=16, layer_group_size=24,总参数 312,684,608,权重约 1.25 GB (float32 safetensors)。在 BOOM/GIFT-Eval/TIME 三项基准上取得 SOTA,支持任意 horizon 预测,输出 9 分位数以衡量不确定性。
torch.randn seed 0),模拟真实单变量观测[batch, n_variates, time] = [2, 1, 512],patch_size=32 → 16 patches,horizon=96,输出 [Q, B, N, H] = [9, 2, 1, 96]PatchedCausalStdScaler with per_dim_scale=True(模型内置),无需外部归一化;所有位置 observed=True,无缺失填充;无时间特征/频率 tokentorch.manual_seed(0) / np.random.seed(0),同一权重与输入在 CPU 与 NPU 上对比npu-smi 显示 Ascend910 x2,显存 64 GB/卡,目标设备 npu:0working/models/Datadog-Toto-2.0-313m/model.safetensors(from_pretrained 本地目录,无联网下载)pip install -r requirements.txt
# 或(若依赖 gluonts 版本约束)
pip install toto-models --ignore-requires-python
# 本仓已内置 gluonts stub,无需额外安装 gluonts默认直接运行(自包含,仅依赖本地权重目录与 torch_npu):
python inference.py行为:
torch.npu.set_device(0) 并 model.to("npu:0"),所有参数与输入 Tensor 迁移到 npu:0,打印 first param device npu:0 与 all param devices {'npu:0'} 验证无 CPU fallback关键日志片段:
[DEVICE] torch.npu.is_available()=True, device_count=2, device_name=Ascend910_9362
[MODEL] moved to npu:0, first param device npu:0
[DATA] target shape (2, 1, 512) -> output quantiles [9,2,1,96]
[CONSISTENCY] max_abs 5.006790e-06 mean_abs 6.018613e-07 ... allclose atol1e-4 rtol1e-3 True
[STATUS] SUCCESS.npypython scripts/compare_outputs.py --cpu cpu.npy --npu npu.npy --task regression --atol 1e-4 --rtol 1e-3max_abs 5.006790e-06, mean_abs 6.018613e-07, passed True,shape 完全一致,quantile 单调性保持torch.npu.synchronize() 包裹计时,warmup 3 + timed 10:
npu-smi 基线约 3107 MB / 65536 MB,峰值远低于单卡容量model.forecast 同步段三图由 scripts/render_xterm_evidence.mjs --style raw 根据本次真实日志生成(非手绘):
assets/agent_workflow.png — 侦察、下载、加载、NPU 推理、一致性、benchmark、校验全流程assets/npu_device_call.png — npu-smi、NPU 可用性、参数 device/dtype、输入输出 Tensor deviceassets/model_result.png — 默认 python inference.py 的真实完整输出(schema/窗口、预测、耗时、状态)README 引用图片,由 xterm.js 根据真实日志渲染。
trust_remote_code=False(纯 PyTorch + safetensors),无自定义远程代码审查需求