{"record":{"id":"0d4b9c0ec140af29","repo":"hiyouga/LlamaFactory","slug":"no-checkpoint-files-found-in-hf-model-path","errorCode":null,"errorMessage":"No checkpoint files found in {hf_model_path}","messagePattern":"No checkpoint files found in (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/v1/plugins/trainer_plugins/distributed/fsdp2.py","lineNumber":518,"sourceCode":"        else:\n            is_safetensors = False\n            index_file = os.path.join(hf_model_path, \"pytorch_model.bin.index.json\")\n            if os.path.exists(index_file):\n                with open(index_file) as f:\n                    index = json.load(f)\n                checkpoint_files = sorted(set(index[\"weight_map\"].values()))\n                checkpoint_files = [os.path.join(hf_model_path, f) for f in checkpoint_files]\n            elif os.path.exists(os.path.join(hf_model_path, \"pytorch_model.bin\")):\n                checkpoint_files = [os.path.join(hf_model_path, \"pytorch_model.bin\")]\n            else:\n                checkpoint_files = sorted(glob.glob(os.path.join(hf_model_path, \"*.safetensors\")))\n                if checkpoint_files:\n                    is_safetensors = True\n                else:\n                    checkpoint_files = sorted(glob.glob(os.path.join(hf_model_path, \"*.bin\")))\n\n        if not checkpoint_files:\n            raise ValueError(f\"No checkpoint files found in {hf_model_path}\")\n\n        param_map = dict(model.named_parameters())\n        conversion_ctx = self._try_build_hf_weight_conversion_context(model)\n        total_files = len(checkpoint_files)\n\n        for i, ckpt_file in enumerate(checkpoint_files):\n            if self.rank == 0:\n                logger.info(f\"[{i + 1}/{total_files}] Loading {os.path.basename(ckpt_file)} ...\")\n\n            if is_safetensors:\n                from safetensors import safe_open\n\n                with safe_open(ckpt_file, framework=\"pt\", device=\"cpu\") as f:\n                    for key in sorted(f.keys(), key=sort_key):\n                        renamed_key = key\n                        source_pattern = None\n                        if conversion_ctx is not None:\n                            renamed_key, source_pattern = conversion_ctx[\"rename_source_key\"](","sourceCodeStart":500,"sourceCodeEnd":536,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/v1/plugins/trainer_plugins/distributed/fsdp2.py#L500-L536","documentation":"The FSDP2 loader resolves model weights from an index weight_map, pytorch_model.bin, *.safetensors, or *.bin files inside the model directory. If none are present, there is nothing to load into the sharded model and it raises. The directory exists but contains no recognizable checkpoint shards.","triggerScenarios":"hf_model_path points at a directory with config.json/tokenizer but no weight files (e.g. a repo with weights in a subfolder like 'transformers/'), or all files use an unrecognized extension.","commonSituations":"Pointing at the root of a hub repo whose weights live under a subdirectory; interrupted download that left only metadata files; pointing at a tokenizer-only or config-only directory.","solutions":["List the directory and confirm *.safetensors or *.bin files exist at that level","Point hf_model_path at the subdirectory that actually contains the shards (e.g. .../transformers/)","Re-download the model if the snapshot is incomplete (delete cache entry and retry, check HF_HUB_OFFLINE)"],"exampleFix":"# before\nhf_model_path = \"org/model-root\"  # weights in model-root/transformers/\n\n# after\nhf_model_path = \"org/model-root/transformers\"","handlingStrategy":"validation","validationCode":"def has_checkpoint_files(d: str) -> bool:\n    import glob, json, os\n    if os.path.isfile(os.path.join(d, \"model.safetensors.index.json\")):\n        return True\n    return bool(\n        os.path.isfile(os.path.join(d, \"pytorch_model.bin\"))\n        or glob.glob(os.path.join(d, \"*.safetensors\"))\n        or glob.glob(os.path.join(d, \"*.bin\"))\n    )\n\nassert has_checkpoint_files(hf_model_path), f\"no weight shards in {hf_model_path}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify shard files exist at the exact directory level you pass","Watch for hub repos that nest weights under a subfolder","Check snapshot completeness after downloads"],"tags":["fsdp2","model-loading","checkpoint","filesystem"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}