Views
No views yet





pip install torch accelerate transformers~=4.57.11import torch
2from transformers import AutoModelForCausalLM
3
4# load pretrain model
5# supports different lookback/forecast lengths
6model = AutoModelForCausalLM.from_pretrained(
7 'bytedance-research/Timer-S1',
8 trust_remote_code=True,
9 device_map="auto"
10)
11
12# use local model
13# model = AutoModelForCausalLM.from_pretrained(
14# 'path_to_timer_s1',
15# trust_remote_code=True,
16# device_map="auto"
17# )
18
19# prepare input
20batch_size, lookback_length = 64, 11520
21seqs = torch.randn(batch_size, lookback_length).to(model.device)
22
23# Note that Timer-S1 generates predictions at fixed quantile levels
24forecast_length = 256
25
26output = model.generate(seqs, max_new_tokens=forecast_length, revin=True)
27
28# produce quantile forecasts in [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
29print(output.shape) # batch_size x quantile_num(9) x forecast_length
30
31# produce the median forecast of the first sample
32print(output[0][4])Encounter out-of-memory at runtime? Try the following options:python1# Option 1: reduce batch size or context length 2batch_size, lookback_length = 1, 2880 3 4# Option 2: disable KV cache at runtime (or edit it in config.json for a permanent change) 5model.config.use_cache = False # there is no efficiency impact for cases where the prediction horizon does not exceed 256.
@article{liu2026timer,
title={Timer-S1: A Billion-Scale Time Series Foundation Model with Serial Scaling},
author={Liu, Yong and Su, Xingjian and Wang, Shiyu and Zhang, Haoran and Liu, Haixuan and Wang, Yuxuan and Ye, Zhou and Xiang, Yang and Wang, Jianmin and Long, Mingsheng},
journal={arXiv preprint arXiv:2603.04791},
year={2026}
}