liucu/AutonLab-MOMENT-1-large-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

AutonLab/MOMENT-1-large NPU on Ascend 910

#NPU

模型简介

  • 模型名称: AutonLab/MOMENT-1-large
  • 权重地址: https://huggingface.co/AutonLab/MOMENT-1-large
  • 任务类型: 时间序列重构 (reconstruction) / 通用时序基础模型,支持 forecasting / classification / anomaly detection / imputation
  • 架构: MOMENT encoder_only,Transformer backbone google/flan-t5-large (T5, d_model=1024, d_ff=2816, 24 encoder layers + 24 decoder layers, 16 heads, vocab 32128), patch_len=8, patch_stride=8, seq_len=512
  • 权重大小: 1.3 GB safetensors (总 2.77 GB 含 pytorch_model.bin), 预计峰值显存 ~1.4 GB (实测 1394 MB allocated, 1421 MB max)
  • 许可证: MIT
  • 来源: AutonLab Timeseries-PILE 预训练
  • 推理入口: python inference.py 默认在 npu:0 完成真实NPU推理

数据契约

  • 输入契约: x_enc: [batch, n_channels, seq_len] float32, input_mask: [batch, seq_len] float32 (全1表示无缺失), 轴顺序明确为 [B, C, T]
  • 预处理: 无归一化缩放 (原始合成数据直接输入), dtype float32, 随机种子 42 固定生成, 列/通道顺序固定
  • 样例数据: 合成时序 batch=2, n_channels=3, seq_len=512
    • 通道0: sin(5 periods) + 0.5 cos(2 periods) + N(0,0.05)
    • 通道1: 0.01*t trend + 0.8 sin(3 periods) + N(0,0.03)
    • 通道2: 0.6 sin(8 periods) + 0.4 sin(12 periods)
  • 输出契约: reconstruction: [batch, n_channels, seq_len] float32, 与输入同形状, 逆变换已完成 (直接重构值)
  • 预处理是否计时: 性能计时仅包含模型推理,不含数据生成

环境

  • NPU: Ascend910_9362, 2 devices, 选中 npu:0
  • CANN: 8.5.1 (ASCEND_TOOLKIT_HOME=/usr/local/Ascend/cann-8.5.1)
  • Python: 3.11.14
  • torch: 2.9.0+cpu
  • torch_npu: 2.9.0.post1+gitee7ba04
  • transformers: 4.57.6
  • numpy: 1.26.4
  • momentfm: 0.1.5 (git+https://github.com/moment-timeseries-foundation-model/moment.git)
  • npu-smi: 25.5.5, Health OK

安装

pip install -r requirements.txt

NPU 推理

python inference.py

真实日志片段 (npu:0):

[INFO] model_name: AutonLab/MOMENT-1-large
[INFO] npu_available: True
[INFO] npu_device_name: Ascend910_9362
[INFO] weight bytes: 1385501256 (1321.3 MB)
[INFO] first param device after to(npu:0): npu:0
[INFO] input shape: x_enc (2, 3, 512) input_mask (2, 512)
[INFO] reconstruction shape: (2, 3, 512)
[INFO] NPU inference time (single batch, sync): 22.19 ms
[INFO] avg latency over 10 runs: 21.46 ms
[INFO] throughput: 93.2 windows/s (143135.5 points/s)
[INFO] npu memory allocated: 1394.4 MB, max: 1421.4 MB
[SUCCESS] MOMENT-1-large NPU reconstruction completed

真实结果

  • CPU 基线: shape (2,3,512) mean 0.869032 std 1.445462
  • NPU 结果: shape (2,3,512) mean 0.869033 std 1.445462
  • 有限值检查: finite True

一致性

  • 比较工具: .opencode/skills/npu-adapt-skills/scripts/compare_outputs.py --task regression
  • 结果: max_abs_error 2.74e-06 mean 3.05e-07 passed true (FP32 atol 1e-4 rtol 1e-3)
  • 是否发生 CPU fallback: 否

性能

  • 计时方式: 每轮前后 torch.npu.synchronize()
  • 预热: 2 次 warmup, 正式 10 次
  • 形状: batch=2 seq_len=512 n_channels=3 patch_len=8 dtype float32
  • 结果: avg 21.46 ms, throughput 93.2 windows/s, 143135.5 points/s, 峰值 1394 MB

证据图

三图由 xterm.js 根据本次真实日志渲染生成 (raw 风格, 深灰背景, 提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$):

  • 工作流: assets/agent_workflow.png
  • 设备调用: assets/npu_device_call.png
  • 模型结果: assets/model_result.png

agent workflow npu device call model result

限制

  • 单卡 npu:0 推理, 未验证多卡/量化/分布式
  • 仅验证重构任务 smoke consistency
  • FP32 精度, 未测试 FP16/BF16
  • 合成数据验证, 真实业务数据需自行验证缩放与频率