Skip to content

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

Python

feat(timesfm3/mlx): reject checkpoints needing frozen running stats

rachittshah36c0244bb5d3
diff --git a/src/timesfm3/mlx/configs.py b/src/timesfm3/mlx/configs.py
index 94ab017..9f963cc 100644
--- a/src/timesfm3/mlx/configs.py
+++ b/src/timesfm3/mlx/configs.py
@@ -56,6 +56,15 @@ class TimesFM3MlxConfig:
@classmethod
def from_hf_config(cls, cfg: dict) -> "TimesFM3MlxConfig":
"""Build a config from a checkpoint's ``config.json`` dictionary."""
+ if cfg.get("use_frozen_running_stats", False):
+ # Torch freezes the running RevIN stats at the context boundary; the MLX
+ # backend does not implement that yet, so a checkpoint that needs it would
+ # diverge on any unmasked horizon input (past-future covariates). The
+ # public 3.0 checkpoint sets this to False. Fail loudly instead.
+ raise NotImplementedError(
+ "The MLX backend does not implement use_frozen_running_stats=True; "
+ "use the torch backend for this checkpoint."
+ )
transformer = cfg.get("transformer_config", {})
inner = transformer.get("transformer", {})
return cls(
diff --git a/src/timesfm3/mlx/timesfm3_forecaster_test.py b/src/timesfm3/mlx/timesfm3_forecaster_test.py
index 17b5e0d..9403d59 100644
--- a/src/timesfm3/mlx/timesfm3_forecaster_test.py
+++ b/src/timesfm3/mlx/timesfm3_forecaster_test.py
@@ -114,6 +114,14 @@ class TimesFM3MlxModelTest(unittest.TestCase):
logits = model.decode(target, past_future_covariates=pf)
self.assertEqual(logits.shape[2], 30)
+ def test_from_hf_config_rejects_frozen_running_stats(self):
+ # The MLX backend does not implement frozen running stats. A checkpoint that
+ # asks for them must fail loudly rather than silently diverge from torch.
+ with self.assertRaises(NotImplementedError):
+ configs.TimesFM3MlxConfig.from_hf_config({"use_frozen_running_stats": True})
+ # The default (absent / False) builds normally.
+ configs.TimesFM3MlxConfig.from_hf_config({"use_frozen_running_stats": False})
+
def test_detrend_activates_on_strong_trend_only(self):
# Detrend is data-driven (weight-independent): a near-linear series activates
# it; a stationary oscillation does not.