WindFM-Tokenizer is the discrete bottleneck of the WindFM wind-power forecasting foundation model. It turns a multivariate wind time series — wind speed, wind direction, active power, air density, temperature and pressure (six channels) — into two compact discrete token streams, s1 and s2, and can also map those tokens back to a continuous series. Think of it as a learned lossy codec for wind signals: the encoder fuses the six channels, a binary spherical quantizer (BSQ) snapshots the latent into 20 sign bits, and the decoder reconstructs the original channels.
This repository is a ready-to-run serving kit for running that tokenizer natively on Huawei Ascend NPUs. Everything you need to get from "checkpoint in hand" to "HTTP endpoint answering requests" is included, plus measured numbers so you can size your own deployment.
What you get out of the box:
| Item | Detail |
|---|---|
| Self-contained model code | inference.py — no dependency on the upstream WindFM checkout |
| Verified weight loading | strict key-by-key load of model.safetensors (15.8 MB, fp32, 3.96 M params) |
| NPU service | HTTP server on Ascend 910B via torch_npu inside the vLLM-Ascend 0.18.0 stack |
| Three REST endpoints | encode / decode / reconstruct |
| Real measurements | latency, accuracy and NPU footprint captured on a 910B device |
The kit was built and validated in this environment:
Hardware
Ascend910_9362) — 2 cards, 64 GB HBM each, aarch64 host, 256 GB RAMSoftware
A note on the stack: vLLM-Ascend is the deployment layer here, but WindFMTokenizer is an encoder–decoder tokenizer, not a causal language model, so it is not part of vLLM's model registry. Serving is therefore done with torch_npu on the same Ascend runtime that vLLM-Ascend builds on — the vLLM engine itself is not used to host this model.
pip install torch torch_npu numpy pandas safetensors
python3 -c "import torch_npu; print(torch_npu.is_available(), torch_npu.get_device_name(0))"1. Fetch the checkpoint (GitCode mirror, LFS-aware):
git clone https://gitcode.com/hf_mirrors/NeoQuasar/WindFM-Tokenizer.git
curl -L -o model.safetensors \
https://ai.gitcode.com/hf_mirrors/NeoQuasar/WindFM-Tokenizer/resolve/main/model.safetensorsIf GitCode is unreachable, the same files are mirrored on ModelScope and HuggingFace (NeoQuasar/WindFM-Tokenizer).
2. Launch the server:
python3 inference.py --model-dir /path/to/windfm-tokenizer --mode server --host 0.0.0.0 --port 80213. Talk to it:
| Endpoint | Verb | Purpose |
|---|---|---|
/health | GET | liveness probe |
/ | GET | model + device metadata |
/v1/encode | POST | series → s1/s2 token arrays |
/v1/decode | POST | token arrays → reconstructed series |
/v1/reconstruct | POST | series → reconstruction + tokens + error metrics |
Minimal example:
curl -s http://127.0.0.1:8021/v1/encode \
-H "Content-Type: application/json" \
-d '{"task":"encode","data":[[[0.1,0.2,0.3,0.4,0.5,0.6]]]}'Payloads are plain JSON; data is a [batch, seq_len, 6] float array. A ready-made client (inference_test.py) is included in the working tree for reference.
Run a one-shot sanity check with synthetic input:
python3 inference.py --model-dir . --mode smokeExpected output (measured):
[Smoke] 前向推理成功,耗时 270.1 ms
[Smoke] 重建形状 z_full=(1, 32, 6), z_pre=(1, 32, 6)
[Smoke] s1 token 范围: [88, 776], s2 token 范围: [27, 1020]Checks covered: weights load with strict=True, every operator runs on NPU without fallback, output shape matches input, token values stay within the 10-bit domain [0, 1023].
Latency measured on Ascend 910B, single card, input [1, 240, 6] (fp32):
| Operation | Latency |
|---|---|
| First request (graph compile) | ~270–283 ms |
Steady-state reconstruct | ~13.6 ms / request |
encode only | ~5.6 ms |
decode only | ~11.5 ms |
Throughput: ~70 requests/s on the built-in single-threaded HTTP server. The 13.6 ms figure is stable across a run of 8 back-to-back requests (σ < 1 ms).
NPU footprint (npu-smi, sampled around an inference burst):
| Metric | Idle | Under load |
|---|---|---|
| AICore utilization | 0 % | 17–18 % |
| Board power | ~165 W | ~182 W |
| Server process HBM | 226 MB | 226 MB |
The model is small (~4 M params); the bottleneck is host-side request handling rather than NPU compute, so a production deployment should focus on a threaded/async server layer rather than bigger batches.
Fidelity was measured on the official WindFM sample (121522.csv, first 240 steps, z-scored, clipped to ±5):
| Metric | Value |
|---|---|
| RMSE | 0.0819 |
| MAE | 0.0634 |
| Pearson correlation | 0.9967 |
s1 token range observed | [1, 1023] |
s2 token range observed | [17, 1020] |
The 0.9967 correlation means the 20-bit codebook retains essentially all signal structure — decode quality is more than adequate as the conditioning input for downstream WindFM forecasting. Expected reconstruction error on normalized data is below 0.1 RMSE for lookback horizons up to 240 steps.
wind_speed, wind_direction, power, density, temperature, pressure. Do not reorder columns client-side unless you retrain the codec.seq_len.--port; each instance pins one NPU via ASCEND_VISIBLE_DEVICES. Ports 8000/8001/8010 on the test host are used by other tenants — pick a free one.NeoQuasar/WindFM-Tokenizer (WindFM project by shiyu-coder). Attribution appreciated in downstream publications.If this kit or the WindFM tokenizer is useful in your work:
@misc{windfm2025,
author = {shiyu-coder},
title = {WindFM: Wind Power Forecasting Foundation Model},
year = {2025},
howpublished = {\url{https://github.com/shiyu-coder/WindFM}}
}MIT. The underlying model weights are MIT-licensed as well.