{"record":{"id":"a55e5a4b4a3acfba","repo":"Lightning-AI/pytorch-lightning","slug":"you-cannot-execute-fn-ckpt-path-best-with","errorCode":null,"errorMessage":"You cannot execute `.{fn}(ckpt_path=\"best\")` with `fast_dev_run=True`. Please pass an exact checkpoint path to `.{fn}(ckpt_path=...)`","messagePattern":"You cannot execute `\\.(.+?)\\(ckpt_path=\"best\"\\)` with `fast_dev_run=True`\\. Please pass an exact checkpoint path to `\\.(.+?)\\(ckpt_path=\\.\\.\\.\\)`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/checkpoint_connector.py","lineNumber":171,"sourceCode":"                + f\" You can pass `.{fn}(ckpt_path='best')` to use the best model or\"\n                f\" `.{fn}(ckpt_path='last')` to use the last model.\"\n                \" If you pass a value, this warning will be silenced.\"\n            )\n\n        if ckpt_path == \"best\":\n            if len(self.trainer.checkpoint_callbacks) > 1:\n                rank_zero_warn(\n                    f'`.{fn}(ckpt_path=\"best\")` is called with Trainer configured with multiple `ModelCheckpoint`'\n                    \" callbacks. It will use the best checkpoint path from first checkpoint callback.\"\n                )\n\n            if not self.trainer.checkpoint_callback:\n                raise ValueError(f'`.{fn}(ckpt_path=\"best\")` is set but `ModelCheckpoint` is not configured.')\n\n            has_best_model_path = self.trainer.checkpoint_callback.best_model_path\n            if hasattr(self.trainer.checkpoint_callback, \"best_model_path\") and not has_best_model_path:\n                if self.trainer.fast_dev_run:\n                    raise ValueError(\n                        f'You cannot execute `.{fn}(ckpt_path=\"best\")` with `fast_dev_run=True`.'\n                        f\" Please pass an exact checkpoint path to `.{fn}(ckpt_path=...)`\"\n                    )\n                raise ValueError(\n                    f'`.{fn}(ckpt_path=\"best\")` is set but `ModelCheckpoint` is not configured to save the best model.'\n                )\n            # load best weights\n            ckpt_path = getattr(self.trainer.checkpoint_callback, \"best_model_path\", None)\n\n        elif ckpt_path == \"last\":\n            candidates = {getattr(ft, \"ckpt_path\", None) for ft in ft_checkpoints}\n            for callback in self.trainer.checkpoint_callbacks:\n                if isinstance(callback, ModelCheckpoint):\n                    candidates |= callback._find_last_checkpoints(self.trainer)\n            candidates_fs = {path: get_filesystem(path) for path in candidates if path}\n            candidates_ts = {path: fs.modified(path) for path, fs in candidates_fs.items() if fs.exists(path)}\n            if not candidates_ts:\n                # not an error so it can be set and forget before the first `fit` run","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/checkpoint_connector.py#L153-L189","documentation":"Raised when ckpt_path=\"best\" is used but no best_model_path exists yet and fast_dev_run=True. Fast-dev-run runs a single batch/epoch and skips checkpoint saving, so there is never a best checkpoint to resolve; Lightning asks for an explicit path instead.","triggerScenarios":"trainer.test(ckpt_path=\"best\") / .validate() / .predict() on a Trainer configured with fast_dev_run=True where the checkpoint callback has no best_model_path (nothing was saved).","commonSituations":"Smoke-testing pipelines with fast_dev_run=True while reusing eval code that requests the best checkpoint; CI quick checks.","solutions":["Pass an exact checkpoint path: trainer.test(ckpt_path=\"path/to/file.ckpt\")","Use ckpt_path=None to test with the current in-memory weights","Disable fast_dev_run for the fit run so a best checkpoint gets saved before requesting \"best\""],"exampleFix":"# before\ntrainer = Trainer(fast_dev_run=True)\ntrainer.fit(model)\ntrainer.test(ckpt_path=\"best\")\n# after\ntrainer = Trainer(fast_dev_run=True)\ntrainer.fit(model)\ntrainer.test(ckpt_path=\"runs/epoch=2-step=123.ckpt\")  # or ckpt_path=None","handlingStrategy":"validation","validationCode":"if trainer.fast_dev_run:\n    assert ckpt_path not in (\"best\", \"last\") or trainer.checkpoint_callback.best_model_path, \\\n        \"fast_dev_run saves no checkpoints; pass an explicit path\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Branch eval logic: fast_dev_run -> ckpt_path=None or explicit path","Treat fast_dev_run as a pipeline smoke test, not a checkpoint producer"],"tags":["lightning","fast-dev-run","checkpoint","best-model","smoke-test"],"backgroundTag":"checkpoint-not-found","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}