#NPU
A standalone single-card Ascend 910 NPU inference adaptation of
ibm-granite/granite-timeseries-patchtst,
the IBM PatchTST time-series forecasting checkpoint pre-trained on the
ETTh1 dataset (Apache-2.0). The checkpoint is loaded through
transformers.PatchTSTForPrediction and runs entirely on npu:0 — no
network access, random weights, or CPU fallback during the forward pass.
| Field | Value |
|---|---|
| Model | ibm-granite/granite-timeseries-patchtst (PatchTST, namctin/patchtst_etth1_forecast weights) |
| Architecture | PatchTSTForPrediction (transformers, model_type=patchtst) |
| Task | Time-series forecasting, point forecast (loss=mse, inverse-scaled output) |
| Context | 512 hours |
| Horizon | 96 hours |
| Channels | 7 (HUFL, HULL, MUFL, MULL, LUFL, LULL, OT) |
| Weights | 614,496 params, model.safetensors ≈ 2.4 MB, float32 |
| Revision | main |
ETTh1.csv from the ETDataset
(mirrored at raw.gitcode.com/gh_mirrors/et/ETDataset/.../ETTh1.csv),
SHA-256 f18de3ad269cef59bb07b5438d79bb3042d3be49bdeecf01c1cd6d29695ee066.date, HUFL, HULL, MUFL, MULL, LUFL, LULL, OT.[0, 8640), val [8640, 11520), test [11520, 14400).data[13888:14400]), ground truth = next 96 rows (data[14400:14496]).
The window never crosses the data boundary.past_values shape [1, 512, 7] float32; output shape [1, 96, 7],
already inverse-scaled to original units (PatchTST scaling=std computes
loc/scale from the input window internally).npu:0pip install torch torch-npu transformers modelscope numpy pandas# auto-downloads weights + ETTh1.csv, then runs real inference on npu:0
python inference.py
# local model/data (no downloads)
python inference.py --model-dir /path/to/model --data /path/to/ETTh1.csv
# include a 10-run timing benchmark (default does a single + compile run)
python inference.py --bench
# CPU baseline for cross-checking
python inference.py --device cpuinference.py prints a JSON summary (model, backend, device, dtype, first
param device, input/output shape, window, metrics, forecast, timing) and
writes forecast.npy, ground_truth.npy, result.json. Exit code is 0 only
on success.
Forecasting the last 512h window of the ETTh1 test split:
[1, 96, 7], device npu:0, dtype float32[2.7930, 2.8469, 2.8459, 2.7742, 2.6850, 2.4926, 2.3952, 2.2265, 2.3123, 2.4281, 2.4246, 2.6795][2.5320, 2.4620, 2.8140, 2.4620, 2.6030, 2.5320, 2.4620, 2.6730, 2.8140, 2.7440, 2.7440, 2.8840]Task metrics on the 96-step horizon (same window): mae_all=1.7906,
rmse_all=3.7150, mae_ot=2.1592, rmse_ot=2.4664, smape_ot≈109.7%.
Same weights, same input window, same seed, eval mode, float32 on both sides
(compare_outputs.py --task regression):
| Metric | Value |
|---|---|
| max abs error | 8.58e-4 |
| mean abs error | 1.63e-4 |
| tolerance | atol=1e-3, rtol=1e-3 |
| result | PASS |
Tolerances are justified by the output scale (values in ~0.5–30, mean ~5):
errors are below 1e-3 in absolute terms and stay within rtol=1e-3 for
larger values. FP32 accumulation order differs slightly between the CPU and
the Ascend NPU kernels, producing errors ~1000x smaller than the values.
Measured after 3 warmups, 10 timed windows, torch.npu.synchronize() around
each call: first run (JIT compile) 126.9 ms; stable avg 2.52 ms, min 2.50 ms,
max 2.54 ms, p50 2.52 ms, p90 2.54 ms, p95 2.54 ms, ~397 windows/s, peak
memory 2.4 MB. Preprocessing (CSV read + window slicing) is not included in
the timing; only the model forward pass is measured.
assets/agent_workflow.png — recon, dataset check, download, load, NPU inference, consistency, benchmarkassets/npu_device_call.png — npu-smi info + NPU availability / device / model device & dtypeassets/model_result.png — full default python inference.py --bench output on npu:0These images were rendered by xterm.js from the actual command logs of this adaptation run; they are not desktop screenshots.
inference.py downloads them once.loss=mse
(point forecast).