thuml/timer-base-84m 是 Timer (Time-Series Transformer) 的 84M 轻量级生成式时序基础模型,基于 Decoder-only Causal Transformer 预训练于 260B 时序点,支持零样本点预测。该版本为单变量预训练,84M 参数,8 层 8 头 hidden 1024,patch 长度 96,上下文最长 2880。
70077a71acce1b4c00d98332fcaabc694255d8e5model.safetensors 336.6 MB, 84.14M 参数, FP32, TimerForPredictionconfig.json input_token_len 96 hidden_size 1024 num_hidden_layers 8 num_attention_heads 8 output_token_lens [96] rope_theta 10000torch, torch_npu, transformers==4.40.1, safetensors, 无额外 remote code 依赖 (需 trust_remote_code=True 加载 modeling_timer.py)任务路由: 时间序列点预测 — 输入
seqs [B, T](B=1, T=2880) → 输出forecast [B, 96]经model.generate(seq, max_new_tokens=96)自回归生成,单 patch 输出。
series [1, 2880] float32, 合成 torch.randn(1,2880) seed 42, mean 0.0051 std 0.9918, 无缺失context_length 2880 = 30 patches ×96, prediction_length 96 =1 patch[B, T] 单变量时序, 无时间戳/频率依赖, 模型内部 TimerPatchEmbedding 做 patch 划分SHA 无外部文件forecast [1, 96] float32 finite, mean 0.151062, 头 5 [-0.0947,0.5686,0.6033,0.5576,0.8727] 尾 5 [0.2096,0.0089,-0.2983,0.0222,-0.0013]TimerPatchEmbedding Linear(96->1024) + RoPE + LayerNormmodel.generate 自回归, use_cache=False (规避新版 transformers Cache API 差异), max_new_tokens 控制预测长度torch.npu.is_available()==True, device_count=2, torch.npu.get_device_name(0)=Ascend910_9362pip install -r requirements.txt
# requirements: torch, torch_npu, transformers="=4.40.1," numpy, safetensors, acceleratepython inference.py日志示例见 assets/model_result.png。默认 python inference.py 即完成真实 NPU 推理 (use_cache=False, seed 42)。
forecast [1,96] finite, mean 0.151062, 首轮 0.2315s (含编译), 次轮 0.0100s[1,2880] -> 输出 [1,96] 单步生成 (horizon 96)python /opt/atomgit/.opencode/skills/npu-adapt-skills/scripts/compare_outputs.py --cpu working/cpu_timer.npy --npu working/npu_timer.npy --task regression --atol 1e-4 --rtol 1e-3max_abs_error 1.52e-06 mean 4.06e-07 passed true (atol 1e-4 rtol 1e-3)npu:0 验证working/perf_timer.json MAE 4.06e-07单样本 smoke consistency,非全量数据集评测。
first_run 0.2445s (含编译) second_run 0.0099s avg 0.0093s min 0.0088s max 0.0096s p50 0.0095s p90 0.0096s p95 0.0096s throughput 305090 points/savg 0.0093s 10 runs after 3 warmup, torch.npu.synchronize() 前后计时model.generate 计时assets/agent_workflow.png — 工作流 (inspect, download, CPU/NPU, compare, perf, validate)assets/npu_device_call.png — NPU 设备 (npu-smi, check_npu, dummy tensor npu:0, param device npu:0)assets/model_result.png — 推理结果 (input/output device, shape, head, timing, SUCCESS)三图由 xterm.js 根据真实日志渲染 (PIL 模拟终端, 深灰背景 #282828, 白色等宽字体, 固定提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$)。
get_usable_length->get_seq_length, get_max_length, apply_rotary clamp, TSGeneration _sample 委托