m
mengsihan/qcw2333-YingLong_110m-NPU
Model Introduction
Files & versions
Pull Requests
Discussion
Analysis

YingLong_110m — Zero-shot Time Series Forecasting on Ascend NPU

#NPU · Model: qcw2333/YingLong_110m (revision main) · Task: zero-shot time-series forecasting (99-quantile probabilistic output)

This repository adapts the YingLong 110M time-series foundation model to run on a single Ascend 910B NPU (npu:0). The original checkpoint uses CUDA-only custom ops (flash_attn, xformers.ops.SwiGLU, dropout_layer_norm, rotary_emb); this adaptation replaces them with mathematically equivalent standard PyTorch operations so the real pretrained weights run on Ascend NPU with no CPU fallback.

Model

FieldValue
Modelqcw2333/YingLong_110m
ArchitectureYingLong (GPT-style, 12 layers, n_embd=768, patch_size=32, unet decoder, Haar wavelet tokenizer)
Params120,464,736 (~110M)
Weightsbfloat16, model.safetensors (240,947,188 bytes)
LicenseCC-BY-4.0
TaskTime-series forecasting — outputs 99 quantiles per forecast step

Data contract

Validation uses the public ETT-small/ETTh1 dataset (Electricity Transformer Temperature, hourly, from the ETDataset repository):

ItemValue
Sourcehttps://github.com/zhouhaoyi/ETDataset/blob/main/ETT-small/ETTh1.csv
SHA-256c4477ee44965ae09b9206136b26b794305fd7b2f4fa869953a29bc73832a034e
Rows3262 (last incomplete row dropped)
Columnsdate, HUFL, HULL, MUFL, MULL, LUFL, LULL, OT
TargetOT (oil temperature), float32, no missing values after drop
Context (lookback)2880 hourly steps
Horizon (prediction)96 hourly steps
Ground truththe 96 values immediately following the context window

The script validates missing columns, column order and non-convertible values. The model performs zero-shot inference (no per-dataset fit()); normalization is the model's built-in patch-wise mean/std scaling and is inverted on the output, so forecasts are in the original OT units (°C-like).

Environment

Validated on:

  • Ascend 910B (Ascend910_9362), 2 devices, target npu:0
  • CANN 8.5.1, torch 2.9.0, torch_npu 2.9.0.post1
  • Python 3.11, aarch64 Linux

Install

pip install -r requirements.txt

Default command (NPU inference)

python inference.py

On first run the script downloads model.safetensors (from the model weight URL, default https://huggingface.co/qcw2333/YingLong_110m) and ETTh1.csv, then runs the 96-step zero-shot forecast on npu:0. You can point it at local files / a custom CSV:

python inference.py \
  --model-dir ./model_weights \
  --input-csv ./ETTh1.csv \
  --target-col OT \
  --lookback 2880 \
  --prediction 96

Custom input is supported via --input-csv and --target-col; the last lookback + prediction rows of the target column are used (first lookback = context, next prediction = ground truth).

Real result (npu:0)

Default python inference.py on the ETTh1 OT window (lookback=2880, horizon=96), model weights on npu:0, dtype bfloat16:

MetricValue
Output shape[1, 96, 99] (96 steps × 99 quantiles)
MAE (median q≈0.50 vs ground truth)4.98
RMSE5.35
SMAPE28.65 %
First run (compile)0.31 s
Steady inference0.019 s
Peak NPU memory256 MB

The forecast median at the last horizon step is ≈ 19.8 °C; ground truth at the same step is 19.8 °C. These are the real zero-shot model outputs — no fabricated scores.

CPU–NPU consistency

CPU and NPU use identical weights, the same window, preprocessing, dtype (bfloat16) and seed:

CheckResult
Output shape match✅ [1, 96, 99] on both
Finite outputs✅
Max absolute error (bf16)0.5 (scale ≈ [-18, 42])
Mean absolute error0.053
Quantile monotonicity (99 quantiles)✅ monotonic on CPU and NPU

Tolerance atol=0.6, rtol=0.02 is justified by the bf16 output scale (values range ≈ -18 to 42; bf16 has ~3 decimal digits). The comparison follows the skill tool convention [batch, quantiles, steps].

Performance (npu:0, lookback=2880, horizon=96, bf16)

MetricValue
Warmup / runs3 / 10
First run (compile)333.8 ms
avg / min / max18.25 / 17.81 / 19.38 ms
p50 / p90 / p9518.22 / 18.44 / 18.91 ms
Peak memory255.8 MB
Throughput54.8 windows/s

Evidence

The following images are rendered by xterm.js from the real execution logs of this adaptation (not simulated screenshots):

ImageContent
agent workflowReconnaissance, data inspection, download, CPU baseline, NPU inference, consistency, benchmark and submission validation
npu device callnpu-smi, NPU availability, device name, model parameter device/dtype, input/output tensor device
model resultDefault python inference.py full output: data contract, real forecast, timing, metrics, status

Adaptation notes & limitations

  • Code changes: model.py was adapted to replace CUDA-only custom ops — flash_attn (fused attention), xformers.ops.SwiGLU, dropout_layer_norm (fused RMSNorm), and rotary_emb (fused rotary) — with equivalent standard PyTorch operations. Parameter names are unchanged, so the original model.safetensors loads 1:1 (0 missing / 0 unexpected keys).
  • Data: only a single ETTh1 window is used for validation; this is a smoke/consistency check, not a full-dataset accuracy evaluation.
  • Quantiles: the 99 outputs are trained with a quantile loss; on the validation window they are monotonic, but adjacent quantiles can be close for flat regions.
  • Zero-shot: results are the pretrained model's zero-shot forecasts and were not tuned on ETTh1.