/tmp/cisco-weights/torch_model.pt (1,995,580,564 bytes, 1.9 GiB, float32)x_f 512 点 (分钟级) + 粗粒度 x_c 512 点 (小时级, agg_factor 60), 右对齐, 特殊 token + resolution embeddingsforecast[0]['mean'] shape [horizon] float32, forecast[0]['quantiles']['0.1' ... '0.9'] 各 [horizon], 已逆归一化T=30720 (512h*60min), 采样公式 h[(t//60)]*(1+0.05*sin(2πt/30))+N(0,0.4), 本次验证使用完全相同合成数据 (seed 42)build_multi_resolution -> coarse 512 (block 60 均值) + fine 512 (右截) -> _pad_or_truncate 左补0 -> normalize_with_pad (masked mean/std, clamp ±1000) -> Tensor [B,512,1] -> patch 32 -> N=16 patches/streamfreq_tensor zeros [B,1] (high freq)mean*scale+offsetinput_series_1 mean 105.79 std 24.22) 和示例2 (input_series_2 logistic+cos) 已验证多条批处理torch.npu.is_available()=True, device_count=2, device_name Ascend910_9362, npu:0 OK (3112/65536 MB idle)torch_model.pt 1.9 GiB, 498,832,800 params F32, revision bf56b79pip install -r requirements.txt
# torch==2.9.0 torch_npu==2.9.0.post1 numpy==1.26.4 huggingface_hub timesfm==1.3.0 utilsforecast einshape absl-py pandas scikit-learn权重获取 (需联网, 建议 HF_ENDPOINT=https://huggingface.co):
HF_ENDPOINT=https://huggingface.co hf download cisco-ai/cisco-time-series-model-1.0-preview --local-dir /tmp/cisco-weights
# 或 huggingface-cli download cisco-ai/cisco-time-series-model-1.0-preview --local-dir /tmp/cisco-weights# 默认执行 (自动完成 NPU 加载 + 编译 + 预测 + benchmark, 要求 npu:0)
python inference.py
# 自定义视野
python inference.py --horizon 128 --agg-factor 60
# 长视野自回归
python inference.py --horizon 240
# 多条批处理 (inference.py 内 batch=1 示例, 代码支持 batch_size 参数)
python inference.py --batch-size 2 --horizon 128核心逻辑 (inference.py:40-):
torch.npu.is_available() 且 device==npu:0, 首个参数 device 必须为 npu:0TimesFmCheckpoint(path="/tmp/cisco-weights/torch_model.pt") -> CiscoTsmMR(...).load_from_checkpoint -> model._model.to(npu:0), evalrng(42) 合成 30720 点, build_multi_resolution -> coarse/fine -> normalize -> [B,512,1] NPU tensormodel.forecast(series, horizon_len=128, agg_factor=60) -> 自回归 decode 1 patch/iter (128 steps), 细粒度追加 + 粗粒度聚合, 返回 mean [H] + quantiles [9,H]torch.npu.synchronize() 包围首次编译与稳定推理, warmup 3 + iters 10 分离报告执行命令: python inference.py (在 npu:0 上真实执行, 权重来自本地 /tmp/cisco-weights/torch_model.pt, 输入 CPU 生成后拷贝至 NPU, float32)
[INFO] Model: cisco-ai/cisco-time-series-model-1.0-preview
[INFO] Weight URL: https://huggingface.co/cisco-ai/cisco-time-series-model-1.0-preview
[INFO] Revision: bf56b7946c42912ddb05dbf14aabc59f0974d31b
[INFO] Task: time-series-forecasting (multiresolution point + quantiles)
[INFO] Architecture: PatchedTSMultiResolutionDecoder, 50 layers, hidden 1280, patch 32, horizon 128, use_resolution_embeddings=True, use_special_token=True
[INFO] Context: coarse 512 + fine 512 (fine raw up to 30720), agg_factor default 60, horizon default 128
[INFO] torch 2.9.0+cpu torch_npu 2.9.0.post1+gitee7ba04
[INFO] torch.npu.is_available=True device_count=2
[INFO] NPU device name Ascend910_9362
[INFO] NPU memory free 64.57GB total 65.79GB
[INFO] Selected device npu:0
[INFO] Weight path: /tmp/cisco-weights/torch_model.pt (2.00 GB)
Loaded model from checkpoint: /tmp/cisco-weights/torch_model.pt
Sending checkpoint to device cpu
[INFO] First param device: npu:0 dtype: torch.float32 expected: npu:0
[INFO] Model loaded on npu:0, num_params 498.8M, dtype float32
[INFO] Input series len 30720 dtype float32 mean 105.7965 std 24.2271 min 57.9937 max 173.0328
[INFO] Input first 5 [80.12, 80.41, 81.92, 82.72, 82.19]
[INFO] Input last 5 [155.93, 156.13, 158.18, 159.84, 160.59]
[INFO] Coarse ctx len 512 mean 105.7965 first 3 [80.02, 85.20, 90.20] last 3 [162.51, 163.75, 162.69]
[INFO] Fine ctx len 512 mean 150.3873 first 3 [119.50, 120.59, 121.99] last 3 [158.18, 159.84, 160.59]
[INFO] Horizon 128 agg_factor 60 batch 1
[INFO] First run (compile+infer) latency 337.3 ms output mean shape (128,) device npu:0
[INFO] Mean sample first 5 [162.87, 164.54, 166.25, 167.41, 168.21]
[INFO] Mean sample last 5 [158.44, 159.15, 159.71, 160.08, 160.39]
[INFO] Mean stats min 147.1506 max 169.5842 mean 158.9663 std 6.2792 finite True
[INFO] Quantile 0.1 first 5 [162.21, 163.44, 165.17, 166.28, 167.18] last 5 [155.05, 155.82, 156.26, 156.76, 156.84]
[INFO] Quantile 0.5 first 5 [162.88, 164.42, 166.14, 167.36, 168.15] last 5 [158.39, 159.00, 159.51, 159.87, 160.16]
[INFO] Quantile 0.9 first 5 [163.63, 165.44, 167.20, 168.52, 169.22] last 5 [161.81, 162.25, 162.82, 163.11, 163.58]
[INFO] Quantile monotonic at pos0 True values ['162.21', '162.41', '162.59', '162.75', '162.88', '163.03', '163.18', '163.37', '163.64']
[INFO] Benchmark horizon 128 iters 10 warmup 3
[INFO] Stable latency avg 53.1 ms min 52.8 max 53.5 p50 53.1 p90 53.4 p95 53.5 ms
[INFO] Throughput windows/s 18.84 (1 series per window), horizon 128
[INFO] NPU memory after infer free 62.39GB total 65.79GB
[INFO] NPU inference SUCCESS on npu:0 with forecast shape (128,)
[SUCCESS] Cisco TSM MR NPU inference completed数值解读: Coarse/fine 均值符合合成数据小时/分钟级, 预测 mean 162.87-160.39 延续上升趋势, quantiles 单调递增且已逆归一化, finite 且无 NaN.
torch_model.pt), 同一输入 (seed 42 合成 30720 点), 同预处理/归一化/dtype float32/eval, 分别 CPU 与 NPU 推理, 保存 cpu_cisco_mean.npy / npu_cisco_mean.npy, 使用 scripts/compare_outputs.py --task regression --atol 1e-4 --rtol 1e-3{
"task": "regression",
"cpu_shape": [128],
"npu_shape": [128],
"finite": true,
"atol": 0.0001,
"rtol": 0.001,
"max_abs_error": 7.629e-05,
"mean_abs_error": 2.372e-05,
"passed": true
}CPU 均值 [162.87169 164.54495 166.25667 167.41873 168.21674] vs NPU [162.87169 164.54495 166.25671 167.41878 168.21675] 完全一致, 长视野 240 与多条批处理亦验证通过.
torch.npu.synchronize 正常, 无 fallback 日志torch.npu.synchronize(), warmup 3 次不计, 正式 10 次, 报告 compile+first 与 stable 分离, 不含数据生成 (仅含 model.forecast + 同步)以下三图由 xterm.js 根据本次真实日志渲染 (
scripts/render_xterm_evidence.mjs --style raw), 深灰背景白色等宽字, 提示符atomgit@pod-...:~$, 非 Matplotlib/Pillow 模拟.
assets/agent_workflow.png (侦察 -> 下载 -> CPU 基线 -> NPU 推理 -> 一致性 -> 性能 -> 校验)assets/npu_device_call.png (npu-smi + torch.npu.is_available + param device + input/output device)assets/model_result.png (python inference.py 完整输出)

--dtype float16 但需重新校验阈值agg_factortimesfm==1.3.0 的 pytorch_patched_decoder, 若升级 timesfm 2.x API 将失效README 证据图由 xterm.js 根据本次真实日志生成, 非原始桌面截图, Prompt 固定为 atomgit@pod-a94f8701860f4700b161b00e290de466:~$ 仅为展示标签.
模型仓类型: model, 可见范围: 公开, Topics: NPU Ascend Ascend910
#NPU