TiRex: Zero-Shot Forecasting across Long and Short Horizons with Enhanced In-Context Learning (NeurIPS 2025, arXiv:2505.23719).
TiRex-1.1 is a 35M-parameter pre-trained xLSTM-based time-series foundation model. It performs zero-shot probabilistic forecasting — no training on user data — producing a point forecast (the median, 0.5 quantile) plus 9 quantile levels (0.1–0.9). The 1.1 release adds long period normalisation (frequency-domain context downsampling + forecast upsample), applied at inference time. 1.1-gifteval additionally cleans the pretraining data to remove overlaps with the GIFT-Eval test set.
This repository adapts TiRex-1.1-gifteval to run served inference on Ascend NPU using torch_npu +
the official tirex-ts package, exposed as a FastAPI HTTP service.
train_ctx_len=2048), forecast any horizon.model.ckpt (141 MB, PyTorch Lightning checkpoint).resample_strategy="frequency" (default) — dominant-period FFT
downsampling for long contexts, forecast upsampled back to the requested horizon.tirex-ts==1.4.2 (sLSTM native "torch" backend — no CUDA kernels required)Why not vLLM-Ascend? vLLM-Ascend 0.18 serves autoregressive transformer LLMs; the xLSTM time-series architecture is not in its model registry, so TiRex-1.1 is served with torch_npu.
TiRex's sLSTM native torch backend uses only standard PyTorch ops — matmul/einsum
(LinearHeadwiseExpand), F.group_norm (MultiHeadLayerNorm), RMSNorm (rsqrt), and the cell
pointwise updates (sigmoid/exp/tanh/logsigmoid/clamp/max/where/minimum) in bf16.
The v1.1 frequency resampling runs on CPU tensors (torch.fft on the context) and the model itself
runs on NPU. All of these are supported by the Ascend NPU. No source changes were required — the
model loads and runs on NPU with TiRexZero.from_pretrained(ckpt, device="npu:1", backend="torch")
and model.forecast(..., resample_strategy="frequency").
# 1. install deps
pip install tirex-ts==1.4.2 fastapi uvicorn pydantic modelscope
# 2. download weights (ModelScope, idempotent + sha256 check)
python3 download_model.py
# 3. start FastAPI service on NPU (default npu:1:8045)
bash start_serve.sh 8045 npu:1
# 4. smoke test
python3 test_server.py
# 5. verify NPU vs CPU
python3 verify_npu_vs_cpu.pyPOST /v1/forecast
{
"series": [[1.0, 2.0, 3.0, ...], [1.5, 2.5, 3.5, ...]],
"prediction_length": 64,
"resample_strategy": "frequency",
"max_accelerated_rollout_steps": 1
}series accepts a flat list, a list of lists, or a batch of equal-length lists. resample_strategy
defaults to "frequency" (TiRex-1.1 long-period normalisation); use "none" for the plain forecast.
Response returns quantiles (keys 0.1…0.9, each [num_series, prediction_length]), mean
(median), and latency_ms.
| metric | value |
|---|---|
| load time | ~0.38 s |
latency pred=64 (HTTP, frequency resample) | p50 ~910 ms |
latency pred=64, rollout=4 | ~380 ms |
| process HBM (npu-smi) | ~434 MB |
| NPU vs CPU median max_abs_diff | ~0.005 (~0.5%) |
| NPU vs CPU median correlation | >0.99999 |
The small NPU-vs-CPU difference is inherent bf16 rounding inside the sLSTM cell (both sides run the
same native torch backend in bf16), not an NPU defect.
inference.py — engine + CLI (python3 inference.py --series ... --prediction-length 64)server.py — FastAPI /v1/forecast on Ascend NPUdownload_model.py — ModelScope download + sha256 verifymake_test_data.py / test_server.py / verify_npu_vs_cpu.py / start_serve.shassets/ — screenshot materials (adaptation-workflow / adaptation-result / npu-smi)Weights are not committed — download via download_model.py (ModelScope NX-AI/TiRex-1.1-gifteval).