atlasleong/windfm-tokenizer-npu
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

NeoQuasar/WindFM-Tokenizer — Ascend NPU delivery

workflow

目录 / Contents

  • 模型简介 / Model introduction
  • 精确元数据 / Exact metadata
  • 环境依赖清单 / Dependency matrix
  • CANN / 镜像假设 / CANN & image assumptions
  • Aliyun 安装命令 / Aliyun install commands
  • 分步推理操作流程 / Step-by-step inference commands
  • 完整测试用例 / Complete test case
  • 输出结果 / Output field interpretation
  • NPU-only 断言 / NPU-only assertions
  • 局限性 / Limitations
  • 来源与许可证 / Provenance & license
  • 故障排查 / Troubleshooting
  • 验收清单 / Acceptance checklist

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

ComponentDetail
Input embeddingnn.Linear(d_in=6, d_model=256)
Encoder3 × TransformerBlock (RoPE self-attention, RMSNorm, SwiGLU FFN)
QuantizerBSQuantizer → BinarySphericalQuantizer (20-bit, group_size=5)
Decoder3 × TransformerBlock
Reconstruction headshead (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.


精确元数据

FieldValue
modelNeoQuasar/WindFM-Tokenizer
source revision (HF)8f610d340e9063493926dd4402667faafb9e857b
official implementation revisionf0fc5ec210c3f11caf06948c75a9e42503d114e3
local weight/work/pipeline/models/tabular16/windfm-tokenizer/model.safetensors
weight size15,842,376 bytes
weight SHA2565e02f9f5bee945e1b0d9dbd82c2826bd45e9163f13771fbb3b0df997881116dc
devicenpu:1
enginetorch_npu
input shape[batch, sequence, 6]
token code20-bit binary spherical code (10-bit stage 1 + 10-bit stage 2)
task / pipeline_tagtime-series-tokenization / time-series-forecasting
licenseMIT (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.

PackageVersionOriginUsed for
torch2.9.0+cpuAscend image (matched)base tensors, NN modules
torch_npu2.9.0Ascend image (matched)NPU accelerator backend
einops0.8.1Aliyun mirrormodel/module.py rearrange/reduce
safetensors0.6.2Aliyun mirrorstrict model.safetensors load
pandas2.2.2Aliyun mirrormodel/windfm.py module-scope import
tqdm4.67.1Aliyun mirrormodel/windfm.py module-scope import
huggingface_hub0.33.1Aliyun mirrorPyTorchModelHubMixin base class
Pillow10.4.0Aliyun mirrorscripts/render_assets.py only
numpy1.26.4Base imagefixture + metrics

CANN / 镜像假设

  • Hardware: Ascend 910B4 (8 devices visible; this delivery is pinned to npu:1).
  • CANN toolkit: 8.5.1 (/usr/local/Ascend/ascend-toolkit/latest, set_env.sh).
  • Driver / npu-smi: 25.5.1.
  • Python: 3.11.14 (/usr/local/python3.11.14/bin/python3).
  • torch is built +cpu (torch.version.cuda is None); torch.cuda.is_available() is False.
  • The model runs in float32 (the official pretrained precision).

Aliyun 安装命令

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

Recorded 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 1

Optional 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 1

The 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=0

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

live session npu device call model result

输出结果

logs/npu_result.json (machine-readable acceptance record) contains:

FieldMeaning
engine / frameworktorch_npu / pytorch
source_revision / official_implementation_revisionpinned revisions
assigned_device, device_index, npu_name, npu_device_namenpu:1, 1, Ascend910B4-1, Ascend910B4-1
cann_version, torch_version, torch_npu_versionruntime versions
process_id, utc_timeOS PID and UTC capture time
input_device, model_device, output_device, z_device, quantized_device, z_indices_device, loss_deviceall npu:1 (asserted)
npu_process_evidenceprocess_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)
codebookcodebook_dim=20, s1_bits=10, s2_bits=10, full vocab 2²⁰
reconstruction_maemean absolute error of z_pre (stage-1 only), z (full 20-bit), round-trip half decode
bsq_lossBSQuantizer loss (commit + entropy penalty; can be negative)
token_stats.*.min/max/unique_count/totaltoken index range and unique-token count
deterministic_token_samplefirst token's full 20-bit index, bit string, s1/s2 indices, bipolar code
quantized_samplefirst token's 20-dim ±1/√20 code vector
finite_checksper-output finite-value assertions
outputhuman-readable summary of the meaningful tokenizer output (token-index range/unique count, MAE, loss)
test_inputfixture source, CC0 license, features, preprocessing
weight_bytes / weight_sha256pinned local-weight integrity
exit_codeexplicit process exit code (0)

NPU-only 断言

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);
  • the assigned device index exists and torch.npu.set_device("npu:1") succeeds;
  • weight size and SHA256 match the pinned facts exactly;
  • strict 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);
  • the model parameters and every input/output tensor (input, both reconstructions, quantized representation, token indices, decode output, and loss) are on exactly npu:1;
  • every meaningful output is finite.

CPU is used only for deterministic fixture generation, per-channel standardization, JSON serialization, hashing, and screenshot rendering.

局限性

  • This delivery exercises the tokenizer only (encoder + quantizer + decoder). It does not run the WindFM decoder-only transformer autoregressive forecasting, which is a separate model (NeoQuasar/WindFM-8.1M).
  • The test fixture is synthetic CC0 wind telemetry, not real wind-farm data; reconstruction MAE is in standardized units (the same normalization the official predictor applies).
  • No public upload or anonymous verification is performed or claimed here.
  • The copied model/ package is a verbatim, MIT-attributed copy of the official implementation; no behavioral changes were made.

来源与许可证

  • Model weights and architecture: NeoQuasar/WindFM-Tokenizer, MIT license (official implementation copyright © 2025 ShiYu). The local model/ package contains verbatim copies of windfm.py, module.py, __init__.py and the MIT LICENSE from the pinned official revision f0fc5ec210c3f11caf06948c75a9e42503d114e3.
  • Test fixture: CC0 (public domain). It is self-authored, closed-form, deterministic, contains no third-party data, and is fully redistributable.
  • Config card: license: mit, pipeline_tag: time-series-forecasting.

故障排查

SymptomLikely causeFix
torch.npu.is_available() is FalseCANN env not loadedsource /usr/local/Ascend/ascend-toolkit/set_env.sh
No module named 'einops'venv deps not installedrun the Aliyun install block in 安装命令
weight size/SHA mismatchwrong weightsverify against the 精确元数据 pinned values
strict weight load failedkey mismatchdo not random-init; report the missing/unexpected keys
OOMbatch/sequence too largereduce --seq-len / --batch-size
torch_npu import errortorch replaced from PyPIrecreate venv with --system-site-packages; never reinstall torch

验收清单

  • inference.py with --model-path, --device, --output-json (plus extras)
  • model-specific model/ module with MIT attribution + license notice
  • requirements.txt (no downloadable torch replacement; image-supplied torch/torch_npu documented)
  • readme.md and README.md byte-identical
  • metadata.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 run
  • logs/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 itself
  • exit code 0, finite meaningful results, strict real-weight loading, no CPU/CUDA fallback markers