jsjs1258/NeoQuasar-WindFM-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

WindFM - NPU (Ascend 910)

#NPU

WindFM is an open-source foundation model for zero-shot wind power forecasting (paper: arXiv:2509.06311). It uses a discretize-and-generate framework: a specialized time-series tokenizer (WindFMTokenizer) converts continuous multivariate inputs (wind speed, wind direction, power, density, temperature, pressure) into discrete hierarchical tokens, and a decoder-only Transformer (WindFM) autoregressively generates future token sequences to produce deterministic and probabilistic wind-power forecasts.

This repository adapts the original Hugging Face checkpoint (NeoQuasar/WindFM + NeoQuasar/WindFM-Tokenizer) to run real inference on a single Huawei Ascend 910 NPU (npu:0).

Model / Revision

  • Model: NeoQuasar/WindFM (transformer weights, ~8.1M params, config: s1_bits=10, s2_bits=10, n_layers=4, d_model=256, n_heads=8)
  • Tokenizer: NeoQuasar/WindFM-Tokenizer (d_in=6, d_model=256, n_heads=4, n_enc_layers=4, n_dec_layers=4, s1_bits=10, s2_bits=10, group_size=5)
  • Architecture family: Decoder-only Transformer + BSQ time-series tokenizer
  • Task: Time-series (probabilistic) forecasting — wind power
  • License: MIT

Weights are not committed to this repo; inference.py downloads them via huggingface_hub.snapshot_download on first run (or you can place them in local models/ dirs).

Data Contract

WindFM expects an hourly, UTC wind-farm time series with exactly these columns (order preserved):

time, wind_speed, wind_direction, power, density, temperature, pressure

  • time: datetime with UTC timezone (e.g. 2007-01-05 04:00:00+00:00)
  • power: target variable (wind power), must be included
  • No missing values are allowed in the feature columns
  • The model normalizes input with per-feature mean/std and clips to [-5, 5]
  • context_length (lookback) default 240; prediction_length (horizon) default 80
  • Output is a probabilistic forecast: pred_len x sample_count array of power samples (quantiles p10/p50/p90 are derived for reporting)

The validation run in this repo uses the official examples/data/121522.csv sample (420 rows, hourly, UTC).

Environment

  • Huawei Ascend 910 (Ascend910_9362), 64 GB HBM
  • CANN / torch_npu with torch.npu.is_available() == True
  • Python 3.11, PyTorch 2.9, torch_npu, einops 0.8.1

Installation

pip install -r requirements.txt

NPU Inference

# Option A: auto-download weights into ./models
python inference.py

# Option B: use pre-downloaded local weights
python inference.py --model-dir models/windfm --tokenizer-dir models/windfm-tokenizer --data data/sample_wind_farm_data.csv

The default command runs the full pipeline on npu:0: loads weights, builds input windows, runs autoregressive token generation, computes power quantiles, reports the real forecast, and prints sync timing and status.

Real Result (Ascend 910, npu:0)

Default run on examples/data/121522.csv with lookback=240, pred_len=80, sample_count=50, max_context=512:

[device] torch=2.9.0+cpu npu_available=True device=npu:0 device_name=Ascend910_9362
[model] WindFM ... device=npu:0 dtype=torch.float32 n_params=4.10M
[bench] first_run(compile)=2231.2 ms samples=50
[bench] runs=10 avg=1364.7ms min=1349.5ms max=1391.9ms p50=1361.8ms p90=1377.1ms p95=1384.5ms series/s=0.73
[result] power_q50[:8]=[0.284, 0.308, 0.353, 0.403, 0.433, 0.507, 0.731, 1.363]
[metric] MAE(q50 vs GT)=3.2193 RMSE(q50 vs GT)=4.0289
[metric] prediction tensor finite=True shape=(80, 50)
[status] NPU inference SUCCESS

The forecast tensor is finite and has the expected shape (pred_len, sample_count). Note: the foundation model emits forecasts in its normalized power scale; raw MW values in the sample CSV produce a large absolute MAE, which reflects the pretraining-data-scale mismatch of the checkpoint rather than an NPU issue.

Consistency (CPU vs NPU)

The same weights, input window, preprocessing, dtype (fp32) and seed were used on CPU and npu:0. Output logits from the tokenizer encoder and the transformer decode_s1/decode_s2 paths were compared with compare_outputs.py (atol=1e-4, rtol=1e-3):

  • s1 logits: max_abs_error 8.58e-06, argmax match 100%
  • s2 logits: max_abs_error 1.24e-05, argmax match 100%
  • Result: PASS (both CPU and NPU run on identical weights, no CPU fallback)

Performance

  • First run (compile): 2231.2 ms (includes dynamic-shape/ACL graph compilation)
  • Stable inference (10 runs after warmup, sample_count=50, pred_len=80): avg 1364.7 ms, p95 1384.5 ms, throughput 0.73 series/s
  • Timing uses torch.npu.synchronize() around each call; preprocessing (CSV read / scaling) is not included.

Evidence

The three images below were generated by xterm.js from this run's real captured logs (not hand-edited).

ImageDescription
agent_workflowFull adaptation workflow log
npu_device_callNPU availability, device name, model tensor device/dtype
model_resultDefault python inference.py real output

Limitations

  • Absolute forecast error vs raw MW ground truth is large because the checkpoint predicts normalized power; deploy with site-appropriate inverse scaling.
  • The model is released for research use (MIT); verify on your own wind-farm data before operational use.
  • Single-device npu:0 inference only; no distributed/parallel decoding implemented here.