{"record":{"id":"142864f97f9c280e","repo":"google-research/timesfm","slug":"self-weights-filename-not-found-in-directory-pa","errorCode":null,"errorMessage":"{self.WEIGHTS_FILENAME} not found in directory {path}","messagePattern":"(.+?) not found in directory (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/timesfm/timesfm_2p5/timesfm_2p5_torch.py","lineNumber":292,"sourceCode":"  CONFIG_FILENAME = \"config.json\"\n\n  def __init__(\n    self,\n    torch_compile: bool = True,\n    config: Optional[dict] = None,\n    **kwargs,\n  ):\n    self.model = TimesFM_2p5_200M_torch_module()\n    self.torch_compile = torch_compile\n    if config is not None:\n      self._hub_mixin_config = config\n\n  def load_checkpoint(self, path: str, **kwargs):\n    \"\"\"Loads a TimesFM model from a checkpoint directory or file.\"\"\"\n    if os.path.isdir(path):\n      model_file_path = os.path.join(path, self.WEIGHTS_FILENAME)\n      if not os.path.exists(model_file_path):\n        raise FileNotFoundError(\n          f\"{self.WEIGHTS_FILENAME} not found in directory {path}\"\n        )\n    else:\n      model_file_path = path\n\n    torch_compile = kwargs.pop(\"torch_compile\", self.torch_compile)\n    self.model.load_checkpoint(model_file_path, **kwargs)\n    if torch_compile:\n      logging.info(\"Compiling model...\")\n      self.model.forward = torch.compile(self.model.forward)\n\n  @classmethod\n  def _from_pretrained(\n    cls,\n    *,\n    model_id: str = DEFAULT_REPO_ID,\n    revision: Optional[str],\n    cache_dir: Optional[Union[str, Path]],","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/google-research/timesfm/blob/331c6d33cb1ac2611de3056d0ac7164aab6301eb/src/timesfm/timesfm_2p5/timesfm_2p5_torch.py#L274-L310","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: dir has old-style weights\nmodel.load_checkpoint(\"/checkpoints/timesfm_v1\")  # FileNotFoundError\n// after: pass the weights file directly, or use a dir containing model.safetensors\nmodel.load_checkpoint(\"/checkpoints/timesfm_v1/timesfm_weights.safetensors\")","handlingStrategy":"validation","validationCode":"import os\nif os.path.isdir(path) and not os.path.exists(os.path.join(path, \"model.safetensors\")):\n    raise FileNotFoundError(f\"model.safetensors missing in {path}; re-download checkpoint\")","typeGuard":null,"tryCatchPattern":"try:\n    model.load_checkpoint(path)\nexcept FileNotFoundError:\n    model = TimesFM_2p5_200M_torch.from_pretrained(\"google/timesfm-2.5-200m-pytorch\")","preventionTips":["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."],"tags":["file-not-found","checkpoint-loading","filesystem"],"backgroundTag":"checkpoint-file-not-found","analyzedSha":"331c6d33cb1ac2611de3056d0ac7164aab6301eb","analyzedAt":"2026-08-29T01:04:23.138Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}