#NPU
Model: NeoQuasar/Kronos-base (revision 2b554741eca47781b64468546e77fef3e85130e6) + Tokenizer NeoQuasar/Kronos-Tokenizer-base (revision 0e0117387f39004a9016484a186a908917e22426)
Task: Time-series forecasting — 5-min K-line (OHLCV+amount) 20-step ahead prediction (context 400, horizon 20, 6 channels)
Pipeline: time-series-forecasting (tokenized autoregressive: BSQuantizer tokenizer + Transformer decoder)
pd.DataFrame shape [batch, time, 6] columns open, high, low, close, volume, amount (float32), plus x_timestamp: pd.Series[datetime64] length = lookback, y_timestamp: pd.Series[datetime64] length = pred_len. OHLCV in price units, volume in shares, amount = closevolume0.01 if missing. Values clipped to [-5,5] after per-series z-score (x-mean)/std.TemporalEmbedding (learn_pe=True for model, fixed for tokenizer) added to token embeddings.s1_bits=10, s2_bits=10 (codebook 20 bits, vocab 1024 each), BSQuantizer(20, 5/1.1/1.0/0.05, group_size=4), half=True (pre/post split). Input [B,T,6] -> [B,T,20] bits -> [B,T] s1/s2 ids.pred_df: pd.DataFrame shape [pred_len, 6] columns open/high/low/close/volume/amount, index y_timestamp, float32, inverse-z-scored. Saved as np.ndarray [20,6] for validation.n=512, lookback=400, pred_len=20, freq=5min, dates 2024-01-01 09:30 random walk (seed 42). Real market data should replace synthetic but keep same schema/order.KronosPredictor.predict().npu:0 (910_9362, 2 devices on host, only npu:0 used)torch 2.9.0+cpu, torch_npu 2.9.0.post1+gitee7ba04, transformers 4.57.6 (for hub), pandas 3.0.2, numpy 1.26.4, einops 0.8.2, safetensors 0.7.0, tqdm 4.67.3, huggingface_hub 0.36.28.5.1 (ASCEND_TOOLKIT_HOME=/usr/local/Ascend/cann-8.5.1), SOC_VERSION=ascend910_9391, TASK_QUEUE_ENABLE=1python .opencode/skills/npu-adapt-skills/scripts/collect_env.py --output working/env.json + npu-smi infopip install -r requirements.txt # torch, torch_npu, pandas, numpy, einops, safetensors, huggingface_hub, tqdmrequirements.txt pins numpy==1.26.4 for Ascend compatibility.
python inference.pyNeoQuasar/Kronos-base (409 MB, 102.3M F32) + NeoQuasar/Kronos-Tokenizer-base (15.8 MB) from local models/ or HF mirror https://hf-mirror.com via hf_hub_download (cached to /tmp). No weights are committed.KronosTokenizer and Kronos to npu:0 (next(param).device == npu:0), dtype float32, eval mode.torch.npu.synchronize() before/after timing; reports compile/first-run vs stable.lookback=400, pred_len=20 with T=1.0, top_k=1 (greedy deterministic) / top_p=0.9 stochastic demo, sample_count=1, max_context=512, clip=5.Exit code 0 means full NPU path succeeded without CPU fallback.
[RESULT] NPU deterministic (top_k=1) elapsed 0.77s, throughput 1.30 windows/s
open high low close volume amount
2024-01-02 18:50:00 104.003349 104.329231 103.904076 104.131516 3427.523926 3385.305176
2024-01-02 18:55:00 104.094170 104.366859 104.009079 104.199333 3280.737793 3234.828369
2024-01-02 19:00:00 104.081665 104.358948 104.012794 104.206383 3212.093750 3160.857422
2024-01-02 19:05:00 104.105347 104.207474 103.976768 104.083473 2513.766357 2476.214844
2024-01-02 19:10:00 103.914940 104.222771 103.849899 104.080940 3051.232178 2989.841064
[RESULT] Output shape (20, 6), finite True, device npu:0
[RESULT] NPU stochastic (T=1.0 top_p=0.9) elapsed 0.34s (sampling nondeterministic)Full log in logs/inference.log, captured as assets/model_result.png via xterm.js (raw style, prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$).
model.safetensors), same synthetic slice, same per-series (mean,std), same eval() dtype float32, same seeds (torch.manual_seed 42, torch.npu.manual_seed 42), greedy top_k=1, top_p=1.0 to avoid RNG divergence.cpu_det.npy vs npu_det.npy shape [20,6] float32.python .opencode/skills/npu-adapt-skills/scripts/compare_outputs.py --cpu working/cpu_det.npy --npu working/npu_det.npy --task regression --atol 1e-2 --rtol 1e-2
{"task":"regression","cpu_shape":[20,6],"npu_shape":[20,6],"finite":true,"atol":0.01,"rtol":0.01,"max_abs_error":0.0014648,"mean_abs_error":0.0002224,"passed":true}Also passes atol 1e-3 rtol 1e-3 (max 0.00146 < 0.01). Per-channel: OHLC <1e-4, volume 0.0015/0.0008, amount 0.0012/0.0006 (scale ~3k). Stochastic top_p=0.9 mode diverges (max_abs 3753) due to torch.multinomial RNG difference (NPU vs CPU) and autoregressive error accumulation — documented as expected, not used for strict validation.
No CPU fallback observed (next(param).device == npu:0 both tokenizer and model, input x_tensor.to(npu:0)).
torch.npu.synchronize() before/after, warmup 3, runs 10, T=1.0 top_k=1 deterministic, max_context 512, context 400, horizon 20, batch 1, dtype float32, throughput excludes CSV read (synthetic) but includes normalization/tokenization/inverse.0.311s, stable avg 0.3001s (min 0.297s max 0.302s p50 0.3005 p90 0.3015 p95 0.3019), throughput 3.33 windows/s or 3.33 series/s (1 window = 400->20). CPU single run 32.518s (≈108x slower).working/perf.json, log working/perf.log. Peak HBM ~3821 MB / 65536 MB (npu-smi during inference).| Device | compile | avg | min | max | p50 | p90 | p95 | thrpt |
|---|---|---|---|---|---|---|---|---|
| npu:0 | 0.311s | 0.300s | 0.297s | 0.302s | 0.3005s | 0.3015s | 0.3019s | 3.33 w/s |
| cpu | 32.518s | 32.518s | 32.518s | 32.518s | 32.518s | 32.518s | 32.518s | 0.03 w/s |
All three PNGs rendered by scripts/render_xterm_evidence.mjs --style raw (xterm.js, 1560x height, bg #282828, white 14px DejaVu Sans Mono, prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$), source SHA-256 logged, ANSI stripped, secrets <redacted>, long logs clipped to 110 lines tail. Images only reference real logs, not simulated.
assets/agent_workflow.png — full workflow (inspect, download, load, NPU infer, CPU vs NPU compare, perf, validate). Source: working/logs/workflow.log command python run_adaptation.py exit 0.assets/npu_device_call.png — npu-smi info + check_npu.py + param device/dtype/input-output device. Source: working/logs/device.log command npu-smi info && python scripts/check_npu.py && python -c "import torch;..." exit 0.assets/model_result.png — default python inference.py full stdout (model/rev/task/device/dtype/param device/input summary/output head/timing/status). Source: working/logs/inference.log command python inference.py exit 0.Referenced here:

max_context=512 (Kronos-base). Longer histories truncated to last 512 tokens.predict_batch possible but not benchmarked here).top_p=0.9) is nondeterministic CPU vs NPU due to RNG; greedy top_k=1 is deterministic and validated.fit) not ported — only inference is NPU; fine-tune remains CPU.NPU, Ascend, Ascend910, Kronos, time-series-forecasting, K-line, BSQ, forecasting
MIT (model weights MIT, code MIT from https://github.com/shiyu-coder/Kronos). Hardware flag hardware: NPU in frontmatter required for competition validation.