google-research/timesfm · error · FileNotFoundError
{self.WEIGHTS_FILENAME} not found in directory {path}
Error message
{self.WEIGHTS_FILENAME} not found in directory {path} What it means
load_checkpoint() expects a checkpoint directory to contain a weights file named model.safetensors (cls.WEIGHTS_FILENAME). If path is a directory but that file is absent, a FileNotFoundError is raised. It exists so the loader fails fast instead of producing a confusing error deeper inside safetensors/torch loading.
Source
Thrown at src/timesfm/timesfm_2p5/timesfm_2p5_torch.py:292
CONFIG_FILENAME = "config.json"
def __init__(
self,
torch_compile: bool = True,
config: Optional[dict] = None,
**kwargs,
):
self.model = TimesFM_2p5_200M_torch_module()
self.torch_compile = torch_compile
if config is not None:
self._hub_mixin_config = config
def load_checkpoint(self, path: str, **kwargs):
"""Loads a TimesFM model from a checkpoint directory or file."""
if os.path.isdir(path):
model_file_path = os.path.join(path, self.WEIGHTS_FILENAME)
if not os.path.exists(model_file_path):
raise FileNotFoundError(
f"{self.WEIGHTS_FILENAME} not found in directory {path}"
)
else:
model_file_path = path
torch_compile = kwargs.pop("torch_compile", self.torch_compile)
self.model.load_checkpoint(model_file_path, **kwargs)
if torch_compile:
logging.info("Compiling model...")
self.model.forward = torch.compile(self.model.forward)
@classmethod
def _from_pretrained(
cls,
*,
model_id: str = DEFAULT_REPO_ID,
revision: Optional[str],
cache_dir: Optional[Union[str, Path]],View on GitHub (pinned to 331c6d33cb)
Solutions
- Verify model.safetensors exists in the directory: ls <path>/model.safetensors; if missing, re-download the checkpoint (e.g. huggingface-cli download google/timesfm-2.5-200m-pytorch).
- Ensure git-lfs is installed and pull the actual files: git lfs install && git lfs pull inside the cloned repo.
- Alternatively pass the path of the .safetensors file itself instead of the directory — load_checkpoint accepts a file path when path is not a directory.
- If pointing at a legacy checkpoint directory, locate the safetensors file and pass its full path, or copy/rename it to model.safetensors in the directory.
Example fix
// before: dir has old-style weights
model.load_checkpoint("/checkpoints/timesfm_v1") # FileNotFoundError
// after: pass the weights file directly, or use a dir containing model.safetensors
model.load_checkpoint("/checkpoints/timesfm_v1/timesfm_weights.safetensors") Defensive patterns
Strategy: validation
Validate before calling
import os
if os.path.isdir(path) and not os.path.exists(os.path.join(path, "model.safetensors")):
raise FileNotFoundError(f"model.safetensors missing in {path}; re-download checkpoint") Try / catch
try:
model.load_checkpoint(path)
except FileNotFoundError:
model = TimesFM_2p5_200M_torch.from_pretrained("google/timesfm-2.5-200m-pytorch") Prevention
- Download checkpoints with git-lfs or huggingface-cli so model.safetensors materializes.
- Assert os.path.exists(dir + '/model.safetensors') before loading.
- Pass the .safetensors file path directly for non-standard directory layouts.
- Prefer from_pretrained(repo_id) over manual checkpoint directory management.
When it happens
Trigger: Calling model.load_checkpoint(path) where path is an existing directory that does not contain model.safetensors — e.g. the directory only holds flax checkpoint files, or an incomplete/interrupted download left the folder without the safetensors file.
Common situations: Downloading the Hugging Face repo without git-lfs (so model.safetensors is a pointer stub or missing), renaming checkpoint files manually, pointing at a directory holding an older TimesFM 1.x/2.0 checkpoint whose weights use a different filename, or copying only part of a checkpoint.
Related errors
AI-assisted analysis of google-research/timesfm@331c6d33cb (2026-08-29).
Data as JSON: /api/errors/142864f97f9c280e.
Report an issue: GitHub.