NeoQuasar/Kronos-mini is the first open-source foundation model for financial K-line (candlestick) sequence, trained on 12B records from 45 global exchanges. This adaptation deploys Kronos-mini (4.1M params, d_model 256, 4 layers, context 2048) together with Kronos-Tokenizer-2k (15.8M params, group_size 5, s1_bits=10, s2_bits=10) on Huawei Ascend 910B NPU (npu:0).
[batch, time, 6] with columns open, high, low, close, volume, amount (normalized with clip=5)[batch, pred_len, 6] forecast DataFrame indexed by future timestamps4eef55aa3b7ac0fbccf3a76b87eea46140bf9590fd71133772d3c78b03d4af45 (sample_kline.csv). Real data used in repo: same schema as XSHG_5min_600977.csv example from Kronos GitHub.['open','high','low','close','volume','amount','timestamps'], dtypes float64/float64..., missing 0, duplicate 0.timestamps as datetime, sorted ascending, no duplicate timestamps, 5min frequency, timezone naive.x = (x - mean)/ (std + 1e-5), clip to [-5,5], same mean/std used for inverse transform. Saved and reused across CPU/NPU. Column order fixed; extra/missing columns raise error.torch.npu.is_available()==True, device_count==2, torch.npu.get_device_name(0)==Ascend910_9362pip install -r requirements.txt
# requirements.txt pins:
# torch>=2.0.0, torch-npu, numpy==1.26.4, pandas==2.2.2, einops==0.8.1, huggingface_hub, tqdm, safetensors
# CANN toolkit required at /usr/local/Ascend/cann-8.5.1python inference.py
# Options:
python inference.py --lookback 200 --pred-len 20 --data ./sample_kline.csv
# Default generates synthetic 500-row K-line and forecasts 20 steps from npu:0 with timingKronosTokenizer.from_pretrained("NeoQuasar/Kronos-Tokenizer-2k") + Kronos.from_pretrained("NeoQuasar/Kronos-mini"), then .to("npu:0"), verify next(param).device == npu:0.model.decode_s1/decode_s2 with torch.npu.synchronize() before/after, decode via tokenizer.decode. open high low close volume amount
2024-01-01 16:40:00 98.384041 98.503075 98.300102 98.373299 5637.695801 556256.62500
2024-01-01 16:45:00 98.140549 98.472404 97.731461 98.296661 4791.580078 468634.59375
2024-01-01 16:50:00 98.190002 98.286057 98.131584 98.217094 3069.085449 295601.59375
...
2024-01-01 18:15:00 99.047943 99.089981 98.926941 98.990135 2413.011963 248243.53125
mean open 98.677, std 0.306, throughput 6.54 windows/sModel param device: npu:0, Tokenizer param device: npu:0, NPU device name: Ascend910_9362, no CPU fallback, torch.npu.synchronize() used.[1,50,6] – s1 indices agreement 1.0, s2 agreement 1.0, decoded max_abs_error 1.6689e-06, mean 3.07e-07, PASSED at atol 1e-4, rtol 1e-3 (compare_outputs.py --task forecasting).torch.multinomial – small NPU vs CPU logit differences (e.g., due to SDPA) cause token divergence that amplifies per step; with identical seed 42, lookback 100/greedy and 200/sampled, max_abs_error up to 5.6e4 on amount (scale 1e6). This is expected for generative models; single-step tokenizer consistency proves correct NPU execution without fallback. Quantified via cpu_greedy.npy vs npu_greedy.npy and cpu_output.npy vs npu_output.npy (saved as .npy for compare_outputs.py). Threshold for generative forecast would need to be relaxed to account for sampling stochasticity, documented here.torch.npu.synchronize() before and after each predictor.predict; warmup 3, test 10.All three PNGs generated by scripts/render_xterm_evidence.mjs --style raw from real logs (xterm.js white on dark gray, prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$ is display-only, not host proof).
– reconnaissance, download, inspect, NPU check, CPU baseline, NPU inference, compare, benchmark, validate.
– npu-smi, torch_npu check, device name, param device/dtype, input/output device.
– python inference.py full output, schema, forecast, timing, SUCCESS..
├── inference.py
├── readme.md
├── requirements.txt
└── assets/
├── agent_workflow.png
├── npu_device_call.png
└── model_result.png