Principle:Shiyu coder Kronos Predictor Initialization
| Field | Value |
|---|---|
| principle_name | Predictor_Initialization |
| repo | Shiyu_coder_Kronos |
| domains | Software_Engineering, Inference |
| last_updated | 2026-02-09 14:00 GMT |
| implemented_by | Implementation:Shiyu_coder_Kronos_KronosPredictor_Init |
Summary
Wrapping the tokenizer and autoregressive model into a unified prediction interface with device management and normalization utilities.
Concept
The KronosPredictor implements the Predictor pattern, encapsulating the full inference pipeline into a single object. Rather than requiring the user to manually manage:
- Device placement (CPU, CUDA, MPS)
- Input normalization and output denormalization
- Tokenization and detokenization
- Autoregressive generation loop invocation
The predictor provides a clean, high-level API where the user supplies raw DataFrames and timestamps, and receives forecasted DataFrames in return.
This pattern is especially valuable for financial time series models where the inference pipeline involves multiple steps that must be correctly orchestrated.
Theory
The Predictor pattern encapsulates the following pipeline:
User Input (DataFrame + timestamps)
|
v
KronosPredictor
+-- Device auto-detection (cuda > mps > cpu)
+-- Model + Tokenizer device placement
+-- Instance normalization (mean/std per series)
+-- Tokenization via KronosTokenizer.encode()
+-- Autoregressive generation via Kronos model
+-- Detokenization via KronosTokenizer.decode()
+-- Denormalization (restore original scale)
|
v
Output (Forecasted DataFrame)
Device auto-detection follows a priority order:
- CUDA (NVIDIA GPU) if available
- MPS (Apple Silicon GPU) if available
- CPU as fallback
The predictor moves both the tokenizer and model to the detected device during initialization, ensuring all subsequent tensor operations happen on the same device without user intervention.
Context window management is controlled by the max_context parameter, which limits the number of tokens the Transformer attends to during generation. The clip parameter bounds normalized values to prevent extreme outliers from destabilizing the model.
Source
- Repository: Kronos on GitHub
Domains
- Software_Engineering: Encapsulation pattern for inference pipelines.
- Inference: Device management, normalization, and generation orchestration.
Related Principles
- Principle:Shiyu_coder_Kronos_Tokenizer_Loading - The tokenizer that is wrapped by the predictor.
- Principle:Shiyu_coder_Kronos_Model_Loading - The model that is wrapped by the predictor.
- Principle:Shiyu_coder_Kronos_Single_Series_Forecasting - Single-series prediction using the predictor.
- Principle:Shiyu_coder_Kronos_Batch_Forecasting - Batch prediction using the predictor.