Phase 1 — Prefill:
Feed all context patches through the transformer. The model produces
output patches (each covering outputPatchLen future steps) and populates
the KV cache.
Phase 2 — Autoregressive Decode:
Take the last output patch's median value, split it into sub-patches,
feed each back through the model to generate the next chunk of the
forecast horizon.
Mirrors the decode() method in timesfm_2p5_torch.py.
Autoregressive decode loop for TimesFM.
This is the core inference algorithm:
Phase 1 — Prefill: Feed all context patches through the transformer. The model produces output patches (each covering outputPatchLen future steps) and populates the KV cache.
Phase 2 — Autoregressive Decode: Take the last output patch's median value, split it into sub-patches, feed each back through the model to generate the next chunk of the forecast horizon.
Mirrors the
decode()method in timesfm_2p5_torch.py.