google-research/timesfm · error · FileNotFoundError
{cls.WEIGHTS_FILENAME} not found in directory {model_id}
Error message
{cls.WEIGHTS_FILENAME} not found in directory {model_id} What it means
_from_pretrained is the from_pretrained hook: when model_id points to a local directory it requires model.safetensors (cls.WEIGHTS_FILENAME) inside it; otherwise it downloads from Hugging Face via hf_hub_download. If model_id is a directory lacking the weights file, a FileNotFoundError is raised before any model is built.
Source
Thrown at src/timesfm/timesfm_2p5/timesfm_2p5_torch.py:341
try:
hf_hub_download(
repo_id=model_id,
filename=cls.CONFIG_FILENAME,
revision=revision,
cache_dir=cache_dir,
force_download=force_download,
local_files_only=local_files_only,
token=token,
)
except Exception:
pass
model_file_path = ""
if os.path.isdir(model_id):
logging.info("Loading checkpoint from local directory: %s", model_id)
model_file_path = os.path.join(model_id, cls.WEIGHTS_FILENAME)
if not os.path.exists(model_file_path):
raise FileNotFoundError(
f"{cls.WEIGHTS_FILENAME} not found in directory {model_id}"
)
else:
logging.info("Downloading checkpoint from Hugging Face repo %s", model_id)
model_file_path = hf_hub_download(
repo_id=model_id,
filename=cls.WEIGHTS_FILENAME,
revision=revision,
cache_dir=cache_dir,
force_download=force_download,
token=token,
local_files_only=local_files_only,
)
# Create an instance of the model wrapper class.
instance = cls(config=config, **model_kwargs)
logging.info("Loading checkpoint from: %s", model_file_path)View on GitHub (pinned to 331c6d33cb)
Solutions
- Check the directory contains model.safetensors; if not, re-download it from the Hugging Face repo (with git-lfs enabled or huggingface-cli download).
- Install/initialize git-lfs and pull real weights: git lfs install && git lfs pull in the cloned repo.
- Pass the correct HF repo id (e.g. google/timesfm-2.5-200m-pytorch) or the direct .safetensors file path instead of the incomplete directory.
- Verify the download completed (file size matches the repo listing) before loading.
Example fix
// before
model = TimesFM_2p5_200M_torch.from_pretrained("./saved_model") # dir lacks model.safetensors
// after
model = TimesFM_2p5_200M_torch.from_pretrained("google/timesfm-2.5-200m-pytorch")
# or ensure ./saved_model/model.safetensors exists before calling Defensive patterns
Strategy: validation
Validate before calling
import os
if os.path.isdir(model_id) and not os.path.exists(os.path.join(model_id, "model.safetensors")):
model_id = "google/timesfm-2.5-200m-pytorch" # fall back to HF repo id Try / catch
try:
model = TimesFM_2p5_200M_torch.from_pretrained(model_id)
except FileNotFoundError:
logging.warning("Local dir %s lacks model.safetensors; using HF repo", model_id)
model = TimesFM_2p5_200M_torch.from_pretrained("google/timesfm-2.5-200m-pytorch") Prevention
- Verify the local dir contains model.safetensors (and its size) before from_pretrained.
- Enable git-lfs before cloning model repos.
- Use huggingface-cli download to get complete snapshots.
- Prefer repo ids over hand-managed local dirs.
When it happens
Trigger: Calling TimesFM_2p5_200M_torch.from_pretrained(local_dir) where local_dir is a directory without model.safetensors. A non-directory model_id is instead treated as a Hugging Face repo id and downloaded.
Common situations: A local HF snapshot cache missing the LFS weights, cloning the model repo without git-lfs, pointing from_pretrained at a directory containing config/tokenizer files but not weights, or an interrupted copy of a checkpoint directory.
Related errors
AI-assisted analysis of google-research/timesfm@331c6d33cb (2026-08-29).
Data as JSON: /api/errors/9d1638a7ba8ff149.
Report an issue: GitHub.