model.safetensors 1.25 GB (FP32, 313M 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-313m (本地加载,无网络回退需 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-313m/opt/atomgit/adapt-npu-agent/working/models/Toto-2.0-313m./model_cache/Datadog_Toto-2.0-313mDatadog/Toto-2.0-313m (需 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, ~1.50s):
quantiles median (q0.5) [0,0,:5]=[1.5145249,1.5148589,1.5063951,1.4884542,1.4420119]
quantiles q0.1 [0,0,:5]=[1.3872376,1.3874069,1.3834891,1.3587645,1.3178761]
quantiles q0.9 [0,0,:5]=[1.6283168,1.6363148,1.6221295,1.6013562,1.5577158]
finite True monotonic True (quantiles sorted increasing axis 0)NPU (npu:0, float32, first run ~430ms compile, second run ~118ms):
quantiles median [0,0,:5]=[1.5145241,1.5148575,1.5063917,1.4884557,1.4420117]
quantiles q0.1 [0,0,:5]=[1.3872375,1.3874068,1.3834881,1.3587653,1.3178756]
quantiles q0.9 [0,0,:5]=[1.6283156,1.6363174,1.6221290,1.6013540,1.5577132]
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.5145237,1.5148571,1.5063912,1.4884554,1.4420113]终态: SUCCESS - NPU inference validated (exit 0)
.npy 对比/tmp/cpu_toto313.npy vs /tmp/npu_toto313.npy,shape [9,1,2,96]max_abs = 4.89e-06mean_abs = 7.77e-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 内单独校验,因脚本 axis 假设不同)此为 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_toto313.npy --npu /tmp/npu_toto313.npy --task regression --atol 1e-4 --rtol 1e-3
所有计时前后调用 torch.npu.synchronize(),预热 3 次,正式 10 次。
对比 CPU: 1505 ms (单次,无 synchronize),NPU 加速 ~13x (稳定阶段)。
三张证据图由 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