Supporting Time Series and Tabular Foundation Models in BigQuery

Haoming Chen, Qiang Hao, Xi Cheng, Haiyang Qi, Jenny Ortiz, Jiashang Liu, Chaoyi Shen, Zehao Xu, Omid Fatemieh, Jing Jing Long, Yichen Zhou, Rajat Sen, Weihao Kong, Ayush Jain, Erez Louidor Ilan, Petros Mol, Abhimanyu Das, Steve Thomas, Weijie ShenarXiv 2026

TL;DR

Traditional database machine learning forces you through a tedious loop: train a model, manage its artifacts, wait for it to go stale, and repeat. This paper embeds two massive foundation models—TimesFM for time series and TabFM for tabular data—directly inside BigQuery’s distributed CPU workers. The result is one-step, zero-shot forecasting (AI.FORECAST) and tabular prediction (AI.PREDICT) in plain SQL, scaling to billions of rows without a single CREATE MODEL statement.

What Problem Does This Paper Address?

In-database ML tools like BigQuery ML let analysts run models using SQL, but they still rely on a two-step "train-then-predict" workflow (CREATE MODEL followed by ML.PREDICT). That creates three headaches:

  1. Training latency & ops overhead: Users wait for multi-minute training jobs and manage hyperparameter pipelines.
  2. Permission barriers: Read-only users, BI dashboards, and LLM agents often lack write permissions to store model artifacts.
  3. Staleness: Models decoupled from live tables quickly drift as new data arrives.

Foundation Models (FMs) solve this via zero-shot inference—predicting directly from context without task-specific training. However, dropping a 200M-parameter time series model (TimesFM) or a 410M-parameter tabular model (TabFM) into a distributed SQL engine's CPU workers hits three walls: strict per-worker memory limits, quadratic $O(n^2 + nm^2)$ attention complexity for tabular data, and a distributed execution mismatch (SQL engines shuffle rows randomly, whereas time series need contiguous history per entity and tabular in-context learning needs a unified global context).

Methods

Instead of calling external GPU endpoints over the network, the authors mount immutable, versioned model packages directly onto BigQuery’s Borg CPU workers for in-process C++ inference.

Fig. 1. Model Deployment and Co-Located Serving Architecture in BigQuery. Pre-trained foundation model packages are mounted locally on execution workers for in-worker C++ inference without external RPC calls.

From there, each model gets a tailored distributed architecture:

  • One-Stage Execution for TimesFM (AI.FORECAST): Time series naturally partition by entity (e.g., store_id). BigQuery hash-partitions the data and caps each series at 15,360 recent points before shuffling, preventing massive "whale" entities from causing worker out-of-memory errors. Each worker shares a single read-only copy of the 8-bit integer (INT8) quantized model via a C++ TFLite runtime with XNNPACK kernels. For long horizons (up to 10,000 steps), a multi-patch uncertainty propagation scheme prevents prediction intervals from collapsing during autoregressive rolling.
Fig. 2. One-Stage Distributed Execution for TimesFM in BigQuery. Time series are hash-partitioned by id_cols across workers for parallel in-worker quantized TFLite inference.
  • Two-Stage Prefill-Decode for TabFM (AI.PREDICT): Running tabular in-context learning naively on every worker would duplicate $O(n^2)$ attention work and blow up memory. Instead, Stage 1 runs centralized prefill once on a single worker, using deterministic class-balanced subsampling (via 64-bit FarmHash) to cap context size while preventing rare-class starvation. It serializes the resulting Key-Value (KV) cache and global preprocessing stats into 1 MB chunks and broadcasts them. Stage 2 workers deserialize the KV cache once per process in shared memory and decode test rows in bounded 1,280-row mini-batches.
Fig. 3. Decoupled two-stage execution architecture for TabFM in BigQuery. Stage 1 performs centralized In-Context Learning (Prefill) on sampled training rows to materialize the compressed Key-Value (KV) cache and preprocessing metadata, which are partitioned into 1 MB chunks and broadcast via distributed shuffle to Stage 2 workers for parallel mini-batch decoding.

Datasets

  • TimesFM: Evaluated on 56 GIFT-Eval benchmarks (147,902 series across 7 domains) for accuracy, memory, and latency ablations, plus the Iowa Liquor Sales public dataset scaled from 1 series (85 rows) up to 10 million series (1.18 billion input rows) for BigQuery scalability testing.
  • TabFM: Evaluated on 51 TabArena benchmarks curated from OpenML (39 classification, 12 regression tasks), including 9 imbalanced datasets ($\ge 10,000$ rows) for downsampling ablations.

Key Insights and Ideas

  • Runtime vs. quantization gains are cleanly separable: Moving from Python PyTorch to C++ TFLite delivers the raw inference speedup (2.29×), while INT8 quantization delivers the massive memory savings (2.53× additional RAM drop) and faster cold starts (3.58×)—with virtually zero accuracy loss.
  • Asymmetric operator split: Pushing non-linear cross-row self-attention below the broadcast boundary lets BigQuery’s relational shuffle distribute a compact KV cache rather than forcing every worker to recompute $O(n^2)$ attention.
  • Smart subsampling beats naive slicing: On imbalanced tabular data, random or stratified sampling starves minority classes at small context budgets. Square Root ($\alpha=0.5$) and Balanced ($\alpha=0.0$) quotas dramatically improve F1-scores and multi-seed stability.

Key Results

  • TimesFM Efficiency: Compared to Python PyTorch (FP32), C++ TFLite (INT8) achieves a 2.29× warm inference speedup (247.5 ms to 108.2 ms/series), 4.15× peak resident memory reduction (1,581.9 MB to 381.4 MB), and 3.58× faster cold initialization (8.53 s to 2.38 s), with only a −0.29% mean relative MASE shift across 56 GIFT-Eval datasets.
  • TimesFM Scale: At the largest tier (10M series, horizon 1,000), BigQuery generates 10 billion forecast points in ~1.65 hours (1.68M forecast points/s).
Controlled three-way TimesFM 2.5 ablation across Python PyTorch, C++ TFLite FP32, and C++ TFLite INT8
  • TabFM Scalability & Accuracy: Two-stage KV broadcast cuts end-to-end latency by 11.2× (773.5 s at 1 worker to 68.9 s at 64 workers) and reduces total slot consumption by 9.0× at 32 workers. Across 51 TabArena tasks, zero-shot TabFM matches or outperforms untuned full-data XGBoost without feature engineering.

Limitations and Future Work

Both models currently execute on CPU workers, where TabFM’s cross-row attention remains compute-heavy. The authors plan to offload TabFM serving to hardware accelerators (GPUs/TPUs) in future work to further reduce end-to-end latency and support larger context windows.

Summary updated

BibTeX
@misc{chen2026supporting,
  author = {Haoming Chen and Qiang Hao and Xi Cheng and Haiyang Qi and Jenny Ortiz and Jiashang Liu and Chaoyi Shen and Zehao Xu and Omid Fatemieh and Jing Jing Long and Yichen Zhou and Rajat Sen and Weihao Kong and Ayush Jain and Erez Louidor Ilan and Petros Mol and Abhimanyu Das and Steve Thomas and Weijie Shen},
  title = {{Supporting Time Series and Tabular Foundation Models in BigQuery}},
  year = {2026},
  eprint = {2612.03125},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2612.03125},
}
Figure