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

ibm-research/test-patchtst on Ascend NPU

#NPU

A standalone single-card Ascend 910 NPU inference adaptation of ibm-research/test-patchtst, an 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-research/test-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
Revisiona8c54ceeaf3c9c4d864a33d650b156cc18b3ab53

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], inverse-scaled forecasts in original data units.

Environment

  • Ascend 910 (Ascend910_9362), CANN 8.5.1
  • Python 3.11, PyTorch 2.9.0, torch-npu 2.9.0, transformers 4.57.6

Install

pip install torch torch-npu transformers modelscope numpy pandas

NPU inference

python inference.py          # auto-download model+data, run on npu:0
python inference.py --bench  # include 10-run timing benchmark
python inference.py --device cpu  # CPU baseline for comparison

The first NPU call includes on-device compilation; steady-state inference is timed with torch.npu.synchronize() around every forward pass.

Real NPU result (single window, ETTh1 test)

  • Device npu:0, model params on npu:0, input/output tensors on npu:0, dtype float32.
  • First-run (incl. compile) 117.4 ms; steady-state avg 2.58 ms/window (≈ 387 windows/s), min 2.53, max 2.62, p50 2.59, p90 2.62, p95 2.62.
  • Peak NPU memory ≈ 2.4 MB.
Metric (96h OT)Value
MAE (all channels)1.7906
RMSE (all channels)3.7150
MAE (OT)2.1592
RMSE (OT)2.4664
SMAPE (OT)109.75 %

CPU–NPU consistency

Same weights, data window, seed, eval mode and float32 dtype on both devices. compare_outputs.py --task regression --atol 1e-3 --rtol 1e-3 passes: max absolute error 8.6e-4, mean absolute error 1.6e-4 across [1,96,7] outputs. Only 2/672 elements differ by ≤ 0.86e-3 absolute (≤ 0.77% relative) at the small-magnitude MUFL channel; tolerance is set relative to the ~2.5 forecast scale and is documented as the FP32 NPU threshold.

Evidence

The three images below are rendered by the xterm.js renderer from this task's real logs (workflow / device / inference), not from simulated screenshots:

  • assets/agent_workflow.png — inspection, data, compare, submission validation.
  • assets/npu_device_call.png — npu-smi, check_npu.py, model/tensor device+dtype on npu:0.
  • assets/model_result.png — default python inference.py full output on npu:0.

Limitations

  • Single-window consistency is a smoke check, not a full-dataset accuracy benchmark.
  • The test-* checkpoint is a lightweight sample; the forecast is a point forecast (no quantile head in this config).
  • Metrics are reported against one 96h ETTh1 test window only.