#NPU
Model: NeoQuasar/Kronos-Tokenizer-base (https://huggingface.co/NeoQuasar/Kronos-Tokenizer-base)
Revision: local snapshot 2026-08-20, 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 group_size=4
Type: Time-Series Tokenizer for financial K-line (OHLCV + amount) – hierarchical discrete tokenization via BSQuantizer (Binary Spherical Quantization) with Transformer encoder/decoder. Part of Kronos family (Kronos-small/base use this tokenizer, context 512).
Weight: model.safetensors 15.8 MB, FP32, no remote code required.
License: MIT
Original paper: https://arxiv.org/abs/2508.02739 Kronos: A Foundation Model for the Language of Financial Markets
Task routed: Tokenization self-supervised reconstruction (time-series). Tokenizer-only checkpoint is a component of Kronos forecasting pipeline; this adaptation demonstrates encode (6-dim continuous -> s1/s2 discrete tokens 2x10 bits) and decode (tokens -> 6-dim reconstruction) on Ascend NPU.
Architecture: embed(d_in->d_model) -> 3x TransformerBlock encoder -> quant_embed(256->20) -> BSQuantizer (20 dims -> s1 10 bits + s2 10 bits, vocab each 1024) -> post_quant_embed -> 3x TransformerBlock decoder -> head -> reconstruction (s1-only pre and full).
Input contract:
[batch, seq_len, 6] where 6 = [open, high, low, close, volume, amount] (volume/amount optional but filled if missing)Synthetic demo data: seed 42, torch.randn *0.5, shape [2,32,6], mean 0.025 std 0.49, mimics normalized K-line after standardization. Real data would be loaded from CSV with columns open/high/low/close/volume/amount and timestamps for temporal embeddings (KronosPredictor.calc_time_stamps). This submission uses synthetic for CI but code supports df DataFrame path.
Output contract:
s1_ids, s2_ids each [batch, seq_len] int64 0..1023 (vocab 1024)recon [batch, seq_len, 6] float32, finite, reconstructed K-line in normalized space.(z_pre, z) both [B,T,6], bsq_loss scalar, quantized [B,T,20].Preprocessing saved: no extra scaler file needed; predictor does per-series mean/std and clip. Example: x = (x - mean)/ (std+1e-5); x = clip(x, -5,5).
npu:0 via torch.device("npu:0") and .to(device) for model+tensor; no CPU fallback (fails if npu unavailable)./tmp/models/Kronos-Tokenizer-base else snapshot_download via HF_ENDPOINT https://hf-mirror.com.pip install -r requirements.txt
# ensure CANN toolkit at /usr/local/Ascend/cann-8.5.1 is sourced
# weights: auto-downloaded on first run, or pre-download:
python -c "from huggingface_hub import snapshot_download; snapshot_download('NeoQuasar/Kronos-Tokenizer-base', local_dir='/tmp/models/Kronos-Tokenizer-base')"Default command (uses synthetic K-line, runs on npu:0):
python inference.pyWhat it does: loads tokenizer to npu:0, creates batch 2 seq 32 dim6 normalized input, encode to s1/s2 tokens (half=True), decode to reconstruction, forward full, prints device, shapes, sample tokens/recon, timings with torch.npu.synchronize(), CPU-NPU diff, and status.
Expected output snippet:
device: npu:0
model param device: npu:0
input shape: [2,32,6]
encode done: s1 shape [2, 32] s2 shape [2, 32] s1 sample [643,483,473,347,275]
decode done: reconstructed shape [2, 32, 6] reconstructed sample [1.0793,0.4287,0.6702,-0.6551,-0.3674,-0.3132]
forward done: z shape [2, 32, 6] bsq_loss -0.061378
CPU-NPU max_abs_error recon: 0.00000167 mean: 0.00000022
NPU inference SUCCESSFor real CSV:
import pandas as pd
df = pd.read_csv("your_klines.csv", parse_dates=["timestamps"])
# df must contain open,high,low,close,volume,amount
# see KronosPredictor.predict example in original READMERun python inference.py on Ascend910_9362 npu:0:
Same weights, same input, same dtype (float32), same half=True, eval mode.
python scripts/compare_outputs.py --cpu cpu_recon.npy --npu npu_recon.npy --task regression --atol 1e-4 --rtol 1e-3next(model.parameters()).device == npu:0 and output.device == npu:0.Measured with torch.npu.synchronize() before/after, after 3 warmups, 10 timed runs, batch 2 seq 128 din 6 dtype float32 device npu:0:
Three xterm.js evidence PNGs generated from real logs via scripts/render_xterm_evidence.mjs --style raw (logs redacted of tokens/paths). They show workflow, device calls, and model result. Prompt is fixed atomgit@pod-a94f8701860f4700b161b00e290de466:~$ as display label only.



Images are rendered from logs/workflow.log, logs/device.log, logs/inference.log with UTC timestamps and exit_code 0, via xterm.js raw style (dark bg, white mono).
KronosPredictor (see original examples). This repo therefore demonstrates NPU tokenization correctly but does not claim standalone price forecasting.