gcw_6a3w2yXz/NX-AI-TiRex-1.1-gifteval-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

NX-AI/TiRex-1.1-gifteval NPU 适配

任务ID 10702e1f0ffa42bf9a82fb8a9253faf4 · 原始权重 https://huggingface.co/NX-AI/TiRex-1.1-gifteval

#NPU

本仓库将 HuggingFace 上的 NX-AI/TiRex-1.1-gifteval(TiRexZero, 35M 参数, xLSTM sLSTM 架构, patch 32, 9分位数, 训练上下文 2048)适配为可在单卡昇腾 Ascend 910B(npu:0)上真实运行的 GitCode AI model 仓库。支持单变量时序的零样本概率预测(horizon 64),已在 npu:0 上完成真实推理与 CPU-NPU 一致性验证。

  • 模型原始仓库:https://huggingface.co/NX-AI/TiRex-1.1-gifteval
  • 权重:model.ckpt 141 MB, Lightning checkpoint, ~35M params, float32
  • 源实现:https://github.com/NX-AI/tirex(tirex.models.tirex.TiRexZero, tirex.ts 1.4.2)
  • 配置:12×sLSTMBlock + PatchedTokenizer + ResidualBlock,long period normalisation v1.1

任务与路由

项值
模型NX-AI/TiRex-1.1-gifteval(~35.3M params, 141 MB ckpt)
架构TiRexZero(PatchedTokenizer patch 32 + ResidualBlock + 12×sLSTMBlock embedding 512 heads 4 + Quantile Head 9×32)
任务时间序列预测 probabilistic forecasting(单变量分位数预测,horizon 64),quantiles 9
输入context [batch, time] float32(batch 2, time 512 → 内部至 2048)
输出quantiles [batch, horizon, 9] + mean [batch, horizon]
数据契约轴 [batch, time] → [batch, horizon, quantiles];context 512演示,horizon 64,patch 32,raw 数值
路由time-series 概率预测

环境

  • 昇腾 910B(Ascend910_9362),CANN 8.5.1,npu-smi 25.5.5
  • Python 3.11,torch 2.9.0+cpu + torch_npu 2.9.0.post1,tirex-ts 1.4.2

安装

pip install -r requirements.txt

NPU 推理

python inference.py

真实结果(NPU, 2026-08-20)

[DEVICE] torch.npu.is_available()=True, device_count=2, device_name=Ascend910_9362
[MODEL] loaded, first param device npu:0, dtype torch.float32
[MODEL] total params 35291200
[RESULT] NPU inference elapsed 0.7393s (synchronized)
[RESULT] quantiles shape (2, 64, 9) dtype torch.float32
[RESULT] quantiles[0,:3,:] [[5.9577, 5.9777, 5.9937, 6.0069, 6.0199, 6.0280, 6.0317, 6.0504, 6.0678], ...]
[BENCH] avg 0.7394s throughput 2.70 windows/s
[MEM] NPU:0 allocated 138.4 MB
[DONE] NPU inference SUCCESS

一致性

输出shapemax_absmean_abs阈值结果
quantiles[2,64,9]0.017940.00546atol 0.02 rtol 0.01PASS
mean[2,64]0.016520.00556atol 0.02 rtol 0.01PASS

阈值说明:sLSTMCell 内部 bf16,NPU/CPU 误差约 0.3%。

性能

context 512 → horizon 64, batch 2, float32, warmup 2 + 10 runs:avg 0.7394s per batch, throughput 2.70 windows/s, CPU 1.5738s (NPU 2.13×), 显存 138 MB.

证据图

  • assets/agent_workflow.png — 侦察、环境、加载、NPU 推理、一致性、benchmark
  • assets/npu_device_call.png — npu-smi、NPU 可用性、参数 device
  • assets/model_result.png — python inference.py 完整输出

agent_workflow npu_device_call model_result

限制

  • 仅验证单变量合成时序(context 512, horizon 64)
  • 未启用 resample_strategy frequency,权重为 ckpt
  • 内部 bf16 导致小误差已放宽阈值