#NPU Ascend910 NPU 适配 - Toto-Open-Base-1.0 概率时间序列预测
[variates, time] 浮点时序, 频率 1h, context 512, horizon 48, channels=variates, 缩放 CausalPatchStdMeanScalerMaskedTimeseries 结构, 字段:
series: [variates=3, time=512], float32padding_mask: [3,512] bool (全 True)id_mask: [3,512] long (全 0)timestamp_seconds: [3,512] float32 (全 0)time_interval_seconds: [3] float32 (3600 = 1h)forecast.mean [1,3,48], forecast.median [1,3,48], forecast.samples [1,3,48,16], quantiles 0.1/0.5/0.9 单调npu:0, device_name Ascend910_9362pip install -r requirements.txt
# 需已安装 torch_npu 与 CANN 驱动, 并配置 HF 镜像 (hf-mirror.com)
git clone https://github.com/DataDog/toto.git /tmp/toto_src # inference.py 会自动检查 /tmp/toto_srcpython inference.py默认从 /tmp/toto_weights 加载本地权重 (若不存在则从 hf-mirror.com 拉取), 将全部参数移至 npu:0, 使用 torch.npu.synchronize() 计时, 报告 compile/first-run 与稳定推理耗时, 打印 median/mean 统计与采样分位数。
[DEVICE] torch.npu.is_available()=True, device_count="2," device_name="Ascend910_9362"
[MODEL] all param devices: {'npu:0'}
[DATA] input_series shape (3, 512), variates 3, context 512, prediction_length 48
[WARMUP] 1/3 336.8 ms ... 3/3 33.8 ms
[PERF] compile/first-run 33.9 ms, avg 32.2 ms, min 31.8 ms, max 33.9 ms, throughput 31.06 windows/s
[RESULT] median stats: mean 4.2102, std 1.8855, min 1.3174, max 7.3955
[RESULT] variate 0 head 5: [1.3174, 1.7382, 1.5409, 1.4834, 2.0746]
[RESULT] variate 1 head 5: [3.2813, 4.3335, 3.3247, 3.9369, 3.9769]
[RESULT] quantile monotonic (0.1 <= 0.5 <= 0.9): True
[RESULT] mean forecast mean 4.2271, std 1.8443
[STATUS] SUCCESS - NPU inference completed without CPU fallback for mean forecast采样模式 (num_samples=16) 触发 aten::_standard_gamma CPU fallback (Student-T mixture 采样), 已记录; mean 预测无 fallback, 为主指标。
.npy 对比 scripts/compare_outputs.pyToto.load_from_checkpoint(..., map_location="cpu") -> TotoForecaster.forecast(..., num_samples=None).to("npu:0") -> 同 forecastermax_abs_error 2.86e-06, mean 7.81e-07, atol 1e-4 rtol 1e-3 passed True (regression 任务)cpu mean [1.7604 1.7789 ...] vs npu mean [1.7604 1.7789 ...] allclose Truetorch.npu.synchronize()forecaster.forecast证据图由 xterm.js 根据本次真实日志渲染生成 (非桌面截图), 提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$ 仅为展示标签。

num_samples>0) 依赖 aten::_standard_gamma 当前 NPU 不支持, 会 CPU fallback, 已隔离为采样分支, mean 预测不受影响trust_remote_code 审查: Toto 源码含 gluonts/lightning, 已审查无网络/子进程写入