
This directory is a complete, self-contained candidate delivery that adapts the
NeoQuasar/WindFM-Tokenizer time-series tokenizer for the Ascend NPU
(torch_npu on npu:1). It loads the real pinned pretrained weights
(model.safetensors) strictly, runs the full encoder → Binary-Spherical-
Quantizer → decoder forward path, and writes a machine-readable acceptance
record.
WindFM is an open-source foundation model for zero-shot wind power forecasting
(arXiv:2509.06311, MIT licensed). The
WindFM-Tokenizer converts continuous multivariate wind telemetry of shape
[batch, sequence, 6] into a discrete, hierarchical 20-bit binary spherical
code — a 10-bit stage-1 pre token plus a 10-bit stage-2 post token per
timestep — using a hybrid encoder / quantizer / decoder stack.
Architecture (WindFMTokenizer, from the official implementation at the pinned
revision):
| Component | Detail |
|---|---|
| Input embedding | nn.Linear(d_in=6, d_model=256) |
| Encoder | 3 × TransformerBlock (RoPE self-attention, RMSNorm, SwiGLU FFN) |
| Quantizer | BSQuantizer → BinarySphericalQuantizer (20-bit, group_size=5) |
| Decoder | 3 × TransformerBlock |
| Reconstruction heads | head (256→6) for stage-1-only and full 20-bit branches |
| Output | (z_pre, z) reconstructions, bsq_loss, 20-bit quantized, token z_indices |
The quantizer produces a discrete token index per timestep (0 … 2²⁰−1) and a
bipolar code vector ±1/√20 in 20 dimensions, so the continuous input is
represented as a sequence of discrete tokens that can later be consumed by the
WindFM decoder-only transformer.
| Field | Value |
|---|---|
| model | NeoQuasar/WindFM-Tokenizer |
| source revision (HF) | 8f610d340e9063493926dd4402667faafb9e857b |
| official implementation revision | f0fc5ec210c3f11caf06948c75a9e42503d114e3 |
| local weight | /work/pipeline/models/tabular16/windfm-tokenizer/model.safetensors |
| weight size | 15,842,376 bytes |
| weight SHA256 | 5e02f9f5bee945e1b0d9dbd82c2826bd45e9163f13771fbb3b0df997881116dc |
| device | npu:1 |
| engine | torch_npu |
| input shape | [batch, sequence, 6] |
| token code | 20-bit binary spherical code (10-bit stage 1 + 10-bit stage 2) |
| task / pipeline_tag | time-series-tokenization / time-series-forecasting |
| license | MIT (model), CC0 (test fixture) |
Machine-readable metadata is also in metadata.yaml.
The Ascend image already provides a matched, production torch / torch_npu pair. Never install or replace torch or torch_npu from ordinary PyPI.
| Package | Version | Origin | Used for |
|---|---|---|---|
torch | 2.9.0+cpu | Ascend image (matched) | base tensors, NN modules |
torch_npu | 2.9.0 | Ascend image (matched) | NPU accelerator backend |
einops | 0.8.1 | Aliyun mirror | model/module.py rearrange/reduce |
safetensors | 0.6.2 | Aliyun mirror | strict model.safetensors load |
pandas | 2.2.2 | Aliyun mirror | model/windfm.py module-scope import |
tqdm | 4.67.1 | Aliyun mirror | model/windfm.py module-scope import |
huggingface_hub | 0.33.1 | Aliyun mirror | PyTorchModelHubMixin base class |
Pillow | 10.4.0 | Aliyun mirror | scripts/render_assets.py only |
numpy | 1.26.4 | Base image | fixture + metrics |
npu:1)./usr/local/Ascend/ascend-toolkit/latest, set_env.sh)./usr/local/python3.11.14/bin/python3).torch is built +cpu (torch.version.cuda is None); torch.cuda.is_available() is False.Create the model-specific venv (reusing the image's torch/torch_npu through
--system-site-packages) and install only the missing packages from Aliyun:
python3 -m venv --system-site-packages \
/work/pipeline/runtime/venvs-tabular16/windfm-tokenizer-npu
/work/pipeline/runtime/venvs-tabular16/windfm-tokenizer-npu/bin/pip install \
-i https://mirrors.aliyun.com/pypi/simple/ \
einops==0.8.1 safetensors==0.6.2 pandas==2.2.2 tqdm==4.67.1 \
huggingface_hub==0.33.1 Pillow==10.4.0Recorded exact versions (verified in the venv): torch 2.9.0+cpu,
torch_npu 2.9.0, einops 0.8.1, safetensors 0.6.2, pandas 2.2.2,
tqdm 4.67.1, huggingface_hub 0.33.1, Pillow 10.4.0, numpy 1.26.4.
# 1) (if not already) load the Ascend environment
source /usr/local/Ascend/ascend-toolkit/set_env.sh
# 2) change into the delivery directory
cd /work/pipeline/jobs/tabular16/windfm-tokenizer/windfm-tokenizer-npu
# 3) optional: verify the NPU device
npu-smi info
# 4) run the exact end-to-end inference on npu:1
# (the provided runner also captures a live npu-smi monitor alongside)
bash scripts/run_inference_npu.sh \
--model-path /work/pipeline/models/tabular16/windfm-tokenizer \
--device npu:1 \
--output-json logs/npu_result.json \
--log logs/npu_inference.log \
--seq-len 16 --batch-size 1Optional flags: --dtype {float32,float16}, --seed 42.
The script exits 0 on success and non-zero on any NPU / weight / placement
failure.
Command (exactly as run, fresh process, concurrent npu-smi monitor):
bash scripts/run_inference_npu.sh \
--model-path /work/pipeline/models/tabular16/windfm-tokenizer \
--device npu:1 \
--output-json logs/npu_result.json \
--log logs/npu_inference.log \
--seq-len 16 --batch-size 1The runner starts the inference in the background, samples npu-smi info every
0.2 s into logs/npu_device_call.log while it is alive, records the exit code,
and merges real stderr back into the canonical logs/npu_inference.log.
Actual result (from logs/npu_inference.log, logs/npu_device_call.log and
logs/npu_result.json):
hardware_name=Ascend910B4-1 cann_version=8.5.1
torch=2.9.0+cpu torch_npu=2.9.0 device_index=1 pid=163124
strict_load missing=[] unexpected=[]
model_loaded seconds=0.331 num_params=3958042 param_dtype=torch.float32
[placement] input(x) -> npu:1 shape=(1, 16, 6)
[placement] reconstruction_stage1(z_pre) -> npu:1 shape=(1, 16, 6)
[placement] reconstruction_full(z) -> npu:1 shape=(1, 16, 6)
[placement] quantized(20bit) -> npu:1 shape=(1, 16, 20)
[placement] token_indices(z_indices) -> npu:1 shape=(1, 16)
[placement] loss(bsq_loss) -> npu:1 shape=()
forward_elapsed_seconds=0.451 encode_decode_elapsed_seconds=0.046
reconstruction_mae stage1=0.503038 full20bit=0.321169 roundtrip(half_decode)=0.321169
finite_all=true
token_stats full20bit: min=84649 max=1032574 unique=16/16
token_stats stage1(10bit): min=270 max=1022 unique=16/16
token_stats stage2(10bit): min=82 max=1008 unique=16/16
token_sample full20bit idx=901863 bits=11011100001011100111 s1=743 s2=880
bsq_loss=-0.055611
peak_memory_allocated_bytes=49499648
total_elapsed_seconds=2.845
exit_code=0The concurrent npu-smi monitor captured the python inference process
(PID 163124; host-namespace npu-smi PID 2579920) attached to NPU 1
(HBM 114 → 200 MB). See the rendered evidence below.

