YingLong is a probabilistic time-series foundation model from Alibaba (paper: arxiv 2506.11029) based on a bidirectional GPT backbone with patch embedding + Haar wavelet transform + U-Net skip connections, producing 99 quantiles per forecast step. This repo adapts qcw2333/YingLong_110m to run real zero-shot quantile forecasting on a single Ascend 910 NPU (npu:0).
qcw2333/YingLong_110m (revision main, 110M params)Ascend910_9362 (NPU), dtype torch.bfloat16model.safetensors (240 MB) loaded locally, never re-downloaded during inferenceThe official remote model.py requires CUDA-only libraries (flash_attn, xformers). To run on Ascend NPU the model was re-implemented with equivalent standard PyTorch ops while keeping the exact same module structure and state-dict keys:
| Official CUDA op | Ascend replacement |
|---|---|
xformers.ops.SwiGLU | native SwiGLU (w1/w2 gate-up, w3 down) |
flash-attn FusedRMSNorm | native RMSNorm |
flash-attn rotary_emb | native GPT-NeoX rotary embedding |
flash-attn scaled_dot_product_attention | torch.nn.functional.scaled_dot_product_attention |
All weights are loaded with load_state_dict(..., strict=True). No CPU fallback: every model parameter and input/output tensor is on npu:0.
ETTh1.csv, date column + 7 value channels [HUFL, HULL, MUFL, MULL, LUFL, LULL, OT], 17420 rows, hourly, time-sorted, no missing values.OT (oil temperature) channel.L=512 (last 512 timesteps), prediction horizon H=96.[1, 512] (batch, context) in bfloat16; output [1, 96, 99] (batch, horizon, 99 quantile levels 0.01..0.99).npu:0pip install -r requirements.txtpython inference.pyThe script checks torch.npu.is_available(), downloads the weights once via huggingface_hub (respecting HF_ENDPOINT) into a local cache, loads them from local model.safetensors, moves the model and every tensor to npu:0, runs the 96-step quantile forecast, calls torch.npu.synchronize() for timing, and prints the results (exit 0 = success). It also accepts --context-length, --prediction-length, --data and --cache-dir options.
Run on single npu:0 (Ascend910_9362), ETTh1 OT channel, last-512 context, 96-step quantile forecast:
quantiles shape: (1, 96, 99) (batch, horizon, 99 quantiles)
quantile levels: 0.01..0.99
median forecast[:8]: [9.375 9.125 9.125 9. 9.1875 9.3125 9.25 9.4375]
sync elapsed: 0.2543 s
STATUS: NPU_OKSame weights, same input, same seed and eval mode. FP32 outputs saved to .npy and compared with compare_outputs.py:
{"task": "forecasting", "atol": 0.25, "rtol": 0.02, "max_abs_error": 0.125, "mean_abs_error": 0.0173, "passed": true}Threshold rationale: model runs in bfloat16 on NPU (CPU baseline also bfloat16); the output scale is O(10). atol=0.25 is ~2.5% of the median forecast magnitude, consistent with bf16 rounding at this scale.
First run (graph compilation): 269.1 ms; then 3 warmups + 10 timed runs:
{"avg_ms": 14.182, "min_ms": 13.894, "max_ms": 15.239, "p50_ms": 14.098, "p90_ms": 14.323, "p95_ms": 14.781, "throughput_series_per_s": 70.51, "peak_memory_allocated_MB": 487.79}Timing uses torch.npu.synchronize() around every run. Preprocessing (CSV read + DataFrame slicing) is excluded from latency.
The three images in assets/ are rendered by xterm.js from the real logs of this adaptation run (workflow, NPU device calls, and the default python inference.py output):
assets/agent_workflow.png — environment check, model download, CPU baseline, NPU inference, consistency and benchmark steps.assets/npu_device_call.png — npu-smi, torch.npu availability and model/input/output tensor device on npu:0.assets/model_result.png — full output of the default python inference.py command.OT channel of ETTh1 is demonstrated; the model is univariate and can be applied to any real-valued series.--data must point to a CSV with an OT column (or the built-in public ETTh1 URL is used).