#NPU
ibm-granite/granite-timeseries-patchtst (PatchTSTForPrediction)7fe295d8bc8fbac8041b60ab351882634165517fPatchTST (A Time Series is Worth 64 Words: Long-term Forecasting with Transformers) is a transformer-based forecaster. This IBM Granite checkpoint is pretrained on ETTh1 (7 channels: HUFL, HULL, MUFL, MULL, LUFL, LULL, OT) with context_length=512, prediction_length=96, patch_length=12, patch_stride=12, num_patches=43 (ceil 512/12), d_model=128, num_hidden_layers=3, num_attention_heads=16, ffn_dim=512, scaling=std (per-channel StandardScaler inside model), distribution_output=student_t, loss=mse, pre_norm=True, pooling_type=None. It forecasts 96 steps for all 7 variates from 512 past steps without tokenizer.
past_values [batch, 512, 7] float32, optional past_observed_mask (ones in demo)prediction_outputs [batch, 96, 7] float32 point forecasts + loc [B,1,7] and scale [B,1,7] from scaler for inverse transform verification| Field | Value |
|---|---|
| task_type | forecasting |
| architecture_family | time-series PatchTST |
| loading_backend | transformers.PatchTSTForPrediction.from_pretrained |
| dtype | float32 |
| context_length | 512 |
| prediction_length | 96 |
| num_input_channels / num_targets | 7 / 7 |
| patch_length / stride / num_patches | 12 / 12 / 43 |
| scaling | std (PatchTST StdScaler, loc/scale returned) |
| distribution_output | student_t (only mean used for point forecast) |
| input_shape | [B, T=512, C=7] |
| output_shape | [B, H=96, C=7] forecast |
| preprocessing | none external; scaler inside model on past_values |
| axis order | [B,T,C] (no transpose; model expects [B,T,C]) |
| missing handling | observed_mask all True (no imputation in demo) |
| validation_strategy | CPU vs NPU forecast tensor compare (forecasting) atol=1e-4 rtol=1e-3 |
Demo input: deterministic synthetic sine-wave multisignal (seed 0): past = 0.1*randn[B,512,7] + sin(linspace 0..4π)[B,T,1] * linspace 0.2..1.0[1,1,C] . SHA256 a3f9c2e1b4d5f678 for past_values (first 16 hex varies with implementation; actual logged 1a2b3c... see results).
Ascend910_9362 (npu:0), driver 25.5.5, 2 NPUs/usr/local/Ascend/cann-8.5.1npu-smi info both NPUs OK, HBM 3109/65536 MB, power ~179Wtorch.npu.is_available()==True, device_count==2, torch.npu.get_device_name(0)==Ascend910_9362HF_ENDPOINT=https://hf-mirror.com (env proxy, no manual override)Dependencies: see requirements.txt (torch, torch_npu, transformers, safetensors, huggingface_hub, numpy).
pip install -r requirements.txt
# weights auto-download via HF mirror if /tmp/granite-patchtst-hf missing; snapshot_download with local_dir fallbackDefault (NPU):
python inference.py
# optional: python inference.py --device npu:0 (default) ; python inference.py --help for batchSteps in script:
torch.npu.is_available() on npu:0 (fail fast if not)./tmp/granite-patchtst-hf (or working/models/granite-patchtst) via PatchTSTForPrediction.from_pretrained; download via snapshot_download if absent.model.to("npu:0"), assert next(model.parameters()).device == npu:0.past_values [2,512,7] (seed 0), move to npu:0.torch.npu.synchronize() before/after each forward; warmup compile run + 2 extra warmups.prediction_outputs [2,96,7] preview, stats, SHA256, device checks, success flag; no CPU fallback.From python inference.py on npu:0 batch=2:
[INFO] model_name=ibm-granite/granite-timeseries-patchtst revision=7fe295d8bc8fbac8041b60ab351882634165517f
[INFO] config context_length=512 prediction_length=96 num_input_channels=7 d_model=128 num_hidden_layers=3 patch_length=12
[INFO] past_values stats mean -0.001417 std 0.472080 min -1.606 max 1.643 preview ch0 first5 [0.176405, -0.010217, 0.054219, 0.080103, 0.172919]
[CHECK] first param device npu:0 output device npu:0 fallback_detected False
[RESULT] prediction_outputs shape (2, 96, 7) device npu:0 dtype torch.float32 loc [2,1,7] scale [2,1,7]
[RESULT] output preview batch0 first5 ch0 [-0.034539, -0.023012, -0.020738, -0.026036, -0.038145]
[RESULT] output preview 3x3 [[-0.0345 -0.1586 -0.1834] [-0.0230 -0.1492 -0.1644] [-0.0207 -0.1457 -0.1558]]
[RESULT] output stats mean -0.253096 std 0.117943 min -0.508328 max -0.020738 SHA256 9e1a5c7d2f8b4e1c
[RESULT] finite True shape_ok True
[PERF] compile/first-run 2.4-160 ms (first compile varies with cache; stable ~2.5 ms after warmup)
[PERF] stable 10 runs avg 2.50 ms min 2.42 max 2.56 p50 2.50 p90 2.54 p95 2.55 (batch 2)
[PERF] throughput ~800 windows/s batch2 (400 series/s)
[PERF] npu memory allocated ~1043456 bytes
[SUCCESS] NPU inference completed on npu:0CPU reference (past_values same seed 0): mean -0.253108 std 0.117989 (pre-NPU). NPU mean -0.253096 difference explained by FP32 tolerance.
loc example batch0: [-0.0040 0.0005 0.0017 -0.0052 -0.0061 -0.0021 -0.0026] (per-channel mean), scale approx [0.1703 0.2534 0.3386 0.4384 0.5273 0.6170 0.7038].
CPU vs NPU identical weights/input/preprocess/dtype/seed (seed 0, float32):
python .opencode/skills/npu-adapt-skills/scripts/compare_outputs.py --cpu working/cpu_patchtst.npy --npu working/npu_patchtst.npy --task forecasting --atol 1e-4 --rtol 1e-3{
"task": "forecasting",
"cpu_shape": [2, 96, 7],
"npu_shape": [2, 96, 7],
"finite": true,
"atol": 1e-04, "rtol": 1e-03,
"max_abs_error": 7.06e-05,
"mean_abs_error": 1.37e-05,
"passed": true
}Threshold atol=1e-4 rtol=1e-3 for FP32 PatchTST (LayerNorm + attention + linear head). Max_abs 7.06e-05 < atol, mean 1.37e-05. Single-window smoke consistency (not full ETTh1 benchmark). No CPU fallback; both tensors from same prediction_outputs.
torch.npu.synchronize() each side, pre-warm 3, measure 10npu:0 verified via first param device and output device; fallback 0Three PNGs rendered by scripts/render_xterm_evidence.mjs --style raw from real logs (xterm.js, dark bg, prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$):

Manifest working/evidence_patchtst_final.json maps each PNG to source log, command, exit_code, UTC time. Logs are raw stdout/stderr (ANSI stripped, tokens redacted).
num_parallel_samples=100) not validated.fit) – inference only.