AutonLab/MOMENT-1-large 运行于 Ascend 910B npu:0,是一款时间序列基础模型(T5-large 骨干,seq_len 512,patch 8,d_model 1024,24 层 / 16 头 / d_ff 2816 / gated-gelu,共 223 个参数组),用于重构、异常检测与零样本预测。
MOMENTPipeline + T5EncoderModel(google/flan-t5-large,24 层,16 头,d_ff 2816,gated-gelu)、RevIN、Patching(8/8)、PatchEmbedding(1024)、T5 编码器、PretrainHead/ForecastingHead[batch, n_channels, seq_len];模型 tokenizer 期望 [B, C, T],然后 patch 为 [B*C, n_patches, d_model]。输入不是 [B,T,C]。Channel=1 表示单变量;多变量则使用 n_channels>1,布局相同。torch.nan_to_num 用于拦截 NaN/inf。[1,1,512],与输入形状相同(预训练头 Linear 1024->8 后 flatten)。预测:[1,1,96],预测跨度 96。嵌入:[batch, d_model] 或 [batch, n_patches, d_model],reduction 采用 mean。[B,C,T]、T==512、数值有限,并拒绝不匹配。torch.npu.is_available()==True,device_count==2,get_device_name(0)==Ascend910_9362,全部 223 个参数组均位于 npu:0,无 CPU 回退(ArgSort 在 AI CPU 上运行,属预期行为;模型算子无回退)pip install -r requirements.txt
# requires CANN toolkit at /usr/local/Ascend/cann-8.5.1 and torch_npu
# momentfm is vendored: pip install git+https://github.com/moment-timeseries-foundation-model/moment.gitpython inference.py
# defaults: --task reconstruction --seq-len 512 --seed 123 --device npu:0
python inference.py --task forecasting
python inference.py --task embedding
python inference.py --benchmark # warmup 3 + test 10MOMENTPipeline.from_pretrained(local_path, model_kwargs={task_name}),再执行 .init(),然后执行 .to("npu:0"),校验 next(param).device==npu:0,并打印 dtype 与 devicemodel(x_enc, input_mask) 执行重建/预测,调用 model.embed(...) 提取嵌入;计时前后均调用 torch.npu.synchronize(),内部包含 RevIN。First param device: npu:0、NPU device name: Ascend910_9362、Input device: npu:0、Output device: npu:0,223/223 个参数位于 NPU,已使用 torch.npu.synchronize()cpu_output.npy/npu_output.npy,形状为 [1,1,512],float32max_abs_error 1.66e-06, mean_abs_error 2.89e-07,均为有限值,形状一致python .opencode/skills/npu-adapt-skills/scripts/compare_outputs.py --cpu working_moment_large/cpu_output.npy --npu working_moment_large/npu_output.npy --task forecasting --atol 1e-4 --rtol 1e-3 → PASSED(forecasting 任务标志用于通用浮点比较)torch.npu.synchronize();预热 3 次,测试 10 次三张 PNG 均由 scripts/render_xterm_evidence.mjs --style raw 从真实日志生成(xterm.js 为深灰背景白色前景,命令行提示符 atomgit@pod-a94f8701860f4700b161b00e290de466:~$ 仅作展示)。
—— 检查、环境、下载、CPU 基线、NPU 推理、对比、基准测试、验证。
—— npu-smi、check_npu、设备名称、参数 dtype/device、输入/输出设备。
—— python inference.py 完整输出、schema、预测/重建、计时、SUCCESS。assets/ 中恰好包含由 manifest 从 logs/workflow.log、logs/device.log、logs/inference.log 生成的上述三个文件。
.
├── inference.py
├── readme.md
├── requirements.txt
└── assets/
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png