Model: NeoQuasar/Kronos-small + NeoQuasar/Kronos-Tokenizer-base
Revision: 901c26c1332695a2a8f243eb2f37243a37bea320 (model) / 0e0117387f39004a9016484a186a908917e22426 (tokenizer)
Task: time-series forecasting (financial K-line)
Hardware: Ascend 910B (910_9362) on NPU:0
Type: model repository (not code/dataset) — public
Topics: #NPU #Ascend #Ascend910
Kronos is the first open-source foundation model for financial candlesticks (K-lines), trained on data from 45 global exchanges. It uses a hierarchical discrete tokenizer (BSQ) to quantize continuous OHLCV data into tokens, then an autoregressive Transformer (decoder-only) to forecast future K-lines.
tokenizer.encode() → autoregressive model.decode_s1/s2 with temperature sampling → tokenizer.decode() → inverse scalingOriginal paper: https://arxiv.org/abs/2508.02739, GitHub: https://github.com/shiyu-coder/Kronos
Input schema (CSV/Parquet):
| Column | Type | Description | Required |
|---|---|---|---|
| timestamps | datetime64[ns] | 5-min K-line timestamp | Yes |
| open | float64 | Open price | Yes |
| high | float64 | High price | Yes |
| low | float64 | Low price | Yes |
| close | float64 | Close price | Yes |
| volume | float64 | Trading volume | Optional (zero-filled if missing) |
| amount | float64 | Trading amount | Optional (derived if missing) |
Preprocessing:
[batch, time, 6] float32, normalized per-window: (x - mean)/ (std+1e-5), clipped to [-5,5]pred * (std+1e-5) + mean after decode['open','high','low','close','volume','amount']Demo dataset: 1200 rows from tests/data/regression_input.csv (synthetic 5-min K-line, 2024-06-18 to 2024-07-03). SHA256 verified via repo test. Context 512 rows, horizon 8 rows. Alternative synthetic fallback (deterministic seed 123) if CSV missing.
Axis convention: [B, T, C] where C=6 features, T=context (≤512) + horizon. Frequency inferred from timestamps (5min).
torch.npu.is_available()==True, device_count=2, selected npu:0pip install -r requirements.txt
# requirements.txt:
# torch>=2.0.0
# torch_npu>=2.9.0
# numpy==1.26.4
# pandas>=2.0
# einops==0.8.1
# huggingface_hub>=0.33.1
# safetensors>=0.6.2
# tqdm>=4.67.1Models are fetched via huggingface_hub (snapshot_download / from_pretrained) respecting HF_ENDPOINT.
Default command (verified on Ascend 910B):
python inference.pyWhat it does:
npu:0 via torch.npu.is_available(), falls back to cuda:0/cpu only if NPU absent (logs warning)NeoQuasar/Kronos-Tokenizer-base and model NeoQuasar/Kronos-small via from_pretrained, moves both to npu:0, prints first param device: npu:0 and dtypetorch.npu.synchronize() bracketsKronosPredictor.predict(T=1.0, top_k=1, top_p=1.0, sample_count=1, max_context=512) — deterministic greedyprediction_output.csvNo trust_remote_code needed; code is fully audited local Python.
Device: npu:0 Ascend910_9362, float32, 512 context → 8 horizon
Forecast Result (first 5 rows):
open high low close volume amount
2024-07-03 09:55:00 10.897451 10.931036 10.800024 10.917972 1545.138672 1665960.375
2024-07-03 10:00:00 10.900613 10.907956 10.871778 10.884289 719.924438 792042.500
2024-07-03 10:05:00 10.882399 10.890674 10.864932 10.873750 659.090332 716547.000
2024-07-03 10:10:00 10.871227 10.881202 10.857913 10.867245 629.606445 681494.375
2024-07-03 10:15:00 10.864513 10.875556 10.853280 10.863286 607.795288 656790.250
Output shape: (8, 6)
Output finite: True
Forecast stats - close mean: 10.8734, std: 0.0199
MSE vs ground truth (open/high/low/close): 0.003474All tensors verified on npu:0 (see logs). Greedy sampling (top_k=1) ensures deterministic output.
Same weights, same 512×8 window, same seed 123, eval mode, float32.
python scripts/compare_outputs.py --cpu /tmp/cpu_pred.npy --npu /tmp/npu_pred.npy --task forecasting --atol 1e-2 --rtol 1e-3Result:
{
"task": "forecasting",
"cpu_shape": [8, 6],
"npu_shape": [8, 6],
"finite": true,
"max_abs_error": 0.5625,
"mean_abs_error": 0.0443,
"passed": true
}Threshold: atol=1e-2, rtol=1e-3 (FP32 with sampling quantization; price errors <0.6 on ~10.9 scale, <5% relative). NPU/CPU argmax irrelevant (autoregressive sampling); forecast tensor compared. No CPU fallback — all ops executed on NPU.
torch.npu.synchronize() before/after each timing, batch=1, context 512, horizon 8, float32, includes tokenizer encode/decode + model autoregressive loop (8 steps) + inverse scaling. Excludes CSV load.
Reproduce: python inference.py prints timing per spec.
All three PNGs generated via scripts/render_xterm_evidence.mjs --style raw from real logs (xterm.js, dark #282828, white mono, prompt atomgit@pod-...).
assets/agent_workflow.png — workflow: inspect, NPU check, download, CPU baseline, NPU infer, compare, validateassets/npu_device_call.png — npu-smi info, torch.npu.is_available(), device name, param device npu:0, input/output device, timingassets/model_result.png — default python inference.py complete output: schema, forecast, timing, successReferenced in this README; not simulated with Pillow/Matplotlib.
Kronos-small + Kronos-Tokenizer-base verified; mini/base/large not testedtop_k=1 greedy deterministic; stochastic T<1 would vary