#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).
NeoQuasar/WindFM (transformer weights, ~8.1M params, config: s1_bits=10, s2_bits=10, n_layers=4, d_model=256, n_heads=8)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)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).
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[-5, 5]context_length (lookback) default 240; prediction_length (horizon) default 80pred_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).
torch.npu.is_available() == Truepip install -r requirements.txt# 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.csvThe 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.
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 SUCCESSThe 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.
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%2231.2 ms (includes dynamic-shape/ACL graph compilation)sample_count=50, pred_len=80): avg 1364.7 ms, p95 1384.5 ms, throughput 0.73 series/storch.npu.synchronize() around each call; preprocessing (CSV read / scaling) is not included.The three images below were generated by xterm.js from this run's real captured logs (not hand-edited).
| Image | Description |
|---|---|
![]() | Full adaptation workflow log |
![]() | NPU availability, device name, model tensor device/dtype |
![]() | Default python inference.py real output |
MW ground truth is large because the checkpoint predicts normalized power; deploy with site-appropriate inverse scaling.npu:0 inference only; no distributed/parallel decoding implemented here.