Time Series Foundation Models - Google TimesFM (Part 1): Model, Algorithms, and Engineering Practice

Table of Contents
Imagine a retail forecasting pipeline where Prophet or LightGBM models reliably forecast sales across tens of thousands of store-SKU pairs. Google then releases TimesFM, an out-of-the-box zero-shot foundation model. For engineering teams, the immediate reaction is rarely academic curiosity; it is a set of pragmatic operational questions: Is introducing a separate deep learning inference service cost-effective? Compared to low-maintenance traditional baselines, what margin of improvement does it genuinely deliver? And practically, can it utilize promotional schedules and store operating calendars that the business has already planned?
In Should We Build a ‘Tower of Babel’ in a Forest of Trees? Time Series Foundation Models vs. GBDT in Practice, we distinguished repurposed language models from Time Series Foundation Models (TSFMs) pre-trained directly on continuous numerical sequences. Bringing these practical operational questions to mainstream benchmarks—such as GIFT-Eval[1], fev-bench[2], or the TIME benchmark[3]—engineers encounter dozens of models trading top positions: Chronos-2, TimesFM, Moirai, Sundial, TiRex, and others. Yet engineering teams have neither the time to parse every paper nor the compute budget to evaluate every checkpoint across multi-origin backtests. A practical question follows: among so many native time-series models, why dissect Google’s TimesFM from its underlying algorithms all the way to production deployment?
A time-series foundation model is a deep neural network pre-trained across hundreds of billions to over a trillion continuous time points spanning multiple industries and sampling frequencies. Its primary engineering appeal is zero-shot forecasting: when given a newly opened store, a recently launched SKU, or newly commissioned equipment, the model requires no local retraining or parameter fine-tuning. From raw historical observations alone, it directly outputs multi-step point forecasts and quantile intervals.
Two engineering reasons make TimesFM a strong reference case:
First, understanding local instance normalization, continuous patching, and multi-step quantile output heads builds a clear baseline for evaluating peer architectures. Current time-series foundation models differ in their backbones and training objectives: the first-generation Chronos[4] quantized continuous values into discrete vocabulary bins, while Chronos-2[5], Sundial[6], Moirai, and TiRex adopt different attention structures or generative heads, and TimesFM itself redesigned its backbone and decoder in version 3.0. Yet local window normalization, continuous patching (packing 1D sequences into fixed-stride input tokens), multi-step quantile projection, and mixed real-and-synthetic pre-training are shared across many leading models. Once you trace how TimesFM aligns variable-length short series with masks, reduces multi-step rollout drift, and injects external promotional schedules, the trade-offs in other models become much easier to evaluate.
Second, TimesFM provides a continuous four-generation evolution record alongside both open Python checkpoints and managed cloud interfaces. From the ICML 2024 release of version 1.0[7] through versions 2.0 and 2.5 to the 2026 release of version 3.0[8], Google has published technical reports, BigQuery AI.FORECAST documentation[9], and open-source code[10]. Teams can run controlled local experiments in Python or evaluate serverless data-warehouse forecasting in BigQuery, while accounting for differences in input contracts, runtime costs, and checkpoint licenses across releases.
Core Architecture and Decisions at a Glance
- Backbone and Decoding Evolution: TimesFM 1.0–2.5 use a univariate causal decoder with asymmetric patches—32-step short inputs and 128-step long outputs—to reduce autoregressive rollout steps over long horizons[7]. TimesFM 3.0 shifts to 32-step inputs and 64-step outputs, pairing Contiguous Patch Masking (CPM) with future placeholder tokens to fill the requested forecast horizon in a single forward pass[8].
- Covariate Integration: Versions 2.0 and 2.5 attach an external in-context linear/ridge module (Exogenous Regressors, XReg) that either strips linear covariate effects before forecasting residuals or fits covariates on backcast residuals—transparent, but constrained by an additive linear model and patch-window rules. Version 3.0 interleaves causal temporal attention with full variate attention, modeling target series and covariates jointly on a two-dimensional token grid[8][10].
- Deployment and Licensing Boundaries: Managed cloud services and self-hosted open checkpoints operate under different constraints. As of November 2026, teams deploying models on private infrastructure for commercial production must distinguish the
Apache-2.0licensed TimesFM 2.5 checkpoints from the public TimesFM 3.0 weights released undertimesfm-non-commercial-license-v1.0[8][9][10].
1. Evolution Across Four Generations #
Over the past three years, Google Research iterated TimesFM through four major releases, progressively addressing long-context throughput, external covariate injection, and native multivariate modeling:
| Dimension | TimesFM 1.0 | TimesFM 2.0 | TimesFM 2.5 | TimesFM 3.0 |
|---|---|---|---|---|
| Release | Feb 2024 | Dec 2024 | Sep 2025 | Aug 2026 |
| Parameters | 200M | 500M | 200M + 30M | 330M |
| Max Context | 512 steps | 2,048 steps | 16,384 steps | 2,048 steps (BQ) |
| Patch Sizes | \(32 \to 128\) | \(32 \to 128\) | \(32 \to 128\) | \(32 \to 64\) (CPM) |
| Covariates | Univariate only | External XReg | External XReg | Native multivariate |
| License | Apache-2.0 | Apache-2.0 | Apache-2.0 | Non-commercial |
Each generation targeted a distinct engineering bottleneck:
- TimesFM 1.0 (Validating the Asymmetric Patch Backbone): Posted on arXiv in October 2023, open-sourced in February 2024, and published at ICML 2024[7]. It established the input patch length \(p=32\), output patch length \(h=128\), 20-layer causal decoder backbone, and joint point-plus-quantile output head, showing that pre-training on continuous waveform patches could match common supervised baselines zero-shot.
- TimesFM 2.0 (Scaling Capacity and Adding External XReg): Expanded parameters to
500M, quadrupled maximum context to2,048steps, and introduced the XReg interface to incorporate external features such as holidays and promotions via in-context linear/ridge regression at inference time[10]. - TimesFM 2.5 (Streamlining the Backbone and Extending Context to 16k): Returned the backbone to
200Mparameters while extending maximum context to16,384steps, removed the categorical frequency indicator required in earlier releases, and added an optional30MContinuous Quantile Head[10]. - TimesFM 3.0 (Shifting to Native Multivariate Attention and CPM Decoding): Pre-trained a
330Mparameter model on more than 1 trillion time points[8], alternating causal temporal attention with full variate attention inside the backbone. Future-known covariates enter through lookahead tokens, and CPM decodes the full forecast horizon in one pass (while the architecture supports long contexts, the managed BigQueryAI.FORECASTinterface currently caps context at2,048steps[9]). Its public PyTorch weights usetimesfm-non-commercial-license-v1.0; commercial workloads can either call BigQueryAI.FORECAST/ Vertex AI under Google Cloud service terms or self-host theApache-2.0licensed TimesFM 2.5 weights[8][9][10].
2. Patch Representation and Decoding Mechanics #
Why do most continuous time-series foundation models avoid the point-by-point autoregressive generation used in large language models? Although early discrete-binning models such as first-generation Chronos generated forecasts token by token[4], rolling forward one scalar time step at a time is inefficient on continuous sequences for two reasons:
- Single Scalar Points Lack Local Shape Information and Scale Poorly: A word token in natural language carries standalone semantic meaning, whereas a single floating-point number (such as \(y_t = 102.0\)) detached from local slope and volatility tells the model very little about trend or phase. Moreover, expanding a sequence of length \(L=2048\) into individual scalar tokens incurs \(O(L^2)\) self-attention memory and compute overhead, slowing batch inference.
- Multi-Step Rollouts Accumulate Early Prediction Errors: Retail replenishment commonly forecasts 28 days ahead, and grid load scheduling often spans hundreds of hours. Emitting only \(\hat{y}_{L+1}\) per forward pass and appending it back to the input to predict \(\hat{y}_{L+2}\) requires dozens of sequential passes, increasing latency and feeding early-step forecast errors into every subsequent step.
To address both constraints, Das et al.[7] designed an asymmetric continuous patching causal decoder for TimesFM 1.0–2.5 across three stages:
- Stage 1 (Input Representation): \(p=32\) continuous patching, reversible instance normalization, and residual feature projection;
- Stage 2 (Causal Backbone): A stacked Transformer decoder aggregating historical patch tokens unidirectionally along time;
- Stage 3 (Output Projection): Direct projection from the final historical token to \(h=128\) future steps of point and quantile forecasts.
TimesFM 3.0 retains 32-step input patches and local normalization, but changes the output patch size to 64 and replaces the 128-step final-token projection with CPM non-autoregressive decoding[8]. Sections 2.1–2.3 detail the three stages in versions 1.0–2.5, and Section 2.4 contrasts them with version 3.0’s CPM decoder.
2.1 Input Patching and Instance Normalization #
All 1D vectors in this article are column vectors by convention. Given a historical time series of length \(L\), \(\mathbf{y}_{1:L} = (y_1, y_2, \dots, y_L)^\top \in \mathbb{R}^L\):
Step 1: Sequence Patching. The model slices the 1D sequence with fixed stride \(p=32\) (input_patch_len) into \(N = \lceil L / p \rceil\) non-overlapping patch column vectors:
When the raw history length \(L\) is not an exact multiple of \(p=32\), the model left-pads the first patch with zeros and constructs a binary mask column vector \(\mathbf{m}_j \in \{0, 1\}^p\) (where \(m_{j,k}=1\) marks padded or masked invalid positions and \(m_{j,k}=0\) marks valid observations). For example, given a 50-day sequence (\(L=50\)), \(N = \lceil 50 / 32 \rceil = 2\): the first patch is left-padded with 14 zeros followed by the first 18 observations \(y_1, \dots, y_{18}\), so \(\mathbf{m}_1\) has 14 ones followed by 18 zeros; the second patch holds \(y_{19}, \dots, y_{50}\) with \(\mathbf{m}_2\) set to all zeros.
Step 2: Reversible Instance Normalization (RevIN). Operational series span wide numerical scales—supermarket egg sales may run in hundreds of cartons per day, slow-moving items in fractions of a unit, and regional power loads in tens of thousands of megawatts. So that a single set of weights can handle any unit scale, TimesFM normalizes each series using the sample mean \(\mu\) and standard deviation \(\sigma\) computed from its first valid window:
\[ \tilde{\mathbf{y}}_j = \frac{\mathbf{y}_j - \mu \mathbf{1}}{\sigma + \epsilon} \in \mathbb{R}^p \]where \(\mathbf{1} = (1, \dots, 1)^\top \in \mathbb{R}^p\) and \(\epsilon\) is a small constant (such as \(10^{-5}\)) that prevents division by zero on constant series. (Note: this is a compact conceptual formulation for clarity; in the source implementation, TimesFM 2.5/3.0 calculates sample mean and variance across the first valid, non-zero window using the binary mask). Following RevIN[11], this strips absolute level and scale before self-attention so the backbone processes normalized wave shapes, then multiplies predictions by \(\sigma\) and adds \(\mu\) at the output to restore business units.
Step 3: Input Residual Block Projection. The normalized \(p\)-dimensional patch and its binary mask are concatenated vertically into a \(2p\)-dimensional feature vector \(\mathbf{u}_j\), which an MLP residual block projects into the Transformer hidden dimension \(d_{\text{model}}=1280\):
\[ \begin{aligned} \mathbf{u}_j &= \begin{bmatrix} \tilde{\mathbf{y}}_j \odot (\mathbf{1} - \mathbf{m}_j) \\ \mathbf{m}_j \end{bmatrix} \in \mathbb{R}^{2p}, \\ \mathbf{t}_j &= \operatorname{ResBlock}_{\text{in}}(\mathbf{u}_j) + \mathbf{p}_j + \mathbf{f}_{\text{freq}} \in \mathbb{R}^{d_{\text{model}}} \end{aligned} \]The symbols are defined as follows:
| Symbol | Shape / Type | Mathematical and Engineering Meaning |
|---|---|---|
| \(\tilde{\mathbf{y}}_j \odot (\mathbf{1} - \mathbf{m}_j)\) | \(\mathbb{R}^p\) (column vector) | Normalized input patch with padded or masked positions zeroed out; \(\odot\) denotes element-wise multiplication |
| \(\mathbf{u}_j\) | \(\mathbb{R}^{2p}\) (column vector) | \(2p=64\) dimensional input feature vector formed by stacking the normalized patch and binary mask |
| \(\operatorname{ResBlock}_{\text{in}}(\mathbf{u}_j)\) | \(\mathbb{R}^{2p} \to \mathbb{R}^{d_{\text{model}}}\) | Input residual projection: \(\mathbf{W}_{\text{out}}\,\sigma_{\text{act}}(\mathbf{W}_{\text{hid}}\mathbf{u}_j + \mathbf{b}_{\text{hid}}) + \mathbf{W}_{\text{skip}}\mathbf{u}_j\) |
| \(\mathbf{p}_j\) | \(\mathbb{R}^{d_{\text{model}}}\) (column vector) | Absolute positional encoding for the \(j\)-th patch token along the time axis |
| \(\mathbf{f}_{\text{freq}}\) | \(\mathbb{R}^{d_{\text{model}}}\) (column vector) | Sampling-frequency embedding (removed as an explicit user argument starting in 2.5 and inferred from context instead) |
2.2 Causal Decoder Backbone #
Once the token sequence \((\mathbf{t}_1, \dots, \mathbf{t}_N)\) is formed, it enters the Transformer decoder backbone. In the 200M configuration, the backbone stacks 20 decoder layers with 16 attention heads per layer and hidden dimension \(d_{\text{model}}=1280\).
In TimesFM 1.0 through 2.5, the backbone applies univariate causal temporal self-attention: a lower-triangular causal mask ensures that patch token \(\mathbf{t}_j\) attends only to itself and earlier tokens \(\{\mathbf{t}_1, \dots, \mathbf{t}_j\}\), blocking any lookahead into future patches. This provides two practical benefits:
- Efficient Parallel Training: Just like next-token prediction in language modeling, a sequence of \(N\) patches evaluates forecast losses across all historical cutoffs \(j=1, \dots, N\) in a single forward pass.
- Flexible Context Length: Because historical context accumulates causally along the patch sequence, a single checkpoint can accept any history length up to its configured context limit.
2.3 Asymmetric Long-Horizon Output Head #
In the 20-layer decoder of versions 1.0–2.5, let \(\mathbf{z}_j^{(l)} \in \mathbb{R}^{d_{\text{model}}}\) denote the hidden state of patch \(j\) after layer \(l\). An output residual block maps the final historical token’s top-layer state \(\mathbf{z}_N^{(20)}\) directly to \(h=128\) normalized future steps:
\[ \hat{\tilde{\mathbf{y}}}_{Np+1 \,:\, Np+h} = \operatorname{ResBlock}_{\text{out}}\!\left(\mathbf{z}_N^{(20)}\right) \in \mathbb{R}^{h \times (1 + |\mathcal{Q}|)} \]Here \(1 + |\mathcal{Q}|\) indicates that each future step in the base output head produces 1 point forecast alongside \(|\mathcal{Q}|=9\) quantile forecasts for \(\mathcal{Q}=\{0.1, 0.2, \dots, 0.9\}\):
- Point Forecast: Depending on the model version and serving API, the point output may represent the conditional mean or median (P50); always check the API contract. For instance, BigQuery
AI.FORECASTexplicitly definesforecast_valueas the P50 conditional median rather than the conditional mean[9]. - P90 and P10 Quantiles: These estimate the 90th and 10th percentiles of the conditional distribution, and their spread (the P10–P90 interval width) reflects forecast uncertainty. In inventory planning, P90 can serve as a distributional input, but it is not identical to safety stock and does not automatically guarantee a 90% in-stock service level—actual service levels also depend on replenishment lead times, on-hand inventory, stockout cost functions, and out-of-sample quantile calibration verified through rolling backtests.
Why Use an Asymmetric Configuration (\(p=32\) Input vs. \(h=128\) Output)?
Ablation studies by Das et al.[7] compared combinations of input and output patch lengths under a fixed pre-training budget: setting the input patch to \(p=32\) achieved lower aggregate test error than \(p=8\) or \(p=128\), while setting the single-step output horizon to \(h=128\) outperformed shorter heads such as \(h=8\) or \(h=32\). Two mechanisms explain this trade-off:
- Input patches should not be too wide: If the input stride were set to \(p=128\), a short sequence with only three or four weeks of history would fill less than a quarter of a patch, smoothing out local inflection points inside a wide linear projection; meanwhile, random prefix masking during training would have to sample offsets across \(0 \sim 127\), making prefix alignment harder to learn.
- Output patches benefit from a longer horizon: Shortening the output patch to \(h=32\) or \(h=8\) would require 4 or 16 autoregressive rollouts to cover a 128-step horizon. Using \(h=128\) reduces rollout passes and cumulative drift; for standard 28-day retail replenishment, a single forward pass covers the full window and slices the first 28 steps.
2.4 TimesFM 3.0: CPM Non-Autoregressive Decoding #
TimesFM 3.0 does not carry over the “project 128 steps from the last history token” head to multivariate settings. Instead, it pairs 32-step input patches with 64-step output patches and uses Contiguous Patch Masking (CPM) for parallel non-autoregressive decoding[8]:
- Append Future Placeholder Tokens: Directly after the observed historical patch tokens, the model appends future placeholder tokens spanning the requested forecast horizon.
- Mask by Variable Role: Across the future horizon, target series and past-only covariates remain masked, whereas future-known covariates retain their scheduled values.
- Lookahead Covariate Encoding: Future-known covariates are encoded with a lookahead structure so that covariate tokens at the current position carry upcoming planned values.
- Parallel Filling via Alternating Attention: After causal temporal attention and full variate attention alternate across layers, the model fills all future placeholder tokens in a single forward pass, outputting nine quantiles (P10 through P90) for each target series.
In short, TimesFM 2.5 projects 128 future steps from the final historical state \(\mathbf{z}_N^{(20)}\) (and appends predictions back to the input if rolling beyond 128 steps), whereas TimesFM 3.0 lays out placeholder tokens for the requested horizon up front and fills them in one forward pass via CPM.
3. Exogenous Covariate Integration and Tensor Flow #
A univariate backbone can only extrapolate from the historical waveform of sales itself. In retail operations, promotional discounts, store closures, and weather shifts substantially alter demand trajectories—how does TimesFM incorporate these external signals?
3.1 Business Covariate Taxonomy and Additive Assumptions #
Exogenous covariates are auxiliary features driven by business schedules or external conditions rather than the target series’ own past values. In classical regression decomposition, daily retail sales \(y(t)\) are often approximated as an additive combination of baseline trend, seasonality, and linear external terms:
\[ y(t) = g(t) + s(t) + f_{\text{hol}}(t) + \beta_{\text{discount}} \cdot d_t + \beta_{\text{temp}} \cdot \mathrm{Temp}_t + \epsilon_t \]where \(g(t)\) is the long-term trend, \(s(t)\) is the periodic seasonal component, \(f_{\text{hol}}(t)\) is the holiday effect, \(d_t\) is the daily discount rate (for example, a 20% discount is recorded as \(d_t = 0.20\)), \(\mathrm{Temp}_t\) is the daily maximum temperature, and \(\epsilon_t\) is random noise.
Before putting this formulation into production, two limitations of the additive linear assumption must be clear:
- Additive vs. multiplicative response: The equation assumes a 20% discount (\(d_t = 0.20\)) adds a fixed unit increment \(\beta_{\text{discount}} \cdot 0.20\). In retail practice, promotions typically act as multiplicative amplifiers of baseline demand (a 20% discount on a high-volume staple generates far more incremental units than on a slow mover) or trigger non-linear demand jumps at deep discount thresholds.
- Hard physical boundaries cannot be guaranteed by additive subtraction alone: A scheduled store closure (\(\mathrm{is\_open}_t = 0\)) forces physical sales to exactly zero on that day. An additive linear regression can only subtract a fixed constant on closure days; it cannot guarantee that the resulting forecast equals 0 (and may even produce negative values or leave a large positive residual when a promotion overlaps the closure). Production pipelines therefore still require a post-processing mask based on the operating calendar.
Based on information availability at the forecast origin (\(t = L\)), exogenous covariates fall into two strict categories:
- Future-Known Covariates (spanning both history and future, total length \(L + H\)):
- Scheduled Promotions: Confirmed promotional calendars, such as a 20% discount (\(d_t = 0.20\)) scheduled for the first 7 days of a 28-day horizon;
- Operating Calendar: Planned store open and closed indicators (\(\mathrm{is\_open}_t \in \{0, 1\}\));
- Public Holidays: Statutory holiday flags (\(\mathrm{is\_holiday}_t \in \{0, 1\}\)).
- Past-Only or Forecasted Covariates:
- Weather and Environmental Signals: Realized daily high temperatures \(\mathrm{Temp}_t\) are known over the historical window \(1:L\), but true future weather is unknown at \(t = L\). Passing temperature as a future covariate over \(L+1 : L+H\) requires substituting meteorological forecasts or historical seasonal averages.
3.2 Two Integration Mechanisms: XReg Linear Regression vs. 3.0 Multivariate Attention #
Across generations, TimesFM has used two distinct mechanisms to incorporate covariates:
Mechanism 1: External In-Context Linear/Ridge Regression in TimesFM 2.0 / 2.5 (XReg).
XRegstands for Exogenous Regressors. Rather than modifying the univariate Transformer backbone, it fits an in-context linear model dynamically for each series at inference time[10]. Under the defaultxreg + timesfmmode, execution proceeds in three steps:- Estimate Historical Linear Effects: Over the historical window \(1:L\), solve for the linear regression coefficients from the covariate design matrix \(\mathbf{X}_{1:L}\) and target series \(\mathbf{y}_{1:L}\) (here shown in closed-form analytical terms for pedagogical clarity, matching the ordinary least squares and ridge regression executed by
timesfm[xreg]in TimesFM 2.5; in the source implementation, the regularization parameterridgedefaults to \(\lambda = 0.0\), enabling an L2 penalty whenridge > 0is passed): \[ \hat{\boldsymbol{\beta}} = \left(\mathbf{X}_{1:L}^\top \mathbf{X}_{1:L} + \lambda \mathbf{I}\right)^{-1} \mathbf{X}_{1:L}^\top \mathbf{y}_{1:L} \] - Forecast the Covariate-Stripped Residuals: Compute the historical residual series \(\mathbf{r}_{1:L} = \mathbf{y}_{1:L} - \mathbf{X}_{1:L}\hat{\boldsymbol{\beta}}\) and pass it into the univariate TimesFM backbone for normalization, patching, and zero-shot extrapolation to obtain future residual forecasts \(\hat{\mathbf{r}}_{L+1:L+H}\);
- Add Back Future Planned Covariates: Sum the backbone’s residual forecast and the future linear covariate projection to produce the final forecast \(\hat{\mathbf{y}}_{L+1:L+H} = \hat{\mathbf{r}}_{L+1:L+H} + \mathbf{X}_{L+1:L+H}\hat{\boldsymbol{\beta}}\).
- Estimate Historical Linear Effects: Over the historical window \(1:L\), solve for the linear regression coefficients from the covariate design matrix \(\mathbf{X}_{1:L}\) and target series \(\mathbf{y}_{1:L}\) (here shown in closed-form analytical terms for pedagogical clarity, matching the ordinary least squares and ridge regression executed by
Mechanism 2: Native Multivariate Attention Grid in TimesFM 3.0. TimesFM 3.0 eliminates external residual stripping and instead patches the target series and covariates together into a two-dimensional “variate channel \(\times\) time patch” token grid of shape \([B,\, C,\, N,\, d_{\text{model}}]\), where \(B\) is batch size and \(C\) is the number of channels[8]. The backbone alternates between two attention operations:
- Causal Temporal Attention: Fixes variate channel \(c\) and passes information unidirectionally along the time-patch axis, preventing future time steps from leaking into historical representations;
- Full Cross-Channel Variate Attention: Fixes time-patch position \(j\) and computes bidirectional attention across all \(C\) channels within that patch. Target sales tokens can thus directly attend to contemporaneous and lookahead-encoded discount, store-open, and temperature tokens in hidden space, learning non-linear interactions across variables.
3.3 Tensor Flow Comparison on a 50-Day Retail Series #
Consider a single-SKU retail forecast with history length \(L=50\) days, forecast horizon \(H=28\) days, and batch size \(B=1\). The inputs are historical daily sales \(\mathbf{y}_{1:50} \in \mathbb{R}^{50}\) and a covariate matrix \(\mathbf{X}_{1:78} \in \mathbb{R}^{78 \times 3}\) covering all 78 historical and future days (discount rate, store-open status, and temperature forecast). Below is how the same task flows through each generation.
Path 1: TimesFM 2.5 + XReg (xreg + timesfm mode)
- Compute Historical Residuals (\(\mathbb{R}^{50} \to \mathbb{R}^{50}\)): Solve \(\hat{\boldsymbol{\beta}} \in \mathbb{R}^3\) over the 50 historical days using the Section 3.2 formula and strip the linear covariate component to obtain the residual vector \(\mathbf{r}_{1:50} \in \mathbb{R}^{50}\).
- Left-Padded Patching and Mask Concatenation (\([1, 50] \to [1, 2, 64]\)): Slice \(\mathbf{r}_{1:50}\) with stride \(p=32\) into \(N = \lceil 50/32 \rceil = 2\) patches. Patch 1 is left-padded with 14 zeros, giving mask \(\mathbf{m}_1 \in \{0, 1\}^{32}\) with 14 ones followed by 18 zeros; Patch 2 has mask \(\mathbf{m}_2\) set to all zeros. After instance normalization and mask concatenation, this forms an input tensor of shape \([1, 2, 64]\).
- Input Residual Block Projection (\([1, 2, 64] \to [1, 2, 1280]\)): Projects the two patches into tokens \(\mathbf{t}_1, \mathbf{t}_2 \in \mathbb{R}^{1280}\).
- 20-Layer Causal Decoder Forward Pass (maintains \([1, 2, 1280]\)): Token 1 attends only to itself, while Token 2 aggregates all 50 valid historical days, yielding the top-layer final state \(\mathbf{z}_2^{(20)} \in \mathbb{R}^{1280}\).
- 128-Step Output Projection and Linear Restoration (\([1, 1280] \to [1, 128, 10] \to [1, 28, 10]\)): The output residual block maps \(\mathbf{z}_2^{(20)}\) to 128 future steps across 10 channels (1 point forecast + 9 quantiles). After denormalizing and slicing the first 28 steps, the model adds back the future linear covariate term \(\mathbf{X}_{51:78}\hat{\boldsymbol{\beta}}\).
Path 2: TimesFM 3.0 Native Multivariate + CPM Decoding
- Multi-Channel Historical Patching and Future Placeholders: The target sales series and the 3 covariate channels are each sliced into \(p=32\) historical patches (left-padding 14 zeros on the first patch with corresponding masks). For the future \(H=28\) days, the model appends masked placeholder tokens for target sales while encoding the 28-day known discount, operating calendar, and temperature forecast into covariate tokens via lookahead construction[8].
- 2D Token Grid Projection: Historical patch tokens, future placeholder tokens, and lookahead covariate tokens are projected into hidden space as a 2D “variate channel \(\times\) time position” grid.
- Alternating Spatio-Temporal Attention: Across backbone layers, temporal attention propagates causally along time, while full variate attention connects sales, discount, open-status, and temperature channels at each patch position, allowing future placeholder tokens to fuse planned promotions with historical sales dynamics directly.
- Single-Pass 28-Day Quantile Decoding via CPM: Using its \(h=64\) output patch head, the model decodes the future placeholder tokens in one pass and denormalizes them to return the requested 28 days of P10–P90 quantiles and point forecasts without an external regression step.
The table below summarizes the structural differences between the two paths:
| Stage | TimesFM 2.5 + XReg | TimesFM 3.0 |
|---|---|---|
| Input Structure | Univariate residual patches + external covariate matrix | 2D token grid combining target series and covariates |
| Covariate Mechanism | In-context linear/ridge regression strips and restores additive increments | Lookahead covariate tokens + full cross-channel variate attention |
| Horizon Decoding | Final historical state \(\mathbf{z}_N^{(20)}\) projects 128 steps, then slices 28 | Appends future placeholder tokens and fills the horizon in parallel via CPM |
| Output Channels | 1 point forecast + 9 quantiles (or 30M continuous quantile head) | P10–P90 nine quantiles for each target series at every future step |
4. Pre-Training Mechanics and Corpus Composition #
With a fixed input patch stride of \(p=32\), why can the model ingest a 14-day cold-start series or a 50-day series (\(50 \equiv 18 \pmod{32}\)) at inference time without suffering phase misalignment? The answer lies in the random prefix masking scheme used during pre-training.
4.1 Random Prefix Masking #
If a patched model were pre-trained exclusively on sequence lengths divisible by 32 (32, 64, 96, etc.), it would only learn to forecast starting immediately after multiples of \(32k\) valid observations; feeding an irregular history length at inference time would shift the phase of the predicted waveform.
To prevent this, TimesFM applies Random Prefix Masking (RPM) during pre-training[7]—much like a driving instructor having a student practice hill starts from every point along a slope:
- For each training series, sample a random prefix mask length from a discrete uniform distribution: \[ m_0 \sim \operatorname{Uniform}\{0, 1, \dots, p-1\} \]
- Mask and zero out the first \(m_0\) time steps of the first input patch \(\mathbf{y}_1\) (\(m_{1,1} = \dots = m_{1,m_0} = 1\));
- The first patch token now contains only \(p - m_0\) valid observations, yet must still predict the immediately following window \(\mathbf{y}_{p+1 : p+h}\); the second patch token accumulates \(2p - m_0\) valid observations, and so on.
Because \(m_0\) is sampled uniformly across \(0 \sim 31\), the model practices forecasting from every modulo-\(p\) remainder across hundreds of billions of training points. At inference time, given a sequence of length \(L=50\), the runtime left-pads the first patch with \(m_0 = 14\) zeros and sets those 14 mask bits to 1; the end of the second patch aligns exactly with day 50, allowing the model to project seamlessly starting from day 51.
4.2 Point and Quantile Composite Loss #
During pre-training, TimesFM minimizes the sum of normalized point Mean Squared Error (MSE) and multi-step quantile Pinball Loss[7]:
\[ \begin{aligned} \mathcal{L}(\Theta) &= \frac{1}{N} \sum_{j=1}^{N} \Bigl( \mathcal{L}_{\text{point}}(j) + \mathcal{L}_{\text{quantile}}(j) \Bigr), \\ \mathcal{L}_{\text{point}}(j) &= \frac{1}{h}\left\|\tilde{\mathbf{y}}_{jp+1:jp+h} - \hat{\tilde{\mathbf{y}}}_j^{(\text{point})}\right\|_2^2, \\ \mathcal{L}_{\text{quantile}}(j) &= \frac{1}{h} \sum_{q \in \mathcal{Q}} \sum_{\tau=1}^{h} \rho_q\!\left(\tilde{y}_{jp+\tau} - \hat{\tilde{y}}_{j,\tau}^{(q)}\right) \end{aligned} \]where \(\rho_q(e)\) is the pinball loss for quantile level \(q \in \mathcal{Q}\):
\[ \rho_q(e) = \max\!\left(q \cdot e,\, (q - 1) \cdot e\right) = \begin{cases} q \cdot e, & \text{if } e \ge 0, \\ (1 - q) \cdot (-e), & \text{if } e < 0. \end{cases} \]Suppose actual demand on a given day is 25 units:
- If the P90 forecast under-predicts at 22 units (residual \(e = 25 - 22 = +3\)): the loss is \(0.9 \times 3 = 2.7\);
- If the P90 forecast over-predicts at 28 units (residual \(e = 25 - 28 = -3\)): the loss is only \((1 - 0.9) \times 3 = 0.3\).
At \(q=0.9\), under-prediction incurs a gradient penalty 9 times as large as an equal over-prediction, driving that output channel toward the 90th percentile of the conditional distribution; symmetrically, at \(q=0.1\), over-prediction is penalized 9 times as heavily as under-prediction. This allows the network to emit asymmetric prediction intervals in a single forward pass without assuming Gaussian errors, though empirical out-of-sample coverage still requires rolling backtest verification.
4.3 Real-World and Synthetic Pre-Training Corpus #
The TimesFM 1.0 paper reports a pre-training corpus composed of 80% real-world time series and 20% synthetic series[7] (the TimesFM 3.0 technical report states that real and synthetic corpora together exceed 1 trillion time points without disclosing the exact split[8]). The version 1.0 mixture consists of:
- Real-World Corpus (80% share):
- Google Trends: Hourly, daily, weekly, and monthly search interest across roughly 22,000 high-frequency queries, capturing event spikes and daily human routines;
- Wikipedia Pageviews: Hourly and daily traffic across millions of articles, covering long-tail sparse series and holiday shifts;
- Public Time-Series Repositories: Training splits from M4, electricity load, and traffic benchmarks (with held-out test windows excluded to prevent data leakage).
- Synthetic Mathematical Processes (20% share):
- Real-world series cluster around standard calendar frequencies (such as 7 days or 24 hours) and contain substantial noise. To teach generalizable trend and periodic extrapolation rules, the authors combined four mathematical generators:
- Autoregressive Moving Average processes: \(\operatorname{ARMA}(p_{\text{ar}}, q_{\text{ma}})\), simulating short-range autocorrelation and stochastic shocks across varying orders;
- Multi-frequency sine and cosine mixtures: Randomly sampled non-integer periods so the network does not merely memorize fixed 7-day or 12-month cycles;
- Piecewise-linear and exponential trends with changepoints: Training the model to recognize slope shifts and inflection points;
- Step functions and pulse waves: Simulating equipment start/stop cycles, price changes, and promotional plateaus.
- Real-world series cluster around standard calendar frequencies (such as 7 days or 24 hours) and contain substantial noise. To teach generalizable trend and periodic extrapolation rules, the authors combined four mathematical generators:
5. Engineering Calls and Deployment Boundaries #
Chapters 1 through 4 dissected patch decoding, covariate integration, and pre-training mechanics. Moving to engineering implementation, this chapter uses two shared synthetic retail datasets—variable-length univariate histories (DATA_1) and a promotional series with future schedules (DATA_2)—to directly compare Python API calls, forecast behaviors, managed BigQuery interfaces, and open-weight licensing boundaries across TimesFM 2.5 and 3.0.
5.1 Local Zero-Shot Inference #
The first test dataset (DATA_1) contains two univariate histories of sharply different lengths: a mature product with a full 365-day cycle and a newly launched product with only 14 days of history, both targeting a 28-day forecast horizon. On a local GPU or CPU environment, we load TimesFM 2.5 (200M PyTorch weights; raw FP32 parameters occupy roughly 800 MB, so reserving at least 4 GB of RAM is recommended once activations and framework overhead are included) and TimesFM 3.0 for zero-shot univariate inference:
import numpy as np
import timesfm
FORECAST_HORIZON = 28
# Data 1: Univariate histories for a 365-day mature item and a 14-day cold-start item
DATA_1 = [
{
"name": "Mature product",
"history": np.sin(np.linspace(0, 20, 365)) * 15 + 100,
},
{
"name": "New product",
"history": np.array(
[
12.0, 15.0, 14.0, 18.0, 22.0, 25.0, 20.0,
16.0, 19.0, 21.0, 24.0, 28.0, 30.0, 26.0,
]
),
},
]
data_1_histories = [item["history"] for item in DATA_1]
# Experiment 1: Load and compile TimesFM 2.5 (enable return_backcast for later XReg reuse)
model_25 = timesfm.TimesFM_2p5_200M_torch.from_pretrained(
"google/timesfm-2.5-200m-pytorch"
)
model_25.compile(
timesfm.ForecastConfig(
max_context=1024,
max_horizon=FORECAST_HORIZON,
normalize_inputs=True,
use_continuous_quantile_head=True,
return_backcast=True,
)
)
# Pass both variable-length series in one batch; slice the trailing 28 forecast steps when return_backcast=True
point_forecasts_25_raw, quantile_forecasts_25_raw = model_25.forecast(
horizon=FORECAST_HORIZON,
inputs=data_1_histories,
)
point_forecasts_25 = point_forecasts_25_raw[:, -FORECAST_HORIZON:]
quantile_forecasts_25 = quantile_forecasts_25_raw[:, -FORECAST_HORIZON:, :]
# Experiment 2: Load TimesFM 3.0 and run 28-day zero-shot inference on the same series
model_3 = timesfm.TimesFM3Forecaster.from_pretrained()
forecast_outputs_3_data_1 = [
model_3.predict(
context=np.asarray(history, dtype=np.float32),
horizon=FORECAST_HORIZON,
return_quantiles=True,
make_positive=True,
)
for history in data_1_histories
]
point_forecasts_3 = np.stack(
[output.forecast for output in forecast_outputs_3_data_1]
)
quantile_forecasts_3 = np.stack(
[output.quantiles for output in forecast_outputs_3_data_1]
)
The univariate forecasts from both generations on DATA_1 are shown below:


Comparing the two figures: on the 365-day mature product (top panel of each figure), where historical periodicity is well-established and stationary, both TimesFM 2.5 and 3.0 closely track the sinusoidal phase with narrow quantile bands. On the 14-day new product (bottom panel of each figure), both models generate 28-day forecasts directly without manual lag engineering, but their extrapolation shapes differ—2.5 continues a more pronounced 7-day weekly oscillation, whereas 3.0 produces a smoother point trajectory with a quantile fan that widens progressively across the forecast horizon.
Importantly, architectural support for short-sequence inputs (sequence-length compatibility) must not be conflated with an accuracy advantage on cold-start items (forecast accuracy). While both checkpoints forward-pass 14-day histories without padding errors, zero-shot foundation models in the absence of established historical cycles must still be benchmarked rigorously against Seasonal Naive, category medians, or hierarchical shrinkage before assuming operational efficacy.
5.2 TimesFM 2.5: XReg Covariate Calls #
When future schedules such as promotions or store operating hours affect demand, univariate forecasting cannot condition on those known plans directly. Installing the timesfm[xreg] extras enables forecast_with_covariates[10]: dynamic covariates must span both the history and the forecast horizon for a total length of \(L + H\), whereas static covariates require no time dimension. The source implementation supports two xreg_mode options:
xreg + timesfm(default): Fits covariate effects on historical sales first, forecasts the remaining residual series with TimesFM, and adds the projected effect of future known covariates back onto the forecast. This suits series where historical covariate variations are representative and the linear relationship holds reasonably well into the future.timesfm + xreg: Generates the forecast and historicalbackcastwith TimesFM first, fits covariate effects on the residuals between historical sales and thebackcast, and adds the future covariate correction onto the forecast. It relies onbackcastresiduals rather than rolling historical forecasts, and requiresreturn_backcast=True.
In the source implementation, the ridge parameter defaults to 0.0, meaning it performs unregularized ordinary least squares by default; enabling an L2 ridge penalty requires explicitly passing a ridge value greater than 0[10].
To test how these configurations behave, the second shared dataset (DATA_2) sets history length \(L=50\) days and forecast horizon \(H=28\) days (total length 78 days). Historical sales multiply a sinusoidal baseline by two 20%-off promotions (days 8–12 and days 30–34), a single store-closure zeroing event (day 16), and a single holiday pulse (day 24). Across the future 28-day schedule, a 20%-off promotion runs during the first 7 days (days 50–56), with a planned store closure on day 56 (is_open = 0 overlapping discount = 0.20 on the same day), and a statutory holiday falls on day 64. Reusing the compiled model_25 instance, we run Experiment 3 (default xreg + timesfm, ridge=0.0), Experiment 3b (xreg + timesfm, ridge=0.9), and Experiment 3c (timesfm + xreg, ridge=0.9):
# Data 2: 50-day sales history plus 78-day promotional, store-open, and holiday schedules
DATA_2_HISTORY_DAYS = 50
DATA_2_HORIZON = 28
DATA_2_DISCOUNT = np.zeros(DATA_2_HISTORY_DAYS + DATA_2_HORIZON)
DATA_2_DISCOUNT[8:13] = 0.20
DATA_2_DISCOUNT[30:35] = 0.20
DATA_2_DISCOUNT[DATA_2_HISTORY_DAYS : DATA_2_HISTORY_DAYS + 7] = 0.20
DATA_2_IS_OPEN = np.ones(
DATA_2_HISTORY_DAYS + DATA_2_HORIZON,
dtype=int,
)
DATA_2_IS_OPEN[16] = 0
DATA_2_IS_OPEN[DATA_2_HISTORY_DAYS + 6] = 0
DATA_2_IS_HOLIDAY = np.zeros(DATA_2_HISTORY_DAYS + DATA_2_HORIZON, dtype=int)
DATA_2_IS_HOLIDAY[24] = 1
DATA_2_IS_HOLIDAY[DATA_2_HISTORY_DAYS + 14] = 1
DATA_2_BASE_SALES = 100.0 + 15.0 * np.sin(
np.linspace(0, 4 * np.pi, DATA_2_HISTORY_DAYS + DATA_2_HORIZON)
)
DATA_2_HISTORY_SALES = (
DATA_2_BASE_SALES[:DATA_2_HISTORY_DAYS]
* (1.0 + 1.5 * DATA_2_DISCOUNT[:DATA_2_HISTORY_DAYS])
* (1.0 + 0.2 * DATA_2_IS_HOLIDAY[:DATA_2_HISTORY_DAYS])
* DATA_2_IS_OPEN[:DATA_2_HISTORY_DAYS]
).astype(np.float32)
# Experiment 3: Call TimesFM 2.5 forecast_with_covariates (xreg + timesfm, default ridge=0.0)
point_forecasts_25_data_2_raw, quantile_forecasts_25_data_2_raw = (
model_25.forecast_with_covariates(
inputs=[DATA_2_HISTORY_SALES],
dynamic_numerical_covariates={
"discount": [DATA_2_DISCOUNT],
},
dynamic_categorical_covariates={
"is_open": [DATA_2_IS_OPEN],
"is_holiday": [DATA_2_IS_HOLIDAY],
},
static_categorical_covariates={
"category": ["grocery"],
},
xreg_mode="xreg + timesfm",
)
)
point_forecast_25_data_2 = np.asarray(
point_forecasts_25_data_2_raw
)[0, :DATA_2_HORIZON]
quantile_forecast_25_data_2 = np.asarray(
quantile_forecasts_25_data_2_raw
)[0, :DATA_2_HORIZON, :]
# Experiment 3b: Keep data and mode identical, explicitly set ridge=0.9 to enable L2 regularization
point_forecasts_25_data_2_ridge_09_raw, quantile_forecasts_25_data_2_ridge_09_raw = (
model_25.forecast_with_covariates(
inputs=[DATA_2_HISTORY_SALES],
dynamic_numerical_covariates={
"discount": [DATA_2_DISCOUNT],
},
dynamic_categorical_covariates={
"is_open": [DATA_2_IS_OPEN],
"is_holiday": [DATA_2_IS_HOLIDAY],
},
static_categorical_covariates={
"category": ["grocery"],
},
xreg_mode="xreg + timesfm",
ridge=0.9,
)
)
point_forecast_25_data_2_ridge_09 = np.asarray(
point_forecasts_25_data_2_ridge_09_raw
)[0, :DATA_2_HORIZON]
quantile_forecast_25_data_2_ridge_09 = np.asarray(
quantile_forecasts_25_data_2_ridge_09_raw
)[0, :DATA_2_HORIZON, :]
# Experiment 3c: Switch to xreg_mode="timesfm + xreg" while keeping ridge=0.9
point_forecasts_25_data_2_tf_xreg_raw, quantile_forecasts_25_data_2_tf_xreg_raw = (
model_25.forecast_with_covariates(
inputs=[DATA_2_HISTORY_SALES],
dynamic_numerical_covariates={
"discount": [DATA_2_DISCOUNT],
},
dynamic_categorical_covariates={
"is_open": [DATA_2_IS_OPEN],
"is_holiday": [DATA_2_IS_HOLIDAY],
},
static_categorical_covariates={
"category": ["grocery"],
},
xreg_mode="timesfm + xreg",
ridge=0.9,
)
)
point_forecast_25_data_2_tf_xreg = np.asarray(
point_forecasts_25_data_2_tf_xreg_raw
)[0, :DATA_2_HORIZON]
quantile_forecast_25_data_2_tf_xreg = np.asarray(
quantile_forecasts_25_data_2_tf_xreg_raw
)[0, :DATA_2_HORIZON, :]



Comparing the three output charts reveals how the additive assumption, ridge penalty strength, and underlying patch mechanics interact:
- Experiment 3: Default
xreg + timesfmwithridge=0.0(first chart): The model runs ordinary least squares across all 50 historical days (days 0–49). It restores positive lifts during the 20%-off promotion on days 50–55 and the holiday on day 64 (raising forecasted sales to roughly 144 and 120 units); however, on the day-56 store closure (store open = No), because that day also falls inside the 20% discount window, the additive linear model sums the negative closure effect and the positive promotional effect directly, dropping the forecast only to about 42 units rather than zeroing it out like the non-promotional closure on day 16. - Experiment 3b:
xreg + timesfmwithridge=0.9(second chart): Within the 50-day history, the 20% discount appears on 10 days, whereas the store closure appears only once (on day 16). Adding theridge=0.9L2 penalty leaves the well-sampled promotional coefficient virtually unchanged (days 50–55 remain near 144 units), but strongly shrinks the sparse single-occurrence closure coefficient toward zero, so the day-56 closure forecast drops only to 76.65 units. - Experiment 3c:
timesfm + xregwithridge=0.9(third chart): The forecast curve flattens near 97–99 units and shows no closure drop or holiday lift. The root cause is that TimesFM 2.5 uses an input patch length of \(p = 32\) days: because the causal decoder cannot generate abackcastfor the first input patch without preceding context,timesfm + xregskips the first patch when fitting residuals, using only the last 18 days (days 32–49) of this 50-day history. That 18-day window contains only 3 promotional days (days 32–34) and zero closure or holiday samples (the day-16 closure and day-24 holiday both fall inside the skipped first 32 days), leaving the regressor unable to estimate either effect.
Recalculated metrics on the same DATA_2 dataset under ridge=0.9 confirm this contrast:
| Mode Configuration | 28-Day Forecast Mean | Planned Closure Day Forecast | Mean Interval Width |
|---|---|---|---|
xreg + timesfm (ridge=0.9) | 119.56 | 76.65 | 10.24 |
timesfm + xreg (ridge=0.9) | 97.28 | 99.49 | 18.89 |
| Univariate TimesFM Baseline | 117.27 | 117.26 | — |
In Experiment 3c, the closure-day forecast (99.49) shows virtually no closure effect, and its overall level shift (97.28) relative to the univariate baseline (117.27) cannot be attributed simply to the planned covariates. While ridge=0.9 shrinkage contributes, the fundamental constraint is that skipping the first 32 days leaves the residual fitting window without any closure or holiday examples. Making timesfm + xreg effective requires a longer history where the fitting window after day 32 still contains multiple promotions, closures, and holidays.
5.3 TimesFM 3.0: Native Multivariate and Covariate Calls #
Corresponding to Path 2 in Chapter 3, Experiment 4 uses the exact same DATA_2 inputs, stacking the discount rate, store-open indicator, and holiday schedule into a [3, 78] numerical matrix passed via past_future_covariates to model_3.predict()[8][10]:
# Experiment 4: Stack covariates into a [feature, time] matrix for TimesFM 3.0
past_future_covariates_3 = np.vstack(
[DATA_2_DISCOUNT, DATA_2_IS_OPEN, DATA_2_IS_HOLIDAY]
).astype(np.float32)
output_3_data_2 = model_3.predict(
context=DATA_2_HISTORY_SALES,
horizon=DATA_2_HORIZON,
past_future_covariates=past_future_covariates_3,
return_quantiles=True,
make_positive=True,
)
point_forecast_3_data_2 = output_3_data_2.forecast
quantile_forecast_3_data_2 = output_3_data_2.quantiles

Comparing TimesFM 3.0 with 2.5: without an external linear regressor, 3.0 uses lookahead covariate tokens and full variate attention to capture the promotional lift on days 50–55 (roughly 145 units) and the modest holiday bump on day 64, while widening its uncertainty interval during the promotional period. On the day-56 store closure, 3.0 pulls the point forecast down to about 56 units (with the lower quantile reaching roughly 17 units), though continuous attention outputs likewise do not hit exact zero on their own.
Consequently, when incorporating covariates in offline backtests or production pipelines, engineering teams should enforce three leakage-prevention and boundary rules:
- Regular Calendar Alignment and Invalid-Zero Filtering: Align series to a regular calendar grid before splitting at the forecast origin. Historical store closures or confirmed stockout censorship must not be fed into the model as normal zero demand; mask and impute them on the regular grid first, and abort with an explicit error if a series contains no valid historical observations.
- Strict Separation of Future-Known Plans from Realized Outcomes: Covariates spanning the future window \(L+1 : L+H\) may include only business schedules already fixed at the forecast origin (\(t=L\))—such as planned discounts, statutory holidays, and operating calendars—or meteorological forecasts. Never include realized future sales, realized stockout flags, or ex-post aggregates.
- Physical Boundary Post-Processing: As Experiments 3, 3b, 3c, and 4 all show, both external linear/ridge regression and native continuous attention can leave non-zero residual predictions on closed days. In production, alongside non-negative clipping (
make_positive=Trueornp.clip(..., 0, None)), multiply outputs by the future operating maskDATA_2_IS_OPEN[-DATA_2_HORIZON:]during post-processing to force point and quantile forecasts to zero on known closure days.
5.4 Managed BigQuery Deployment and Three Runtime Modes #
When enterprise data already resides in Google Cloud and the workload only requires a daily batch forecast across store–SKU pairs, maintaining dedicated GPU containers and distributed patching jobs often costs more in engineering upkeep than inference itself. BigQuery ML packages TimesFM as the serverless built-in function AI.FORECAST[9], generating batch forecasts directly through standard SQL (note: the query below follows the official Google Cloud tutorial; as of November 2026, TimesFM 3.0 in BigQuery ML is governed by Pre-GA Offerings Terms, so check current quotas and documentation before production rollout[9]):
-- Call built-in TimesFM 3.0 in BigQuery for a 28-day demand forecast and 90% prediction interval
SELECT
store_id,
sku_id,
forecast_timestamp AS business_date,
forecast_value AS yhat_point,
prediction_interval_lower_bound AS yhat_p05,
prediction_interval_upper_bound AS yhat_p95
FROM
AI.FORECAST(
(
SELECT
store_id,
sku_id,
business_date,
clean_demand_units
FROM
`retail_prod_dw.daily_store_sku_demand`
WHERE
business_date <= DATE '2025-12-03'
),
data_col => 'clean_demand_units',
timestamp_col => 'business_date',
id_cols => ['store_id', 'sku_id'],
model => 'TimesFM 3.0',
horizon => 28,
confidence_level => 0.90
)
ORDER BY
store_id, sku_id, business_date;
Note the quantile convention: the internal model output head emits P10–P90 by default (the central 80% prediction interval). Because the SQL query above explicitly specifies confidence_level => 0.90, AI.FORECAST returns the central 90% prediction interval, corresponding to the 5th and 95th percentiles (yhat_p05 and yhat_p95; set confidence_level to 0.80 if you need P10 and P90)[9].
As of November 2026, production deployments typically follow one of three runtime modes[8][9][10]:
| Dimension | 1. BigQuery AI.FORECAST | 2. Vertex AI Online Endpoint | 3. Self-Hosted Open Weights |
|---|---|---|---|
| Model Versions | TimesFM 2.0 / 2.5 / 3.0 | TimesFM 2.5 / 3.0 | TimesFM 2.5 (200M) / 2.0 |
| Best Fit For | Data warehouse & analytics teams on GCP | Low-latency online serving teams | On-prem, multi-cloud, or strict data-residency teams |
| Customization | Native SQL multi-series batching & intervals | Managed containers & MLOps pipeline hooks | Full control (custom XReg & pre/post-processing) |
| Ops & Cost | No GPU ops: billed by query & bytes scanned | Moderate: billed by managed node hours | Self-managed: own GPU or multi-core CPU batching |
| License Terms | Covered by Google Cloud commercial terms | Covered by Google Cloud commercial terms | 2.5 is Apache-2.0 commercial (3.0 is non-commercial) |
5.5 Practical Boundaries and Open-Weight Licenses #
Before promoting TimesFM into a production candidate pool, teams should verify four operational boundaries:
- Short-History Covariates and High-Dimensional Feature Interactions:
TimesFM 2.5’s XReg incorporates external variables without fine-tuning backbone weights, working well when a series has sufficient history and repeated observations of promotions and holidays. However, when history is short—especially in
timesfm + xregmode where skipping the first 32-step patch leaves a narrow fitting window—or when events are sparse, per-series local regression lacks the sample size to estimate \(\hat{\boldsymbol{\beta}}\) reliably. Moreover, an additive linear model cannot directly represent cross-SKU price cannibalization or hard monotonic constraints (such asmonotone_constraints). Even with TimesFM 3.0’s full variate attention, wide-table tasks with dozens of engineered business features should be benchmarked against global supervised models like LightGBM under the exact same information set. - Zero-Inflated Intermittent Demand and Stockout Censorship: On ultra-sparse slow-moving series, continuous patched models often output smooth fractional values near zero and should be compared against Croston, SBA, two-stage hurdle models, and count-distribution tree models across multiple forecast origins. In addition, if historical records contain uncleaned stockout censorship, any model observing only sales history can mistake inventory-driven zero sales for falling demand; stockout imputation must happen upstream during data cleaning.
- Managed Cloud Cost and Latency Budgeting:
AI.FORECASTeliminates GPU serving maintenance and lets data-warehouse teams stand up a zero-shot baseline quickly, but production cost and end-to-end runtime depend on bytes scanned, number of series, query frequency, and regional quotas. Always benchmark actual job statistics before scheduling daily production runs. - Commercial Licensing Red Lines for Open Checkpoints (as of November 2026):
TimesFM 1.0, 2.0, and 2.5 code and model weights use the
Apache-2.0open-source license, permitting commercial self-hosting on private servers. By contrast, Google released the public TimesFM 3.0 weights undertimesfm-non-commercial-license-v1.0[8][10], which prohibits using downloaded 3.0 weights directly in commercial production services (commercial workloads must call managed Google Cloud services such as BigQueryAI.FORECASTor Vertex AI[9]). Teams planning self-hosted commercial deployments should prioritizeApache-2.0licensed TimesFM 2.5 (200M) or fellowApache-2.0foundation models such as Chronos-2[5] and Sundial[6].
6. Adoption and Validation Guidelines #
Engineering teams integrating TimesFM into a production forecasting stack can follow three practical guidelines:
- Use a Dual-Track Selection Strategy by License and Multivariate Needs ("3.0 for Research & Managed Cloud" vs. “2.5 for Self-Hosted Commercial Deployment”):
- Research Validation and Cloud-Native Batch Forecasting (Candidate: TimesFM 3.0): When tasks require testing native multivariate interactions and future-known covariates, pin a specific revision of the 3.0 Python checkpoint for reproducible non-commercial evaluation, or evaluate the managed
AI.FORECASTinterface in BigQuery; in both cases, validate accuracy, interval coverage, query cost, and latency on your own rolling backtest windows. - Self-Hosted Commercial Clusters (Candidate: TimesFM 2.5): Commercial systems requiring strict data residency or self-managed inference services should adopt the
Apache-2.0licensed 2.5 checkpoint and pair it withxreg + timesfmon series with sufficient historical coverage of calendar and promotional events.
- Research Validation and Cloud-Native Batch Forecasting (Candidate: TimesFM 3.0): When tasks require testing native multivariate interactions and future-known covariates, pin a specific revision of the 3.0 Python checkpoint for reproducible non-commercial evaluation, or evaluate the managed
- Establish a Zero-Shot Shadow Challenger Baseline: Before spending weeks building complex lag and cross-feature pipelines, run TimesFM zero-shot on calendar-aligned, stockout-cleaned historical data in shadow mode alongside your existing production model. If a heavily tuned supervised pipeline fails to beat the zero-shot baseline, either noise dominates the series, evaluation metrics are misaligned, or flaws exist in feature construction or historical stockout cleaning—all signals worth investigating early.
- Evaluate Short-History Cold-Start Series as a Separate Cohort: Random prefix masking allows TimesFM to ingest irregular short histories such as 14 or 50 days without waiting to accumulate long lag windows, but that capability does not guarantee superiority over Seasonal Naive or hierarchical statistical baselines across every product category. Group backtest errors by time since launch (e.g., under 14 days, 14–56 days, and 56+ days) and set model-switching rules based on empirical cohort performance.
Next in Part 2: In Time Series Foundation Models - Google TimesFM (Part 2): Synthetic Retail Experiments and Forecast Analysis, we run multi-origin rolling forecast experiments across four five-year synthetic retail scenarios, comparing TimesFM univariate zero-shot, known-covariate integration, statistical baselines, and global tree models under regular promotions, deep discounts, zero-inflated intermittent demand, and stockout censorship.
References #
[1] G. Woo, C. Liu, A. Kumar, C. Xiong, S. Savarese, D. Sahoo. GIFT-Eval: A benchmark for general time series forecasting evaluation. arXiv:2406.06688, 2024. https://arxiv.org/abs/2406.06688
[2] O. Shchur, A. Turkmani, Y. Zhang, B. N. Oreshkin, A. F. Ansari. fev-bench: A unified framework and benchmark for time series forecasting evaluation. arXiv:2509.26468, 2025. https://arxiv.org/abs/2509.26468
[3] Z. Qiao, S. Pan, A. Wang, V. Zhukova, Y. Liu, X. Jiang, Q. Wen, M. Long, M. Jin, C. Liu. It’s TIME: Towards the next generation of time series forecasting benchmarks. Proceedings of the 43rd International Conference on Machine Learning (ICML), PMLR 306, 2026. https://arxiv.org/abs/2602.12147
[4] A. F. Ansari, L. Stella, C. Turkmen, X. Zhang, P. Mercado, H. Shen, O. Shchur, S. S. Rangapuram, S. P. Arango, S. Kapoor, J. Zschiegner, D. C. Maddix, H. Wang, M. W. Mahoney, K. Torkkola, A. G. Wilson, M. Bohlke-Schneider, Y. Wang. Chronos: Learning the language of time series. Transactions on Machine Learning Research (TMLR), 2024. https://arxiv.org/abs/2403.07815
[5] A. F. Ansari, O. Shchur, J. Küken, A. Auer, B. Han, P. Mercado, S. S. Rangapuram, H. Shen, L. Stella, X. Zhang, et al. Chronos-2: From univariate to universal forecasting. arXiv:2510.15821, 2025. https://arxiv.org/abs/2510.15821
[6] Y. Liu, G. Qin, Z. Shi, Z. Chen, C. Yang, X. Huang, J. Wang, M. Long. Sundial: A family of highly capable time series foundation models. Proceedings of the 42nd International Conference on Machine Learning (ICML), PMLR 267, pp. 39295–39317, 2025. https://arxiv.org/abs/2502.00816
[7] A. Das, W. Kong, R. Sen, Y. Zhou. A decoder-only foundation model for time-series forecasting. Proceedings of the 41st International Conference on Machine Learning (ICML), PMLR 235, pp. 10148–10167, 2024. https://arxiv.org/abs/2310.10688
[8] A. Jain, R. Sen. TimesFM-3: A zero-shot foundation model for multivariate forecasting. Google Research Blog, 2026. https://research.google/blog/timesfm-3-a-zero-shot-foundation-model-for-multivariate-forecasting/
[9] Google Cloud. The AI.FORECAST function in BigQuery ML. Google Cloud Documentation, 2026. https://cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-forecast
[10] Google Research. TimesFM: Time Series Foundation Model Repository. GitHub, 2026. https://github.com/google-research/timesfm
[11] T. Kim, J. Kim, Y. Tae, C. Park, J.-H. Choi, J. Choo. Reversible instance normalization for accurate time-series forecasting against distribution shift. International Conference on Learning Representations (ICLR), 2022. https://openreview.net/forum?id=cGDAkQo1C0p