liaogx_/granite-timeseries-patchtsmixer
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

Granite-TimeSeries-PatchTSMixer on Ascend NPU

IBM Granite PatchTSMixer time-series forecasting model (KDD'23, arXiv:2306.09364), pre-trained on the 7-channel ETTh1 dataset, adapted for Ascend NPU via torch_npu.

Model Description

PatchTSMixer is a lightweight multivariate time-series forecasting model based on the MLP-Mixer architecture: instead of token-wise attention it performs lightweight mixing across patches, channels and hidden features using only MLP blocks, reaching SOTA forecasting accuracy at a fraction of the compute of transformer baselines. This checkpoint is the IBM pre-trained model for the ETTh1 dataset (7 channels, context 512, prediction 96), reporting MSE 0.37 on the ETTh1 test split.

Architecture: PatchTSMixerForPrediction (native in transformers 4.57.6)

  • 2 MLP-Mixer layers, d_model=48, expansion_factor=3, gated attention
  • Patch embedding: patch_length=16, patch_stride=16 → 32 patches
  • Context length: 512, prediction length: 96
  • std scaling (RevIN-style), common-channel mixing mode
  • Parameters: 196,144 (~0.2M)
  • Weight format: fp32 safetensors (789KB)

Environment

  • Hardware: Ascend 910 ×2 (64GB HBM/card)
  • CANN: 8.5.1
  • Python: 3.11.14
  • torch: 2.9.0 / torch-npu 2.9.0.post1
  • transformers: 4.57.6 (ships PatchTSMixerForPrediction natively)

NPU Adaptation

Zero source modifications — no vendoring, no patching! PatchTSMixerForPrediction is shipped natively by transformers 4.57.6 and uses only NPU-native operators: eager matmul / LayerNorm / GELU / sigmoid / std (std scaling) — no flash-attention, no CUDA kernels. The model runs on Ascend NPU via torch_npu as-is.

Performance

MetricValue
Load time~1.1s (first run ~3.5s with aclnn compile)
First request (w/ compile)~160-170ms
Steady-state forward (server-side)p50 1.61ms
Steady-state HTTP latencyp50 6.06ms / p95 6.13ms
CPU reference (single core)~11.3ms
Speedup~6.7×
HBM (process)126MB
NPU vs CPU cosine1.0000000000
NPU vs CPU max_abs_diff2.20e-04

Usage

Start server

bash start_serve.sh

API endpoints

POST /v1/forecast

{
  "past_values": [[10.1, 9.8, ...], [20.2, 19.9, ...], ...]
}

past_values accepts a single series [T], a multivariate series [T, C] or a batch [B, T, C] (each series ≥ 512 points; the last 512 form the context window). The model is channel-flexible despite being pre-trained on 7 channels. Response: {"prediction": [B,96,C], "loc": ..., "scale": ..., "prediction_length": 96, "context_length": 512, "latency_ms": 1.61, "http_latency_ms": 6.06}

GET /health → {"status": "ok", ...}

Python library

from inference import PatchTSMixerEngine
engine = PatchTSMixerEngine()          # npu:1
res = engine.forecast([[10.0, 9.8, ...]])   # -> {"prediction": [1, 96, 7], ...}

Files

FilePurpose
inference.pyPatchTSMixerEngine (NPU inference)
server.pyFastAPI server
download_model.pyModelScope download + sha256 verify
make_test_data.pyGenerate demo multivariate test data
verify_npu_vs_cpu.pyNumerical consistency check
test_server.pyHTTP endpoint tests
start_serve.shOne-click start script
requirements.txtPython dependencies
.gitignoreExcludes weights, data, screenshots

References

  • TSMixer: Lightweight MLP-Mixer Model for Multivariate Time Series Forecasting
  • PatchTSMixer docs
  • IBM Granite TSFM Repository
  • ETT Dataset (ETTh1)