MCPcopy
hub / github.com/google-research/timesfm

github.com/google-research/timesfm @v2.0.2 sqlite

repository ↗ · DeepWiki ↗ · release v2.0.2 ↗
490 symbols 1,497 edges 57 files 288 documented · 59%
README

TimesFM

TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.

This open version is not an officially supported Google product.

Latest Model Version: TimesFM 2.5

Archived Model Versions:

  • 1.0 and 2.0: relevant code archived in the sub directory v1. You can pip install timesfm==1.3.0 to install an older version of this package to load them.

Update - July 2, 2026

Updated PyPI to timesfm=2.0.2. See Install.

Update - Apr. 9, 2026

Added fine-tuning example using HuggingFace Transformers + PEFT (LoRA) — see timesfm-forecasting/examples/finetuning/. Also added unit tests (tests/) and incorporated several community fixes.

Shoutout to @kashif and @darkpowerxo.

Update - Mar. 19, 2026

Huge shoutout to @borealBytes for adding the support for AGENTS! TimesFM SKILL.md is out.

Update - Oct. 29, 2025

Added back the covariate support through XReg for TimesFM 2.5.

Update - Sept. 15, 2025

TimesFM 2.5 is out!

Comparing to TimesFM 2.0, this new 2.5 model:

  • uses 200M parameters, down from 500M.
  • supports up to 16k context length, up from 2048.
  • supports continuous quantile forecast up to 1k horizon via an optional 30M quantile head.
  • gets rid of the frequency indicator.
  • has a couple of new forecasting flags.

Since the Sept. 2025 launch, the following improvements have been completed:

  1. ✅ Flax version of the model for faster inference.
  2. ✅ Covariate support via XReg (see Oct. 2025 update).
  3. ✅ Documentation, examples, and agent skill (see timesfm-forecasting/).
  4. ✅ Fine-tuning example with LoRA via HuggingFace Transformers + PEFT (see timesfm-forecasting/examples/finetuning/).
  5. ✅ Unit tests for core layers, configs, and utilities (see tests/).

Install

From PyPI

# Install the package with torch
pip install timesfm[torch]
# Or with Flax
pip install timesfm[flax]
# And when XReg is needed
pip install timesfm[xreg]

Local Install

  1. Clone the repository: shell git clone https://github.com/google-research/timesfm.git cd timesfm

  2. Create a virtual environment and install dependencies using uv: ```shell # Create a virtual environment uv venv

    Activate the environment

    source .venv/bin/activate

    Install the package in editable mode with torch

    uv pip install -e .[torch]

    Or with flax

    uv pip install -e .[flax]

    And when XReg is needed

    uv pip install -e .[xreg] ```

  3. [Optional] Install your preferred torch / jax backend based on your OS and accelerators (CPU, GPU, TPU or Apple Silicon).:

  4. Install PyTorch.

  5. Install Jax for Flax.

Code Example

import torch
import numpy as np
import timesfm

torch.set_float32_matmul_precision("high")

model = timesfm.TimesFM_2p5_200M_torch.from_pretrained("google/timesfm-2.5-200m-pytorch")

model.compile(
    timesfm.ForecastConfig(
        max_context=1024,
        max_horizon=256,
        normalize_inputs=True,
        use_continuous_quantile_head=True,
        force_flip_invariance=True,
        infer_is_positive=True,
        fix_quantile_crossing=True,
    )
)
point_forecast, quantile_forecast = model.forecast(
    horizon=12,
    inputs=[
        np.linspace(0, 1, 100),
        np.sin(np.linspace(0, 20, 67)),
    ],  # Two dummy inputs
)
point_forecast.shape  # (2, 12)
quantile_forecast.shape  # (2, 12, 10): mean, then 10th to 90th quantiles.

Core symbols most depended-on inside this repo

revin
called by 14
src/timesfm/torch/util.py
revin
called by 12
src/timesfm/flax/util.py
linear_interpolation
called by 10
src/timesfm/timesfm_2p5/timesfm_2p5_base.py
strip_leading_nans
called by 8
src/timesfm/timesfm_2p5/timesfm_2p5_base.py
update_running_stats
called by 8
src/timesfm/flax/util.py
_logging
called by 8
v1/src/timesfm/timesfm_base.py
from_pretrained
called by 7
src/timesfm/timesfm_2p5/timesfm_2p5_flax.py
forecast
called by 7
v1/src/timesfm/timesfm_base.py

Shape

Method 267
Function 135
Class 88

Languages

Python100%

Modules by API surface

v1/src/timesfm/pytorch_patched_decoder.py42 symbols
src/timesfm/timesfm_2p5/timesfm_2p5_flax.py23 symbols
v1/src/timesfm/patched_decoder.py22 symbols
v1/src/finetuning/finetuning_torch.py21 symbols
timesfm-forecasting/scripts/check_system.py21 symbols
v1/src/timesfm/timesfm_base.py20 symbols
tests/test_torch_utils.py20 symbols
tests/test_torch_layers.py18 symbols
tests/test_base_utils.py18 symbols
v1/experiments/extended_benchmarks/utils.py16 symbols
src/timesfm/torch/transformer.py15 symbols
v1/src/adapter/lora_layers.py14 symbols

Dependencies from manifests, versioned

anyio4.11.0 · 1×
certifi2025.10.5 · 1×
click8.3.0 · 1×
filelock3.19.1 · 1×
fsspec2025.9.0 · 1×
h110.16.0 · 1×
hf-xet1.2.0 · 1×
httpcore1.0.9 · 1×
httpx0.28.1 · 1×
huggingface-hub1.0.1 · 1×
idna3.10 · 1×
numpy2.2.6 · 1×

For agents

$ claude mcp add timesfm \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact