#NPU 昇腾 NPU 时间序列预测适配。把 IBM Granite PatchTST 时间序列基础模型真实运行在单卡昇腾 910(npu:0)上,完成 ETTh1 多变量点预测(context=512 → horizon=96)。
ibm-granite/granite-timeseries-patchtstPatchTSTForPrediction(channel-independent Transformer,PatchTST ICLR 2023)float32)ibm-granite/granite-timeseries-patchtst,权重 2.47 MB(model.safetensors)使用官方模型卡对应的 ETTh1(电力变压器油温,逐小时,7 通道)公开数据集:
HUFL, HULL, MUFL, MULL, LUFL, LULL, OT(batch, context, channel),batch_first=TrueETT-small/ETTh1.csv(https://github.com/zhouhaoyi/ETDataset)loc / scaleAscend910_9362),CANN 8.5.1pip install -r requirements.txt默认在 npu:0 加载真实权重完成推理(首次运行会自动经 HF 镜像下载权重与 ETTh1 数据到本地):
python inference.py也可指定本地已下载的权重目录与数据文件:
python inference.py --model-dir /path/to/model --data /path/to/ETTh1.csv说明:
npu:0。torch.npu.synchronize()。(1, 512, 7) float32,device npu:0(1, 96, 7) forecast,device npu:0前 8 步预测(7 通道):
step 1: [11.035 3.300 7.250 1.704 3.388 1.275 9.548]
step 2: [11.832 3.703 8.020 2.031 3.477 1.280 9.351]
step 3: [12.833 4.241 9.037 2.461 3.555 1.287 9.183]
...相同权重、相同数据切片、相同 seed、eval 模式、float32:
| 指标 | 值 |
|---|---|
| 首轮(compile+infer) | 203.2 ms |
| avg / min / max | 2.5 / 2.4 / 2.5 ms |
| p50 / p90 / p95 | 2.5 / 2.5 / 2.5 ms |
| 吞吐 | ~405 windows/s |
| 峰值 NPU 显存 | 5.4 MiB |
| 输入 shape / dtype | (1, 512, 7) / float32 |
以下三张图片由 xterm.js 依据本次真实运行日志生成(非原始桌面截图):
assets/agent_workflow.png — 侦察、数据检查、加载、NPU 推理、一致性、性能与提交校验流程assets/npu_device_call.png — npu-smi、NPU 可用性、设备名、模型参数/输入/输出 tensor deviceassets/model_result.png — 默认 python inference.py 的真实完整输出