logs/npu_result.json (machine-readable acceptance record) contains:
| Field | Meaning |
|---|---|
engine / framework | torch_npu / pytorch |
source_revision / official_implementation_revision | pinned revisions |
assigned_device, device_index, npu_name, npu_device_name | npu:1, 1, Ascend910B4-1, Ascend910B4-1 |
cann_version, torch_version, torch_npu_version | runtime versions |
process_id, utc_time | OS PID and UTC capture time |
input_device, model_device, output_device, z_device, quantized_device, z_indices_device, loss_device | all npu:1 (asserted) |
npu_process_evidence | process_id, npu_smi_pid, max_process_memory_mb, npu_smi_samples_seen correlating the inference OS PID with the live npu-smi row on NPU 1 |
input_shape | [1, 16, 6] (batch, sequence, channels) |
codebook | codebook_dim=20, s1_bits=10, s2_bits=10, full vocab 2²⁰ |
reconstruction_mae | mean absolute error of z_pre (stage-1 only), z (full 20-bit), round-trip half decode |
bsq_loss | BSQuantizer loss (commit + entropy penalty; can be negative) |
token_stats.*.min/max/unique_count/total | token index range and unique-token count |
deterministic_token_sample | first token's full 20-bit index, bit string, s1/s2 indices, bipolar code |
quantized_sample | first token's 20-dim ±1/√20 code vector |
finite_checks | per-output finite-value assertions |
output | human-readable summary of the meaningful tokenizer output (token-index range/unique count, MAE, loss) |
test_input | fixture source, CC0 license, features, preprocessing |
weight_bytes / weight_sha256 | pinned local-weight integrity |
exit_code | explicit process exit code (0) |
inference.py hard-fails (non-zero exit) if any of the following is false:
torch.npu.is_available() is True;torch.cuda.is_available() is False (no CUDA neural path);torch.npu.set_device("npu:1") succeeds;load_state_dict(strict=True) has no missing/unexpected keys (the
sole documented non-persistent buffer tokenizer.bsq.group_codebook is
persistent=False in the official code and therefore absent by design);npu:1;CPU is used only for deterministic fixture generation, per-channel standardization, JSON serialization, hashing, and screenshot rendering.
NeoQuasar/WindFM-8.1M).model/ package is a verbatim, MIT-attributed copy of the official
implementation; no behavioral changes were made.model/ package
contains verbatim copies of windfm.py, module.py, __init__.py and the
MIT LICENSE from the pinned official revision
f0fc5ec210c3f11caf06948c75a9e42503d114e3.license: mit, pipeline_tag: time-series-forecasting.| Symptom | Likely cause | Fix |
|---|---|---|
torch.npu.is_available() is False | CANN env not loaded | source /usr/local/Ascend/ascend-toolkit/set_env.sh |
No module named 'einops' | venv deps not installed | run the Aliyun install block in 安装命令 |
| weight size/SHA mismatch | wrong weights | verify against the 精确元数据 pinned values |
strict weight load failed | key mismatch | do not random-init; report the missing/unexpected keys |
| OOM | batch/sequence too large | reduce --seq-len / --batch-size |
torch_npu import error | torch replaced from PyPI | recreate venv with --system-site-packages; never reinstall torch |
inference.py with --model-path, --device, --output-json (plus extras)model/ module with MIT attribution + license noticerequirements.txt (no downloadable torch replacement; image-supplied torch/torch_npu documented)readme.md and README.md byte-identicalmetadata.yaml (license, pipeline_tag, framework, Ascend/NPU/torch_npu/time-series/tokenizer tags, revisions, NPU device)logs/modelagent_session.log (sanitized chronological action transcript)logs/npu_inference.log + logs/npu_device_call.log from a fresh runlogs/npu_result.json (machine-readable acceptance record)assets/agent_workflow.png, assets/modelagent_live_session.png, assets/npu_device_call.png, assets/model_result.png rendered from real logs.gitignore (secrets, env, caches, bytecode, venvs, transient outputs)SHA256SUMS covering every intended public file except itself0, finite meaningful results, strict real-weight loading, no CPU/CUDA fallback markers