IBM Research PatchTST forecasting checkpoint for the 7-channel ETTh1 dataset (ICLR 2023, arXiv:2211.14730), adapted for Ascend NPU via torch_npu.
PatchTST (A Time Series is Worth 64 Words:
Long-term Forecasting with Transformers) segments a time series into
subseries-level patches served as input tokens to a vanilla Transformer
encoder. Each channel is processed independently (channel independence) while
sharing the same embedding and Transformer weights. This checkpoint is the
fine-tuned forecasting model (PatchTSTForPrediction) pre-trained on the
ETTh1 training split (7 channels: HUFL/HULL/MUFL/MULL/LUFL/LULL/OT). It reaches
MSE 0.3881 on the ETTh1 test split for 96-step-ahead forecasting from a
512-hour window.
Note:
ibm-research/test-patchtstis an IBM Research test/scratch release whoseconfig.jsonandmodel.safetensorsare byte-identical to the officialibm-granite/granite-timeseries-patchtst. It is served here as a standalone time-series-forecasting endpoint.
Architecture: PatchTSTForPrediction (native in transformers 4.57.6)
patch_length=12, patch_stride=12 → 42 patches + CLSd_model=128, 16 heads, FFN 512, pre-normsincos positional encoding, shared_embedding/share_projection,
BatchNorm sublayers, std scaling (RevIN-style)loss=mse, distribution_output=student_t)vLLM-Ascend 0.18 is not used (PatchTST is a non-autoregressive
encoder-only time-series model, absent from the 317-architecture LLM registry).
The model runs on torch_npu + transformers 4.57.6 native PatchTSTForPrediction
with zero source modifications — PatchTST ships out of the box in
transformers 4.57.6 (no vendoring, no patching). Every operator used
(eager matmul attention, LayerNorm / BatchNorm, GELU, sincos positional encoding,
std scaling) is natively supported by the Ascend NPU. The model's default
attn_implementation="eager" avoids flash-attention entirely.
torch_npu 2.9.0.post1# 1. download weights (GitCode HF-mirror first, ModelScope fallback; sha256-verified)
python download_model.py
# 2. generate demo data
python make_test_data.py
# 3. start the service (npu:1, port 8043)
./start_serve.sh # or: python server.py --port 8043
# 4. test the service
python test_server.py --port 8043
# 5. verify NPU vs CPU numerics
python verify_npu_vs_cpu.pycurl -X POST http://127.0.0.1:8043/v1/forecast \
-H 'Content-Type: application/json' \
-d @demo_series.json
# -> {"prediction": [[[...], ...]], "loc": [...], "scale": [...],
# "prediction_length": 96, "context_length": 512, "latency_ms": 5.0, ...}Request body (past_values) accepts [T], [T, C] or [B, T, C] (float32).
Each series must have length >= 512; the most recent 512 points are used.
Response prediction has shape [B, 96, C] (one forecast per input channel).
| Metric | Value |
|---|---|
| Model load | ~2.7 s |
| Steady-state forward (NPU) | ~3–5 ms |
| Steady-state HTTP p50 | 9.1 ms / p95 9.2 ms |
| CPU single-core forward | ~14.1 ms |
| NPU vs CPU acceleration | ~2.8× |
| NPU vs CPU cosine | 1.0000000000 |
| NPU vs CPU max_abs_diff | 6.68e-05 |
| HBM usage (process) | 156 MB |
| Port / device | 8043 / npu:1 |
inference.py — PatchTSTEngine (torch_npu inference, [B,T,C] input)server.py — FastAPI service (/v1/forecast, /health)download_model.py — GitCode HF-mirror + ModelScope downloader (sha256 idempotent)make_test_data.py — ETTh1-style 7-channel synthetic demo dataverify_npu_vs_cpu.py — NPU vs CPU numerical equivalence checktest_server.py — HTTP end-to-end smoke teststart_serve.sh — one-click start scriptassets/ — screenshot materials (workflow / result / npu-smi)Model weights are not committed to this repository; run download_model.py
to fetch them.