model.safetensors 9.2 GB (FP32, 2.5B params),config.json 598 B[batch, n_variates, time] (B V T),例如 [1,2,512],支持 target, target_mask, series_ids,频率无关 (frequency-agnostic)[9, batch, n_variates, horizon],分位点 [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9] (9 levels),含 median q0.5npu:0 (Ascend910_9362)/opt/atomgit/adapt-npu-agent/model_cache/Datadog_Toto-2.0-2.5B_complete (本地加载,无网络回退需 HF_ENDPOINT=https://hf-mirror.com)pip install -r requirements.txt
# toto2 与 dd_unit_scaling 需从源码安装(已处理 Python 3.11 兼容 mock):
# git clone https://github.com/DataDog/toto.git /tmp/toto
# pip install --ignore-requires-python --no-deps /tmp/toto/dd_unit_scaling /tmp/toto/toto2
# pip install unit_scaling gluonts toolz einops jaxtyping beartype rotary-embedding-torchrequirements.txt 已固定 torch==2.9.0 torch_npu==2.9.0.post1 等版本。
默认命令(CPU 基准 + NPU 推理 + 一致性 + 性能):
python inference.py脚本自动从本地候选路径加载权重,优先级:
/opt/atomgit/adapt-npu-agent/model_cache/Datadog_Toto-2.0-2.5B_complete/opt/atomgit/adapt-npu-agent/model_cache/Datadog_Toto-2.0-2.5B./model_cache/Datadog_Toto-2.0-2.5B_completeDatadog/Toto-2.0-2.5B (需 HF_ENDPOINT)使用合成多元序列(sinusoid + trend + noise,seed=42,B=1, N=2, T=512,as float32):
[Q,B,N,H] = [9,1,2,96]CPU 基准 (float32, ~13.6s):
quantiles median (q0.5) [0,0,:5]=[1.5040607,1.5042097,1.4926127,1.4661958,1.4208158]
quantiles q0.1 [0,0,:5]=[1.3728367,1.3770763,1.3663798,1.3387630,1.2893097]
quantiles q0.9 [0,0,:5]=[1.6298208,1.6309057,1.6173571,1.5913022,1.5469398]
finite True monotonic True (quantiles sorted increasing axis 0)NPU (npu:0, float32, first run ~540ms compile, second run ~219ms):
quantiles median [0,0,:5]=[1.5040594,1.5042094,1.4926123,1.4661965,1.4208159]
quantiles q0.1 [0,0,:5]=[1.3728380,1.3770734,1.3663780,1.3387631,1.2893151]
quantiles q0.9 [0,0,:5]=[1.6298221,1.6309050,1.6173582,1.5913010,1.5469398]
finite True monotonic True扩展测试 (horizon=192, decode_block_size=768, KV cache 多块):
block decode 192 horizon shape (9,1,2,192) median[0,0,:5]=[1.5040595,1.5042088,1.4926126,1.4661966,1.4208157]终态: SUCCESS - NPU inference validated (exit 0)
.npy 对比/tmp/cpu_toto2_5b.npy vs /tmp/npu_toto2_5b.npy,shape [9,1,2,96]max_abs = 5.96e-06mean_abs = 8.28e-07allclose(atol=1e-4, rtol=1e-3) = Truefinite True (两端)monotonic True (quantiles 单调递增 axis 0, inference.py 校验)shape_ok True ([9,1,2,96])compare_outputs.py --task regression --atol 1e-4 --rtol 1e-3 => passed True (quantile monotonic 在 inference 内单独校验)此为 smoke consistency(固定单窗口,B=1 N=2 T=512 H=96),非完整数据集评测。已通过阈值,未发生 CPU fallback(首参设备验证: cpu vs npu:0)。
运行: python .opencode/skills/npu-adapt-skills/scripts/compare_outputs.py --cpu /tmp/cpu_toto2_5b.npy --npu /tmp/npu_toto2_5b.npy --task regression --atol 1e-4 --rtol 1e-3
所有计时前后调用 torch.npu.synchronize(),预热 3 次,正式 10 次。
对比 CPU: 13648 ms (单次,无 synchronize),NPU 加速 ~61x (稳定阶段)。
三张证据图由 scripts/render_xterm_evidence.mjs --style raw 从本次真实日志渲染,深灰背景,等宽字体,提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$,每张显示 source SHA256、exit code、UTC 时间。图片由 xterm.js 根据本次真实日志生成,非手绘或摆拍。
assets/agent_workflow.png - 工作流:inspect_model → collect_env → npu-smi → check_npu → inference.py (完整 CPU+NPU+一致性+性能)assets/npu_device_call.png - 设备调用:npu-smi info、torch_npu 可用性、device_name、模型首参 device、输入输出 Tensor deviceassets/model_result.png - 默认 python inference.py 完整输出:数据契约、真实预测、耗时、一致性、PASS

has_missing_values=False 路径,不含缺失值掩码与缺失插补分支decode_block_size=768 单块可覆盖 96 horizon;更大 horizon 会触发多块自回归,性能与数值需另测lightning 依赖通过轻量 mock 绕过(forecast 路径不使用 Trainer),若需 Gluonts Trainer 训练则需完整 lightning 安装#NPU