任务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,已验证 32/64/96),已在 npu:0 上完成真实推理与 CPU-NPU 一致性验证。
model.ckpt 141 MB, Lightning checkpoint, TiRexZeroConfig input_patch 32 / output_patch 32 / quantiles 9 / train_ctx 2048 / 12 blocks / embedding 512 / heads 4 / input_ff 2048, ~35M params, float32tirex.models.tirex.TiRexZero, tirex.ts 1.4.2, 论文 https://arxiv.org/abs/2505.23719)TiRexZero 12×sLSTMBlock(RMSNorm + sLSTMLayer + FeedForward) + PatchedTokenizer + ResidualBlock 输入/输出投影,long period normalisation (v1.1),GIFT-Eval 去重models/NX-AI-TiRex-1.1-gifteval/model.ckpt 并本地加载,正式推理不联网| 项 | 值 |
|---|---|
| 模型 | NX-AI/TiRex-1.1-gifteval(revision gifteval-1.1, ~35.3M params, 141 MB ckpt) |
| 架构 | TiRexZero(PatchedTokenizer patch 32 + ResidualBlock in/out + 12×sLSTMBlock (embedding 512, heads 4) + RMSNorm + Quantile Head 9×32) + sLSTMCellTorch (bf16 内部) |
| 任务 | 时间序列预测 probabilistic forecasting(单变量分位数预测,horizon 64),quantiles=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9] |
| 输入 | context shape [batch, time] float32(本仓 batch 2, time 512 → 内部截断/填充至 train_ctx 2048, patchify 32→64 tokens),prediction_length int |
| 输出 | quantiles shape [batch, horizon, 9] float32(分位数预测) + mean shape [batch, horizon] float32(中位数 q=0.5),output_transform 经 PatchedTokenizer 逆变换 |
| 数据契约 | 轴顺序 [batch, time] 输入 → [batch, horizon, quantiles] 输出;context 512(演示,实际支持 ≤2048 任意长度,<2048 用 NaN 前置填充,>2048 尾部截断),horizon 64(演示,任意>0 且按 patch 32 向上取整),频率不敏感(raw 数值),通道独立 单变量,缺失值用 NaN,缩放无(raw)但内部 tokenizer 对 patch 做归一化,轴顺序不可转置 |
| 路由 | time-series 概率预测(参考 time-series-models.md Toto/TiRex/FlowState 类),验收 forecast/quantiles 数值一致性、 throughput、显存,非表格分类 Top-5 |
表格数据类型关联:按任务标题归为“表格数据”,但实际架构为时序基础模型。时序可视为表格中时间-数值列的扩展,验收指标采用分位数/中位数数值一致性与性能,而非分类 logits;已保留轴顺序、dtype、窗口与分位数契约。
torch 2.9.0+cpu + torch_npu 2.9.0.post1,numpy 1.26.4,huggingface_hub,tirex-ts 1.4.2pip install -r requirements.txt模型权重需预先下载(model.ckpt)并置于以下任一路径(inference.py 按序查找):
/opt/atomgit/adapt-npu-agent/models/NX-AI-TiRex-1.1-gifteval/model.ckpt./NX-AI-TiRex-1.1-gifteval/model.ckptMODEL_CKPT 或 MODEL_DIR 指向文件/目录python inference.py行为:打印 npu-smi 与 torch.npu 设备信息,从本地 ckpt 加载 TiRexZero 到 npu:0,构造确定性合成数据 [2,512],执行 forecast horizon 64,warmup 2次 + 同步计时,报告 quantiles [2,64,9] 与 mean [2,64]、throughput 与显存,异常非零。
[DEVICE] torch.npu.is_available()=True, device_count=2, device_name=Ascend910_9362
[MODEL] loading from /opt/atomgit/adapt-npu-agent/models/NX-AI-TiRex-1.1-gifteval/model.ckpt
[MODEL] loaded, first param device npu:0, dtype torch.float32
[MODEL] config input_patch_size=32 output_patch_size=32 quantiles=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9] train_ctx_len=2048 blocks=12 embedding_dim=512
[MODEL] total params 35291200
[DATA] context shape (2, 512) dtype torch.float32 device cpu
[DATA] context[0,:5] [0.5529, 0.5786, 0.6502, 0.7301, 0.7492]
[RESULT] NPU inference elapsed 0.7393s (synchronized)
[RESULT] quantiles shape (2, 64, 9) dtype torch.float32 device cpu
[RESULT] quantiles[0,:3,:] [[5.9577, 5.9777, 5.9937, 6.0069, 6.0199, 6.0280, 6.0317, 6.0504, 6.0678], [6.0762, 6.0984, 6.1121, 6.1250, 6.1394, 6.1458, 6.1575, 6.1732, 6.1947], [6.1885, 6.2059, 6.2273, 6.2413, 6.2516, 6.2660, 6.2774, 6.2929, 6.3129]]
[RESULT] mean[0,:5] [6.0199, 6.1394, 6.2516, 6.3564, 6.4493]
[BENCH] avg 0.7394s min 0.7339 max 0.7460 p50 0.7401 p90 0.7435 p95 0.7448 throughput 2.70 windows/s
[MEM] NPU:0 allocated 138.4 MB reserved 290.0 MB max_allocated 275.9 MB
[DONE] NPU inference SUCCESS同一权重、输入、预处理、dtype float32、seed 0、eval mode、同步后比较:
| 输出 | shape | max_abs | mean_abs | 阈值 atol/rtol | 结果 |
|---|---|---|---|---|---|
| quantiles | [2,64,9] | 0.01794 | 0.00546 | atol 0.02, rtol 0.01 | PASS |
| mean (median) | [2,64] | 0.01652 | 0.00556 | atol 0.02, rtol 0.01 | PASS |
阈值说明:sLSTMCell 内部强制 bf16(cell.py:55-57),NPU 与 CPU bf16 累积误差约 0.3%(输出尺度 5-6),从 FP32 默认 1e-4/1e-3 放宽至 0.02/0.01;finite 与 shape 严格一致,无 CPU fallback(首参 device npu:0)。
context 512 → horizon 64, batch 2, float32, warmup 2 次后测 10 次,torch.npu.synchronize():
| 阶段 | 值 |
|---|---|
| NPU avg / min / max / p50 / p90 / p95 | 0.7394 / 0.7339 / 0.7460 / 0.7401 / 0.7435 / 0.7448 s per batch |
| NPU throughput | 2.70 windows/s |
| CPU avg | 1.5738 s per batch, NPU 加速 2.13× |
| 峰值显存 NPU:0 | allocated 138.4 MB / reserved 290.0 MB / max_allocated 275.9 MB |
三张 PNG 由 xterm.js 根据本次真实日志生成(scripts/render_xterm_evidence.mjs --style raw,深灰背景、白字等宽、提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$):
assets/agent_workflow.png — 侦察、环境、加载、NPU 推理、一致性、benchmark 与校验assets/npu_device_call.png — npu-smi、NPU 可用性、模型首参 device/dtype、输入输出 deviceassets/model_result.png — 默认 python inference.py 完整输出
