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

ibm-granite/granite-timeseries-flowstate-r1 NPU Adaptation

#NPU

Model Introduction

ibm-granite/granite-timeseries-flowstate-r1 (FlowState) is a time-scale adjustable Time Series Foundation Model (TSFM) open-sourced by IBM Research. It combines a State Space Model (SSM) encoder with a Functional Basis Decoder (FBD) to forecast in a timescale-invariant coefficient space, seamlessly adjusting to any sampling rate.

  • Original model: https://huggingface.co/ibm-granite/granite-timeseries-flowstate-r1
  • Paper: https://www.arxiv.org/abs/2508.05287
  • Architecture: FlowState (SSM Encoder + Functional Basis Decoder)
  • Framework: PyTorch + torch_npu (Ascend 910)
  • Task: probabilistic time-series forecasting (9 quantiles [0.1 .. 0.9])
  • Params: 9.07M (FP32)
  • Supports: zero-shot forecasting, flexible context/horizon via scale_factor

This repository adapts the checkpoint to run on a single-card Ascend NPU (npu:0). All model parameters and every input/output tensor are explicitly placed on npu:0; inference.py runs the real weights on real, traceable data.

Data Contract

  • Real dataset: ETTh1 (electricity transformer temperature, hourly, 17,420 rows), from the ETDataset ETT-small collection.
  • Schema: date, HUFL, HULL, MUFL, MULL, LUFL, LULL, OT — the OT (oil temperature) series is used for forecasting.
  • Frequency: hourly → scale_factor = 1.0 (per model card recommendations).
  • Context: 2048 observed hourly values; Horizon: 168 forecast steps (1 week).
  • Input tensor: (context, batch, n_ch), batch_first=False, n_ch == 1 (univariate, as supported by FlowState).
  • Preprocessing: Causal RevIN normalization performed inside the model; the script only loads the raw OT column as float32. No train/test split is needed (zero-shot).
  • Output: (batch, quantiles, horizon, n_ch) quantile forecasts; the median (q=0.5) is reported.

The data file is downloaded from the public ETDataset repository on first run; the model weights are loaded from the local checkpoint directory or downloaded from HuggingFace Hub (HF_ENDPOINT mirror).

Environment

  • Ascend 910 NPU (single card, npu:0), CANN 8.5.1 / Ascend Toolkit
  • Python 3.11, PyTorch 2.9.0, torch_npu 2.9.0.post1
  • tsfm_public 0.1.dev1, pandas, numpy, huggingface_hub

Installation

pip install -r requirements.txt

NPU Inference

python inference.py

Optional arguments: --model-dir <local checkpoint>, --data <csv>, --context 2048, --prediction-length 168, --scale-factor 1.0, --iterations 3.

Real Result

Default run on npu:0 with ETTh1 (OT, hourly), context=2048, horizon=168, scale_factor=1.0:

MetricValue
Devicenpu:0 (Ascend910)
Params9.069M, FP32
Input shape(2048, 1, 1)
Output shape(1, 9, 168, 1)
First run (compile+infer)1065 ms
Avg (warm)~790 ms
Min / Max789 / 799 ms
P50 / P90 / P95791 / 795 / 797 ms
Throughput1.26 windows/s
Peak NPU memory210 MiB
Quantile monotonicTrue
Median forecast mean (168h)9.33 (oil temperature)

Consistency

CPU (same weights, same seed, same input) vs NPU on ETTh1 context=2048 → horizon=168:

  • max abs error: 1.01e-04, mean abs error: 2.64e-05 (FP32, atol=1e-4, rtol=1e-3 → PASS)
  • Both produce shape (1, 9, 168, 1); quantile ordering preserved on NPU.

Evidence

The three terminal screenshots below are rendered by xterm.js from the real logs of this adaptation run (workflow, NPU device probe, and the default python inference.py output).

  • assets/agent_workflow.png — reconnaissance, data inspection, CPU baseline, NPU inference, consistency, benchmark, submission validation.
  • assets/npu_device_call.png — npu-smi, NPU availability, device name, model parameter device/dtype, input/output tensor device.
  • assets/model_result.png — real python inference.py output on npu:0.

workflow npu device model result

Limitations

  • FlowState supports only univariate forecasting (n_ch == 1) and zero-shot inference; multi-variate inputs raise an error.
  • The default run uses a real public dataset (ETTh1); results are a single-window smoke consistency check, not a full benchmark ranking.
  • First run includes NPU graph compilation; subsequent runs are faster (reported separately).
  • Peak memory is reported via torch.npu.max_memory_allocated() for the inference process.