w
gcw_uQ09W7jl/ibm-granite-granite-timeseries-patchtst-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

ibm-granite/granite-timeseries-patchtst on Ascend NPU

#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.

Model / task

FieldValue
Modelibm-granite/granite-timeseries-patchtst (PatchTST, namctin/patchtst_etth1_forecast weights)
ArchitecturePatchTSTForPrediction (transformers, model_type=patchtst)
TaskTime-series forecasting, point forecast (loss=mse, inverse-scaled output)
Context512 hours
Horizon96 hours
Channels7 (HUFL, HULL, MUFL, MULL, LUFL, LULL, OT)
Weights614,496 params, model.safetensors ≈ 2.4 MB, float32
Revisionmain

Data contract

  • Source: official ETTh1.csv from the ETDataset (mirrored at raw.gitcode.com/gh_mirrors/et/ETDataset/.../ETTh1.csv), SHA-256 f18de3ad269cef59bb07b5438d79bb3042d3be49bdeecf01c1cd6d29695ee066.
  • 17,420 hourly rows, 0 missing values, columns date, HUFL, HULL, MUFL, MULL, LUFL, LULL, OT.
  • Standard ETTh1 split: train rows [0, 8640), val [8640, 11520), test [11520, 14400).
  • Forecast window: context = last 512 rows of the test split (data[13888:14400]), ground truth = next 96 rows (data[14400:14496]). The window never crosses the data boundary.
  • Input 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).
  • The model auto-downloads weights (ModelScope mirror) and data once, then runs fully offline.

Environment

  • OS: Linux aarch64
  • NPU: 2x Ascend910 (Atlas 800, 64 GB HBM each), target npu:0
  • CANN: 8.5.1 · npu-smi 25.5.5
  • Python 3.11.14 · PyTorch 2.9.0 · torch-npu 2.9.0.post1
  • transformers 4.57.6 · modelscope 1.36.3 · numpy 1.26.4 · pandas 3.0.2

Install

pip install torch torch-npu transformers modelscope numpy pandas

NPU inference

# 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 cpu

inference.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.

Real result on npu:0

Forecasting the last 512h window of the ETTh1 test split:

  • output shape [1, 96, 7], device npu:0, dtype float32
  • first-run (compile) 126.9 ms, stable avg 2.52 ms/window ≈ 397 windows/s
  • peak NPU memory 2.4 MB
  • forecast (OT, first 12 steps) [2.7930, 2.8469, 2.8459, 2.7742, 2.6850, 2.4926, 2.3952, 2.2265, 2.3123, 2.4281, 2.4246, 2.6795]
  • ground truth (OT, first 12 steps) [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%.

CPU–NPU consistency

Same weights, same input window, same seed, eval mode, float32 on both sides (compare_outputs.py --task regression):

MetricValue
max abs error8.58e-4
mean abs error1.63e-4
toleranceatol=1e-3, rtol=1e-3
resultPASS

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.

Performance

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.

Evidence (generated by xterm.js from real terminal logs)

  • assets/agent_workflow.png — recon, dataset check, download, load, NPU inference, consistency, benchmark
  • assets/npu_device_call.png — npu-smi info + NPU availability / device / model device & dtype
  • assets/model_result.png — full default python inference.py --bench output on npu:0

These images were rendered by xterm.js from the actual command logs of this adaptation run; they are not desktop screenshots.

Limitations

  • Single window demo evaluation (smoke-level consistency), not a full dataset accuracy benchmark — the checkpoint's documented ETTh1 test MSE is 0.3881 under the full official protocol.
  • Weights and dataset are not bundled; inference.py downloads them once.
  • Distribution output is not used because the checkpoint uses loss=mse (point forecast).