r
redannancy/WindFM-Tokenizer
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

WindFM-Tokenizer — Ascend NPU Serving Kit

MIT License Ascend 910B vLLM-Ascend

Introduction

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:

ItemDetail
Self-contained model codeinference.py — no dependency on the upstream WindFM checkout
Verified weight loadingstrict key-by-key load of model.safetensors (15.8 MB, fp32, 3.96 M params)
NPU serviceHTTP server on Ascend 910B via torch_npu inside the vLLM-Ascend 0.18.0 stack
Three REST endpointsencode / decode / reconstruct
Real measurementslatency, accuracy and NPU footprint captured on a 910B device

Validation Environment

The kit was built and validated in this environment:

Hardware

  • Ascend 910B (Ascend910_9362) — 2 cards, 64 GB HBM each, aarch64 host, 256 GB RAM

Software

  • OS: Linux (aarch64) · Python 3.11.14
  • PyTorch 2.9.0 · torch_npu 2.9.0.post1 · CANN 8.5.1
  • vLLM 0.18.0 · vllm-ascend toolchain
  • numpy · pandas · safetensors

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))"

Service Startup

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.safetensors

If 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 8021

3. Talk to it:

EndpointVerbPurpose
/healthGETliveness probe
/GETmodel + device metadata
/v1/encodePOSTseries → s1/s2 token arrays
/v1/decodePOSTtoken arrays → reconstructed series
/v1/reconstructPOSTseries → 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.

Smoke Test

Run a one-shot sanity check with synthetic input:

python3 inference.py --model-dir . --mode smoke

Expected 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].

Performance Reference

Latency measured on Ascend 910B, single card, input [1, 240, 6] (fp32):

OperationLatency
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):

MetricIdleUnder load
AICore utilization0 %17–18 %
Board power~165 W~182 W
Server process HBM226 MB226 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.

Accuracy Evaluation

Fidelity was measured on the official WindFM sample (121522.csv, first 240 steps, z-scored, clipped to ±5):

MetricValue
RMSE0.0819
MAE0.0634
Pearson correlation0.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.

Operational Notes

  1. Channel order matters. The six input channels are read positionally as wind_speed, wind_direction, power, density, temperature, pressure. Do not reorder columns client-side unless you retrain the codec.
  2. Normalize before you send. Feed the API z-scored data (per channel mean/std) clipped to ±5, as the upstream pipeline does. The server does not normalize for you.
  3. Causal attention. Both encoder and decoder are causal along the time axis. Shorter sequences are fine; memory grows linearly with seq_len.
  4. Multi-instance. To run several services, just change --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.
  5. Warm-up. Expect ~270 ms on the very first request (graph compilation), then sub-20 ms afterwards. Bake this into your latency budget or pre-warm at startup.
  6. Backend scale-out. The bundled server is single-process and good for development/CI. For high QPS, put uvicorn/Gunicorn in front or load-balance multiple instances.
  7. Weights & license. Checkpoint is MIT-licensed from NeoQuasar/WindFM-Tokenizer (WindFM project by shiyu-coder). Attribution appreciated in downstream publications.
  8. Precision. Ships fp32; switching to bf16 changes reconstruction error — validate against the numbers above before enabling mixed precision in production.

Citation

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}}
}

License

MIT. The underlying model weights are MIT-licensed as well.