S
Solis_caser/MOMENT-1-small-Ascend-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

AutonLab/MOMENT-1-small 昇腾 NPU 适配

模型介绍

MOMENT-1-small 是面向时间序列任务的基础模型。本仓库固定上游模型版本,使用 torch_npu 将推理放到昇腾 NPU,并验证了预测任务的真实样例推理。

上游模型

上游模型:AutonLab/MOMENT-1-small。

固定 revision / checkpoint commit:411e288267f82cce86296dbe4d6c8bc533cc162f。

固定 checkpoint:model.safetensors,151615328 bytes,SHA-256:785e6c6f57ffa7cac7e2a1fff6369618d49f2f441563ddea76c866231e5aa877。

输入格式

输入为小端序 float32 时间序列 x_enc,shape 为 [1, 1, 512];input_mask 为全 1 的 int64 张量,shape 为 [1, 512]。可复现实例 moment-sine-cosine-512-f32 由 sin(2*pi*i/64)+0.25*cos(2*pi*i/17) 生成,i=0..511,共 2048 bytes,SHA-256 为 d40a52def4dd271ecd73057384674f3dd676a112e9f6bf40bc91887dc38c54d5。预测步长为 8,输出 shape 为 [1, 1, 8]。

NPU 环境

实测设备为 Ascend910,目标设备 npu:0;Python 3.11.14;torch 2.9.0+cpu;torch_npu 2.9.0.post1+gitee7ba04;CANN 8.5.1。推理过程使用 NPU 同步,并未使用 CPU fallback。

运行命令

先将固定 checkpoint 目录和 2048-byte 实例路径分别设置到 MOMENT_MODEL_DIR 与 MOMENT_SAMPLE,再执行:

export MOMENT_MODEL_DIR=/path/to/AutonLab-MOMENT-1-small
export MOMENT_SAMPLE=/path/to/moment-sine-cosine-512-f32.bin
python3 inference.py --model-dir "$MOMENT_MODEL_DIR" --sample "$MOMENT_SAMPLE" --device npu:0 --warmup 1 --runs 2 --seed 0

实际结果

实测真实样例输出为 forecast [1, 1, 8]、dtype float32、device npu:0,数值为 [-0.265547, -0.062929, -0.076634, -0.009477, -0.049849, -0.038295, 0.020615, -0.187625];最终单次耗时 0.008884 秒。

测试样例及输出

  • moment-sine-cosine-512-f32(输入 SHA-256 d40a52def4dd271ecd73057384674f3dd676a112e9f6bf40bc91887dc38c54d5):forecast

1,1,81,1,81,1,8

float32 =

−0.265547,−0.062929,−0.076634,−0.009477,−0.049849,−0.038295,0.020615,−0.187625-0.265547, -0.062929, -0.076634, -0.009477, -0.049849, -0.038295, 0.020615, -0.187625−0.265547,−0.062929,−0.076634,−0.009477,−0.049849,−0.038295,0.020615,−0.187625

;完整输出 SHA-256 9911664a0e34404e1860b6f2d917e51d552dc70050c304854b232674db6324c7。

性能参考

NPU 实测,范围 end\_to\_end,seed=0,input shape=`

1,1,5121, 1, 5121,1,512

,sample-set=moment-sine-cosine-512-f32@411e288267f82cce86296dbe4d6c8bc533cc162f(count=1,SHA-256 d40a52def4dd271ecd73057384674f3dd676a112e9f6bf40bc91887dc38c54d5),预热 1 次,测量 2 次,前后同步=True,batch=1,precision=float32`,median=0.0093175 秒,p95=0.009751 秒。

评测精度

本任务未执行数据集级精度评测,单样例输出不代表精度。原因:No pinned official task-quality dataset, scorer commit, and acceptance threshold are available; do not invent a quality score.

适配一致性

未执行数值一致性对照:No comparable CPU/NPU protocol is established by the sealed plan; CPU fallback and CPU-baseline comparison are explicitly forbidden. Numerical consistency is internal to the observed NPU run.

限制

本适配固定上述 checkpoint、revision、输入样例和运行环境;model.init() 会按上游 API 初始化 forecasting head。未声明数据集级精度,未覆盖未验证的任务类型、输入长度、设备和 CPU fallback。

许可证

上游模型卡核实许可证为 MIT,本适配说明遵循该许可证信息。

截图证据

Model Agent 工作流

昇腾 NPU 设备调用

模型真实推理结果