sheepss/granite-timeseries-flowstate-r1-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

FlowState - granite-timeseries-flowstate-r1 (#NPU)

Model: ibm-granite/granite-timeseries-flowstate-r1 (default revision, r1.0) Architecture: FlowStateModel (S5 state-space encoder + Functional Basis Decoder) Task: zero-shot probabilistic time-series forecasting (quantiles) Device: Ascend 910 (single npu:0) via torch_npu Dtype: float32 | Params: 9,069,312 | Weights: model.safetensors (36.3 MB)

Model Introduction

FlowState is a time-scale adjustable Time Series Foundation Model. A State Space Model (SSM/S5) encoder projects the input into a timescale-invariant coefficient space, and a Functional Basis Decoder (Legendre basis) generates continuous forecasts from that space. It supports zero-shot quantile forecasting: outputs [batch, n_quantiles, forecast_length, n_channels] with quantiles [0.1..0.9], plus a mean prediction.

Data Contract

  • Dataset: ETTh1 (hourly electricity transformer temperature), public zhouhaoyi/ETDataset benchmark. Source file ETTh1.csv, 4066 rows, columns date,HUFL,HULL,MUFL,MULL,LUFL,LULL,OT.
  • Target channel: OT (oil temperature), univariate, no missing values, timestamps hourly and strictly increasing.
  • Preprocessing: last 2048 points used as context window; input reshaped to [batch=1, 2048, 1]. Axis order is [batch, time, channel] (batch_first=True).
  • Scale factor: 1.0 (hourly sampling). Prediction horizon: 96 hours.
  • Outputs are in original units (inverse RevIN normalization applied).

Environment

  • Python 3.11, PyTorch 2.9.0, torch_npu 2.9.0.post1, transformers >= 4.52
  • NPU: Ascend910 (device count >= 1, tested on npu:0)

Installation

pip install torch torch_npu transformers numpy pandas safetensors

Model weights are downloaded automatically via from_pretrained (ibm-granite/granite-timeseries-flowstate-r1) on first run, or pass --model_dir <path> to load a local checkpoint.

NPU Inference

python inference.py --data ETTh1.csv
# optional: --model_dir <local model dir> --context 2048 --prediction_length 96 --scale_factor 1.0

The script verifies the NPU is available, loads the real weights, moves all parameters to npu:0, runs inference with torch.npu.synchronize(), prints the forecast and quantiles, and exits non-zero on any failure.

Real Result (Ascend NPU, default run)

[FlowState] device = npu | model = ibm-granite/granite-timeseries-flowstate-r1
[FlowState] model loaded in 7.10s | params=9,069,312
[FlowState] first param device=npu:0 dtype=torch.float32
[FlowState] data: ETTh1 hourly | rows=4066 | context=2048
[FlowState] prediction_outputs=[1, 96, 1] quantile_outputs=[1, 9, 96, 1]
[FlowState] mean forecast[0:5]=[9.876, 10.507, 10.860, 11.524, 11.793]
[FlowState] forecast min/max = 7.110 / 11.793
[FlowState] quantile monotonicity at t0 = True
[FlowState] FINAL STATUS = PASS on npu
[FlowState] peak npu mem = 199.1 MB

CPU-NPU Consistency

Same weights, input slice, preprocessing, seed, eval mode and float32 dtype. compare_outputs.py --task regression --atol 1e-3 --rtol 1e-3 over the full quantile tensor [1, 9, 96, 1]:

  • max_abs_error = 8.15e-05
  • mean_abs_error = 2.49e-05
  • passed = true (no CPU fallback; PYTORCH_ENABLE_FALLBACK=0)

Performance (Ascend NPU, single series)

  • context=2048, prediction_length=96, batch=1, float32, npu:0
  • first run (compilation): 1.06 s
  • stable (warmup 3 + test 10, per-run torch.npu.synchronize): avg 765 ms, min 763 ms, max 767 ms, p50 765 ms, p90 766 ms, p95 767 ms
  • throughput: 1.31 series/s (window-based, ~0.90 windows/s per 2048-context)
  • peak NPU memory: 199 MB (well within single-card capacity)

Evidence Images

The three images in assets/ were rendered by xterm.js from the actual terminal logs of this adaptation session (not desktop screenshots):

  • assets/agent_workflow.png - reconnaissance, data checks, NPU inference, consistency and benchmark summary
  • assets/npu_device_call.png - npu-smi, NPU availability, device name, model parameter device/dtype
  • assets/model_result.png - full default python inference.py output on npu:0

Limitations

  • Only zero-shot forecasting is supported by the upstream model.
  • SSM kernel is computed via FFT (torch.fft); long contexts scale with the FFT length. Performance reported is for a single 2048-context series.
  • ETTh1 is used as a public benchmark; for production data choose an appropriate --scale_factor (see model card: hourly=1.0, daily≈3.43/0.0656, etc.).