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.
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)
PatchTSMixerForPrediction natively)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.
| Metric | Value |
|---|---|
| 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 latency | p50 6.06ms / p95 6.13ms |
| CPU reference (single core) | ~11.3ms |
| Speedup | ~6.7× |
| HBM (process) | 126MB |
| NPU vs CPU cosine | 1.0000000000 |
| NPU vs CPU max_abs_diff | 2.20e-04 |
bash start_serve.shPOST /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", ...}
from inference import PatchTSMixerEngine
engine = PatchTSMixerEngine() # npu:1
res = engine.forecast([[10.0, 9.8, ...]]) # -> {"prediction": [1, 96, 7], ...}| File | Purpose |
|---|---|
inference.py | PatchTSMixerEngine (NPU inference) |
server.py | FastAPI server |
download_model.py | ModelScope download + sha256 verify |
make_test_data.py | Generate demo multivariate test data |
verify_npu_vs_cpu.py | Numerical consistency check |
test_server.py | HTTP endpoint tests |
start_serve.sh | One-click start script |
requirements.txt | Python dependencies |
.gitignore | Excludes weights, data, screenshots |