jsjs1258/AutonLab-MOMENT-1-base-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

AutonLab/MOMENT-1-base #NPU

MOMENT (A Family of Open Time-series Foundation Models) is a general-purpose time-series foundation model based on a T5-encoder backbone with patching + RevIN normalization. This repo adapts AutonLab/MOMENT-1-base (pre-trained reconstruction head) to run real zero-shot forecasting on a single Ascend 910B NPU (npu:0).

  • Model: AutonLab/MOMENT-1-base (revision main)
  • Task: zero-shot short-horizon forecasting (forecast_horizon=48)
  • Backend: momentfm==0.1.4 MOMENTPipeline + T5EncoderModel
  • Device: Ascend910_9362 (NPU), dtype torch.float32
  • License: MIT

Data contract

  • Dataset: ETTh1 (public, "Electricity Transformer Temperature, hourly"), MIT-compatible research dataset.
  • File: ETTh1.csv, date column + 7 value channels [HUFL, HULL, MUFL, MULL, LUFL, LULL, OT], 17420 rows, hourly, time-sorted, no missing values.
  • SHA-256: f18de3ad269cef59bb07b5438d79bb3042d3be49bdeecf01c1cd6d29695ee066
  • Axis order: [batch, channel, time] (x_enc), context window L=512, forecast horizon H=48.
  • The last L timesteps are used as context; the forecast never crosses the data boundary.
  • Zero-shot short_forecast masks the final H timesteps and reconstructs them with the pre-trained head (no task-specific fine-tuning). RevIN normalization is applied inside the model and inverted on output.

Environment

  • Python 3.11.14
  • torch 2.9.0+cpu, torch-npu 2.9.0.post1+gitee7ba04, CANN 8.5.1
  • momentfm 0.1.4, transformers 4.33.3, numpy 1.26.4, pandas 3.0.2

Install

pip install -r requirements.txt

NPU inference

python inference.py

The script checks torch.npu.is_available(), moves the model and every tensor to npu:0, runs the forecast, calls torch.npu.synchronize() for timing, and writes inference_result.json (exit 0 = success). Model weights are downloaded once via huggingface_hub (respecting HF_ENDPOINT) or loaded from --model-dir if provided.

Real result (NPU)

Run on single npu:0 (Ascend910_9362), ETTh1 last-512 context, 48-step forecast:

{"device_name": "Ascend910_9362", "output_shape": [1, 7, 48], "elapsed_sec": 0.1424, "status": "PASS"}

Sample forecast (OT channel, last 5 steps): [8.4383, 9.0451, 10.7153, 8.1603, 8.6551]

CPU-NPU consistency

Same weights, input, preprocessing, seed and dtype (fp32) on CPU and NPU; raw forecast tensors compared.

metricvalue
taskregression (forecast tensor)
atol / rtol1e-4 / 1e-3
max abs error1.001e-05
mean abs error1.021e-06
resultPASS

Performance (NPU)

batch=4, input [4, 7, 512], forecast_horizon=48, warmup 3, timed 10, torch.npu.synchronize() per round.

metricvalue
first run (compile)0.1360 s
avg0.0126 s
min / max0.0125 / 0.0127 s
p50 / p90 / p950.0126 / 0.0127 / 0.0127 s
throughput318.01 windows/s
peak NPU memory517.11 MB

Evidence

The three images below are rendered by xterm.js from the real captured logs of this adaptation run (workflow, device check, and default python inference.py).

imagecontent
assets/agent_workflow.pngrecon, dataset inspect, model download, load, NPU inference, consistency, benchmark, submission validation
assets/npu_device_call.pngnpu-smi info, NPU availability, device name, parameter device/dtype, input/output tensor device
assets/model_result.pngfull default python inference.py output with schema/window summary, real forecast, sync timing and status

Limitations

  • Only the pre-trained reconstruction head is used (zero-shot short-horizon forecast). Long-horizon forecasting / classification heads are randomly initialized and require fine-tuning.
  • Consistency is a smoke check on one fixed window, not a full benchmark suite.
  • inference.py downloads the dataset from the public ETDataset URL on first run; set --data to a local CSV to run fully offline.
  • Peak memory and latency measured on the target 910B single card.