{"record":{"id":"9d1638a7ba8ff149","repo":"google-research/timesfm","slug":"cls-weights-filename-not-found-in-directory-mod","errorCode":null,"errorMessage":"{cls.WEIGHTS_FILENAME} not found in directory {model_id}","messagePattern":"(.+?) not found in directory (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/timesfm/timesfm_2p5/timesfm_2p5_torch.py","lineNumber":341,"sourceCode":"    try:\n      hf_hub_download(\n          repo_id=model_id,\n          filename=cls.CONFIG_FILENAME,\n          revision=revision,\n          cache_dir=cache_dir,\n          force_download=force_download,\n          local_files_only=local_files_only,\n          token=token,\n      )\n    except Exception:\n      pass\n    \n    model_file_path = \"\"\n    if os.path.isdir(model_id):\n      logging.info(\"Loading checkpoint from local directory: %s\", model_id)\n      model_file_path = os.path.join(model_id, cls.WEIGHTS_FILENAME)\n      if not os.path.exists(model_file_path):\n        raise FileNotFoundError(\n          f\"{cls.WEIGHTS_FILENAME} not found in directory {model_id}\"\n        )\n    else:\n      logging.info(\"Downloading checkpoint from Hugging Face repo %s\", model_id)\n      model_file_path = hf_hub_download(\n        repo_id=model_id,\n        filename=cls.WEIGHTS_FILENAME,\n        revision=revision,\n        cache_dir=cache_dir,\n        force_download=force_download,\n        token=token,\n        local_files_only=local_files_only,\n      )\n\n    # Create an instance of the model wrapper class.\n    instance = cls(config=config, **model_kwargs)\n\n    logging.info(\"Loading checkpoint from: %s\", model_file_path)","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/google-research/timesfm/blob/331c6d33cb1ac2611de3056d0ac7164aab6301eb/src/timesfm/timesfm_2p5/timesfm_2p5_torch.py#L323-L359","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nmodel = TimesFM_2p5_200M_torch.from_pretrained(\"./saved_model\")  # dir lacks model.safetensors\n// after\nmodel = TimesFM_2p5_200M_torch.from_pretrained(\"google/timesfm-2.5-200m-pytorch\")\n# or ensure ./saved_model/model.safetensors exists before calling","handlingStrategy":"validation","validationCode":"import os\nif os.path.isdir(model_id) and not os.path.exists(os.path.join(model_id, \"model.safetensors\")):\n    model_id = \"google/timesfm-2.5-200m-pytorch\"  # fall back to HF repo id","typeGuard":null,"tryCatchPattern":"try:\n    model = TimesFM_2p5_200M_torch.from_pretrained(model_id)\nexcept FileNotFoundError:\n    logging.warning(\"Local dir %s lacks model.safetensors; using HF repo\", model_id)\n    model = TimesFM_2p5_200M_torch.from_pretrained(\"google/timesfm-2.5-200m-pytorch\")","preventionTips":["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."],"tags":["file-not-found","checkpoint-loading","huggingface"],"backgroundTag":"checkpoint-file-not-found","analyzedSha":"331c6d33cb1ac2611de3056d0ac7164aab6301eb","analyzedAt":"2026-08-29T01:04:23.138Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}