#NPU
NeoQuasar/Kronos-Tokenizer-base is the specialized tokenizer for the Kronos Foundation Model family — the first open-source foundation model for financial K-line (candlestick) sequences. It compresses continuous multi-dimensional OHLCV+amount data into hierarchical discrete tokens via Binary Spherical Quantization (BSQ) with 20-bit codebook (s1_bits=10, s2_bits=10, group_size=4). The tokenizer uses 4 encoder Transformer blocks and 4 decoder blocks (d_model=256, n_heads=4, ff_dim=512) and is paired with Kronos-small/base (context 512, 24.7M/102.3M params) for autoregressive forecasting.
This adaptation runs the real tokenizer weights on Ascend 910B npu:0 and validates reconstruction, not a dummy model.
Financial K-line time-series, tabular numeric with temporal order. Not image OCR.
| Column | Dtype | Description | Required |
|---|---|---|---|
| open | float32 | Opening price | yes |
| high | float32 | Highest price | yes |
| low | float32 | Lowest price | yes |
| close | float32 | Closing price | yes |
| volume | float32 | Trading volume | optional (default 0) |
| amount | float32 | Trading amount | optional (volume * mid-price) |
(x - mean)/std then clip to [-5, 5] (same as KronosPredictor). Inverse transform not applied in tokenizer demo but stats saved.data/XSHG_5min_600977.csv with lookback 400, pred_len 120.Synthetic batch=2, seq_len=128, seed 42 — fully traceable generation code in inference.py:gen_synthetic_ohlcv. SHA-256 of generation is deterministic. Real CSV can be passed via --csv path.csv (must contain OHLC columns). No personal data involved.
npu:0torch_npu.npu.is_available()==True, device_count==2 (see npu_device_call.png)npu-smi)pip install -r requirements.txt
# requirements.txt pins:
# torch==2.9.0 torch_npu==2.9.0.post1 transformers==4.57.6 huggingface_hub==0.36.2
# safetensors einops numpy==1.26.4 pandas==3.0.2 tqdmModel weights are not bundled (forbidden). On first run they are downloaded from HF mirror to ./models/Kronos-Tokenizer-base/ via huggingface_hub.snapshot_download (requires env HF_ENDPOINT). Local path is reused on subsequent runs — no hidden network fetch during timed inference.
Default command runs full encode→decode on npu:0:
python inference.py
# or explicitly
python inference.py --model_dir ./models/Kronos-Tokenizer-base --device npu:0 --batch 2 --seq_len 128
# with real CSV
python inference.py --csv ./data/XSHG_5min_600977.csv --seq_len 128 --device npu:0What it logs (must see in model_result.png):
tokenization-reconstruction, backend torch_npu, device npu:0, dtype float32, first param device npu:0[DONE] NPU inference successful on npu:0No CPU fallback: param device strictly npu:0; torch.npu.synchronize() around timing.
Run: python submission/inference.py --device npu:0 (log logs/inference.log)
[INFO] Model: NeoQuasar/Kronos-Tokenizer-base
[INFO] Config: {"d_in":6,"d_model":256,"n_heads":4,"ff_dim":512,"n_enc_layers":4,"n_dec_layers":4,"s1_bits":10,"s2_bits":10,...}
[INFO] First param device: npu:0 dtype: torch.float32
[INFO] Synthetic K-line generated: batch=2 seq_len=128 d_in=6
[INFO] Input tensor shape torch.Size([2, 128, 6])
[INFO] Input device: npu:0
[INFO] s1_indices sample [0 256 96 620 294] s2_indices sample [865 865 801 817 864]
[INFO] Recon shape torch.Size([2, 128, 6]) sample [1.8343743 1.8544402 1.8434399 1.8308125 -0.01325493 0.01147804]
[RESULT] Reconstruction MSE 0.017996 MAE 0.096568 MaxAbs 0.961143
[PERF] Throughput: 319.95 samples/s (40954.06 rows/s)
[DONE] NPU inference successfulConsistency (CPU vs NPU, same seed 42, same weight, float32):
working/cpu_recon.npy vs working/npu_recon.npy compared via scripts/compare_outputs.py --task regression --atol 1e-4 --rtol 1e-3passed: true max_abs_error: 2.62e-06 mean_abs_error: 2.52e-07agent_workflow.png tail.CPU Baseline (same code, device cpu):
| Metric | Value | Notes |
|---|---|---|
| CPU vs NPU max_abs | 2.6e-06 | atol 1e-4, rtol 1e-3 PASS |
| CPU vs NPU mean_abs | 2.5e-07 | float32 |
| Indices equality | 100% | both s1 & s2 |
| First encode (compile) | 263.57 ms | npu:0, sync |
| First decode | 6.67 ms | |
| Stable avg (10 iters, after 3 warmup) | 6.25 ms | |
| Throughput | 319 samples/s, 40954 rows/s | batch=2 seq_len=128 |
| CPU stable avg | 50.47 ms | 39 samples/s |
| Data coverage | Smoke (2 samples) | Not full benchmark |
| dtype | float32 | fp32 threshold strict |
Performance measured with torch.npu.synchronize() before/after; first-run compile separated from stable. Pre-processing (synthetic gen + normalize) not counted in timed section (only encode+decode). Peak NPU HBM 3110 MB used.
Three PNGs are generated only by scripts/render_xterm_evidence.mjs --style raw from real logs (xterm.js, raw style, dark #282828, white, DejaVu Sans Mono, prompt atomgit@pod-a94f8701860f4700b161b00e290de466:~$):
assets/agent_workflow.png — full workflow: discovery → env → inference → consistency → validate (log logs/workflow.log)assets/npu_device_call.png — npu-smi info, check_npu.py, param device npu:0, input/output device npu:0, synchronize ok (log logs/device.log)assets/model_result.png — default python inference.py on npu:0 with reconstruction and perf (log logs/inference.log)All PNGs are valid PNG 1560×~height, verified by Pillow. No manual drawing.

Kronos-Tokenizer-base scope.test-* or research checkpoints excluded; only stable HF checkpoint validated.fit() not needed (pure inference).torch_npu unavailable the script exits non-zero.--csv.