Skip to main content

mlx-timesfm

Pure MLX inference for Google TimesFM 3.0 on Apple silicon.

PyPI CI Python Apple Silicon MLX License

PyPI · Source

mlx-timesfm is an independent, inference-only implementation of TimesFM 3.0 for Apple MLX. It loads the original 330.7M-parameter FP32 checkpoint directly, without converted weights or a PyTorch runtime, and runs forecasting on Apple silicon through MLX and Metal.

[!IMPORTANT] The official TimesFM 3.0 checkpoint is not included. Google distributes it under the TimesFM Non-Commercial License v1.0, which restricts the model to non-commercial, non-production use. Installing this Apache-2.0 package does not download the checkpoint or grant rights to it. Read the checkpoint license before downloading or using the weights.

Features

  • Native MLX model, transformer, normalization, masking, and forecast decode.
  • Direct mx.load() of the original model.safetensors checkpoint.
  • Univariate and multivariate forecasts with nine quantiles.
  • Past-only and past/future dynamic covariates.
  • Linear detrending, stitching, contiguous patch masking, and iterative RevIN.
  • Strict validation of all 445 checkpoint tensors and their shapes.
  • MLX-only CPU/GPU golden regression against a versioned real-data oracle.
  • Full-FP32 matrix kernels by default for numerically stable inference.

Status

Area Status
Core TimesFM 3.0 inference Implemented
Original checkpoint loading Validated
decode() and forecast() Implemented
Multivariate targets and covariates Validated
MLX CPU/GPU golden parity Passing
PyTorch-free runtime and tests Enforced
Training and fine-tuning Out of scope
KV-cache and compiled decode optimizations Not yet implemented

This is an initial alpha release. The reference inference path is implemented and parity-tested, but broader dataset validation and performance tuning remain ongoing.

Requirements

  • Apple silicon Mac with Metal support
  • Python 3.13
  • MLX 0.32.x
  • A separately downloaded TimesFM 3.0 checkpoint

Installation

Install from PyPI with uv:

uv add mlx-timesfm

Or install the current checkout for development:

git clone https://github.com/appautomaton/mlx-timesfm.git
cd mlx-timesfm
uv sync --locked

Model weights

Review and accept Google's checkpoint terms, then download the original files. One option is the Hugging Face CLI in an isolated uv tool environment:

uvx --from huggingface-hub hf download google/timesfm-3.0-pytorch \
  --local-dir models/timesfm_3_0/original

The checkpoint directory must contain:

models/timesfm_3_0/original/
├── config.json
└── model.safetensors

Weights remain local and are excluded from Git and all package distributions.

Quick start

import numpy as np

import mlx_timesfm

model = mlx_timesfm.load("models/timesfm_3_0/original")

# A batch of two univariate series, each with 512 context points.
target = np.random.default_rng(0).normal(size=(2, 512)).astype(np.float32)
quantiles = model.forecast(target, horizon=128)

print(quantiles.shape)  # (2, 1, 128, 9)
median = quantiles[..., 4]

Inputs may be one-dimensional (time), two-dimensional (batch, time), or three-dimensional (batch, variate, time). The output is always (batch, variate, horizon, 9), ordered from the 0.1 through 0.9 quantiles.

Covariates

target = np.zeros((1, 3, 512), dtype=np.float32)
past_only = np.zeros((1, 2, 512), dtype=np.float32)
past_future = np.zeros((1, 2, 512 + 128), dtype=np.float32)

quantiles = model.forecast(
    target,
    horizon=128,
    past_only_covariates=past_only,
    past_future_covariates=past_future,
)

Boolean masks use True for missing or invalid values. forecast() accepts a global context mask; decode() exposes separate masks for targets and both covariate groups.

Numerical precision

FP32 is the supported correctness baseline. MLX can otherwise choose reduced-precision matrix kernels while keeping FP32 array dtypes, so importing mlx_timesfm defaults MLX_ENABLE_TF32 to 0 before MLX computation. An explicit environment setting is preserved:

# Optional faster/reduced-precision experiment; not the parity baseline.
MLX_ENABLE_TF32=1 uv run python your_forecast.py

The model also pins the effective FP32 RMSNorm epsilon used to establish the golden oracle. FP16 and BF16 inference are not currently supported profiles.

Parity

The permanent regression uses 512 real context observations and a 128-step forecast from the UCI Appliances Energy Prediction dataset. It exercises three targets, two past-only covariates, two past/future covariates, every forecast quantile, and quantile ordering.

Comparison Maximum absolute difference Tolerance used Result
Frozen oracle → MLX CPU 0.00308228 3.3% of allowed band Pass
Frozen oracle → MLX GPU 0.00833130 8.2% of allowed band Pass

The golden manifest pins the dataset, source revision, checkpoint/config hashes, execution profile, output shape, and tolerance. These numbers establish implementation parity; they are not claims about forecast accuracy on every downstream dataset.

Development

uv sync --locked
uv run ruff check .
uv run pytest
uv build --no-sources

The normal test suite is MLX-only. With the original checkpoint present it runs the golden on MLX CPU and GPU; without the checkpoint, only the seven weight-dependent checks skip. A permanent hygiene test rejects retired framework imports and dependencies.

Release process

GitHub releases with tags matching v<version> trigger .github/workflows/workflow.yml. The workflow validates tag/version agreement, tests the project, builds and inspects both distributions, smoke-tests installed artifacts, and publishes through PyPI Trusted Publishing. Releases are not published from developer-machine credentials.

The pending PyPI publisher must match:

  • Owner: appautomaton
  • Repository: mlx-timesfm
  • Workflow: workflow.yml
  • Environment: pypi

Licensing

Project source code is Apache-2.0 licensed; see LICENSE. Third-party attributions are recorded in THIRD_PARTY_NOTICES.md. The separately distributed TimesFM 3.0 checkpoint has different, restrictive terms described above.

TimesFM is a Google trademark. This independent project is not affiliated with or endorsed by Google.


Built and maintained by AppAutomaton. Explore more MLX-native projects on GitHub and Hugging Face.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mlx_timesfm-0.0.1.tar.gz (82.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mlx_timesfm-0.0.1-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file mlx_timesfm-0.0.1.tar.gz.

File metadata

  • Download URL: mlx_timesfm-0.0.1.tar.gz
  • Upload date:
  • Size: 82.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mlx_timesfm-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f97b7e4dedb2ee4d21177a3cde1cfbbcbb0901a814135f542b76ad83e5b04bc8
MD5 46e82b744e2faa1ded3cc58923b3cfd1
BLAKE2b-256 e625893f5eaadce0d59a1735b34335072f961bd5b7f30e160589cbfa6c021365

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlx_timesfm-0.0.1.tar.gz:

Publisher: workflow.yml on appautomaton/mlx-timesfm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mlx_timesfm-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mlx_timesfm-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mlx_timesfm-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 121f11ca8241a9ecce4c90b6bf072a752ec7bc3ae05b5b31065273be7dd1f35d
MD5 89a5f66bac455ca1fedad45257f64f25
BLAKE2b-256 3099d6a76329f19c5c025ec62d0c119717ad6d7a601674ae1849023f021cf324

See more details on using hashes here.

Provenance

The following attestation bundles were made for mlx_timesfm-0.0.1-py3-none-any.whl:

Publisher: workflow.yml on appautomaton/mlx-timesfm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page