Skip to content

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

Python

fix: compile forward instead of module in load_checkpoint

Mathis Doutre1e89ad1635f0
diff --git a/src/timesfm/timesfm_2p5/timesfm_2p5_torch.py b/src/timesfm/timesfm_2p5/timesfm_2p5_torch.py
index e41ad5a..44bb354 100644
--- a/src/timesfm/timesfm_2p5/timesfm_2p5_torch.py
+++ b/src/timesfm/timesfm_2p5/timesfm_2p5_torch.py
@@ -81,13 +81,6 @@ class TimesFM_2p5_200M_torch_module(nn.Module):
tensors = load_file(path)
self.load_state_dict(tensors, strict=True)
self.to(self.device)
- torch_compile = True
- if "torch_compile" in kwargs:
- torch_compile = kwargs["torch_compile"]
- if torch_compile:
- logging.info("Compiling model...")
- self = torch.compile(self)
-
self.eval()
def forward(
@@ -302,6 +295,9 @@ class TimesFM_2p5_200M_torch(
model_file_path = path
self.model.load_checkpoint(model_file_path, **kwargs)
+ if self.torch_compile:
+ logging.info("Compiling model...")
+ self.model.forward = torch.compile(self.model.forward)
@classmethod
def _from_pretrained(