eardoi/timer-s1-npu
模型介绍
文件和版本
Pull Requests
讨论
分析

Timer-S1 - 昇腾 NPU 适配模型

Timer-S1 是字节跳动(bytedance-research)开源的时序预测基础模型, 基于 LLM 架构(24 层 Transformer),支持零样本时序预测。 本仓库为 华为昇腾 NPU(Ascend 910B 系列)推理适配版,支持 npu:0 一键推理。

模型简介

项目说明
模型bytedance-research/Timer-S1
架构Timer-S1(LLM 时序基础模型,trust_remote_code)
规模8303.7 M 参数(BF16,4 分片共 15.5GB)
输入时序连续值 (1, 512)
输出logits (1, 9, 16)
任务时间序列预测(零样本)
原始仓库bytedance-research/Timer-S1
LicenseApache-2.0

环境要求

项目要求
硬件Ascend 910B 系列(≥1 卡,本仓库基于 910B4 验证)
CANN≥ 8.0
Python3.10 – 3.11
torch / torch_npu2.9.0 / 2.9.0.post2
transformers5.15.0

模型权重

注意:本仓库不包含模型权重文件(4 个分片共约 15.5GB)。

权重请从以下镜像获取:

git clone --depth 1 https://gitcode.com/hf_mirrors/bytedance-research/Timer-S1.git model_src
# 或用 hf-mirror 逐个下载 model-0000X-of-00004.safetensors

推理

python3 inference.py --device npu [--model_path ./model_src]

实测输出(昇腾 910B4)

$ python3 inference.py --device npu
[info] device = npu:0
[info] model arch     : Timer-S1 (时序基础模型)
      参数: 8303.7 M
[info] input          : 时序 (1, 512)
[info] inference done : 888.9 ms on npu
[info] logits         : (1, 9, 16)
[info] 设备确认       : npu:0
[PASS] Timer-S1 NPU inference OK

适配说明

  • 模型为 Timer-S1 自定义架构(trust_remote_code 的 modeling_TimerS1.py), 无 CUDA 特有 API,直接 .npu() 迁移即可。
  • transformers 5.15 兼容修复:DynamicCache.from_legacy_cache / to_legacy_cache 在新版被移除,推理脚本内已打兼容补丁(monkey-patch)。
  • 输入格式:模型输入为 float 时序连续值(非 token ids), PatchEmbedding 自动分 patch 处理。
  • dtype:模型为 BF16,输入需对齐 dtype。
  • 加载使用 local_files_only=True + trust_remote_code=True 完全离线。