TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.
Python
Move the TimesFM3 PyTorch backend into a torch/ subpackage
rachittshah9de33f6f487b
diff --git a/src/timesfm3/__init__.py b/src/timesfm3/__init__.pyindex da70af8..67390a5 100644--- a/src/timesfm3/__init__.py+++ b/src/timesfm3/__init__.py@@ -12,19 +12,15 @@# See the License for the specific language governing permissions and# limitations under the License.-"""TimesFM3 PyTorch API."""+"""TimesFM3 API.-from .configs import ResidualBlockConfig, StackedTransformersConfig, TransformerConfig-from .evaluator import TimesFM3Evaluator-from .model import TimesFM3Torch-from .timesfm3_forecaster import (- ForecastOutput,- ModelConfig,- TimesFM3Forecaster,- _ModelConfig,-)+The PyTorch backend lives in ``timesfm3.torch`` and the MLX (Apple Silicon) backend in+``timesfm3.mlx``. For backward compatibility the PyTorch API is also re-exported at the top level+(``from timesfm3 import TimesFM3Forecaster``); these names are resolved lazily so that importing+``timesfm3`` — or ``timesfm3.mlx`` — does not require PyTorch to be installed.+"""-__all__ = [+_TORCH_EXPORTS = frozenset({"ForecastOutput","ModelConfig","ResidualBlockConfig",@@ -34,4 +30,14 @@ __all__ = ["TimesFM3Torch","TransformerConfig","_ModelConfig",-]+})++__all__ = sorted(_TORCH_EXPORTS)+++def __getattr__(name): # PEP 562: lazily re-export the torch backend at the top level+ if name in _TORCH_EXPORTS:+ from . import torch as _torch_backend++ return getattr(_torch_backend, name)+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")diff --git a/src/timesfm3/torch/__init__.py b/src/timesfm3/torch/__init__.pynew file mode 100644index 0000000..eaf6e6e--- /dev/null+++ b/src/timesfm3/torch/__init__.py@@ -0,0 +1,37 @@+# Copyright 2026 Google LLC+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++"""TimesFM3 PyTorch backend."""++from .configs import ResidualBlockConfig, StackedTransformersConfig, TransformerConfig+from .evaluator import TimesFM3Evaluator+from .model import TimesFM3Torch+from .timesfm3_forecaster import (+ ForecastOutput,+ ModelConfig,+ TimesFM3Forecaster,+ _ModelConfig,+)++__all__ = [+ "ForecastOutput",+ "ModelConfig",+ "ResidualBlockConfig",+ "StackedTransformersConfig",+ "TimesFM3Evaluator",+ "TimesFM3Forecaster",+ "TimesFM3Torch",+ "TransformerConfig",+ "_ModelConfig",+]diff --git a/src/timesfm3/configs.py b/src/timesfm3/torch/configs.pysimilarity index 100%rename from src/timesfm3/configs.pyrename to src/timesfm3/torch/configs.pydiff --git a/src/timesfm3/cpm_revin_refine.py b/src/timesfm3/torch/cpm_revin_refine.pysimilarity index 100%rename from src/timesfm3/cpm_revin_refine.pyrename to src/timesfm3/torch/cpm_revin_refine.pydiff --git a/src/timesfm3/cpm_revin_refine_test.py b/src/timesfm3/torch/cpm_revin_refine_test.pysimilarity index 100%rename from src/timesfm3/cpm_revin_refine_test.pyrename to src/timesfm3/torch/cpm_revin_refine_test.pydiff --git a/src/timesfm3/dense.py b/src/timesfm3/torch/dense.pysimilarity index 100%rename from src/timesfm3/dense.pyrename to src/timesfm3/torch/dense.pydiff --git a/src/timesfm3/evaluator.py b/src/timesfm3/torch/evaluator.pysimilarity index 100%rename from src/timesfm3/evaluator.pyrename to src/timesfm3/torch/evaluator.pydiff --git a/src/timesfm3/model.py b/src/timesfm3/torch/model.pysimilarity index 100%rename from src/timesfm3/model.pyrename to src/timesfm3/torch/model.pydiff --git a/src/timesfm3/model_test.py b/src/timesfm3/torch/model_test.pysimilarity index 100%rename from src/timesfm3/model_test.pyrename to src/timesfm3/torch/model_test.pydiff --git a/src/timesfm3/normalization.py b/src/timesfm3/torch/normalization.pysimilarity index 100%rename from src/timesfm3/normalization.pyrename to src/timesfm3/torch/normalization.pydiff --git a/src/timesfm3/primitives_test.py b/src/timesfm3/torch/primitives_test.pysimilarity index 100%rename from src/timesfm3/primitives_test.pyrename to src/timesfm3/torch/primitives_test.pydiff --git a/src/timesfm3/timesfm3_forecaster.py b/src/timesfm3/torch/timesfm3_forecaster.pysimilarity index 100%rename from src/timesfm3/timesfm3_forecaster.pyrename to src/timesfm3/torch/timesfm3_forecaster.pydiff --git a/src/timesfm3/timesfm3_forecaster_test.py b/src/timesfm3/torch/timesfm3_forecaster_test.pysimilarity index 100%rename from src/timesfm3/timesfm3_forecaster_test.pyrename to src/timesfm3/torch/timesfm3_forecaster_test.pydiff --git a/src/timesfm3/transformations.py b/src/timesfm3/torch/transformations.pysimilarity index 100%rename from src/timesfm3/transformations.pyrename to src/timesfm3/torch/transformations.pydiff --git a/src/timesfm3/transformer.py b/src/timesfm3/torch/transformer.pysimilarity index 100%rename from src/timesfm3/transformer.pyrename to src/timesfm3/torch/transformer.pydiff --git a/src/timesfm3/transformer_test.py b/src/timesfm3/torch/transformer_test.pysimilarity index 100%rename from src/timesfm3/transformer_test.pyrename to src/timesfm3/torch/transformer_test.pydiff --git a/src/timesfm3/util.py b/src/timesfm3/torch/util.pysimilarity index 100%rename from src/timesfm3/util.pyrename to src/timesfm3/torch/util.py