{"record":{"id":"794234c82b67b860","repo":"hiyouga/LlamaFactory","slug":"resume-from-checkpoint-will-be-supported-in-the","errorCode":null,"errorMessage":"`resume_from_checkpoint` will be supported in the future version.","messagePattern":"`resume_from_checkpoint` will be supported in the future version\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/train/ppo/trainer.py","lineNumber":203,"sourceCode":"                    self.reward_model = self._prepare_deepspeed(self.reward_model)\n            else:\n                self.reward_model = self.accelerator.prepare_model(self.reward_model, evaluation_mode=True)\n\n        self.add_callback(FixValueHeadModelCallback)\n\n        if processor is not None:\n            self.add_callback(SaveProcessorCallback(processor))\n\n        if finetuning_args.use_badam:\n            from badam import BAdamCallback, clip_grad_norm_old_version  # type: ignore\n\n            self.accelerator.clip_grad_norm_ = MethodType(clip_grad_norm_old_version, self.accelerator)\n            self.add_callback(BAdamCallback)\n\n    def ppo_train(self, resume_from_checkpoint: Optional[str] = None) -> None:\n        r\"\"\"Implement training loop for the PPO stage, like _inner_training_loop() in Huggingface's Trainer.\"\"\"\n        if resume_from_checkpoint is not None:\n            raise ValueError(\"`resume_from_checkpoint` will be supported in the future version.\")\n\n        total_train_batch_size = (\n            self.args.per_device_train_batch_size\n            * self.args.gradient_accumulation_steps\n            * self.finetuning_args.ppo_buffer_size\n            * self.args.world_size\n        )\n        if self.args.max_steps > 0:\n            num_examples = total_train_batch_size * self.args.max_steps\n            num_train_epochs = sys.maxsize\n            max_steps = self.args.max_steps\n            steps_in_epoch = self.args.max_steps\n        else:\n            len_dataloader = len(self.dataloader)\n            num_examples = len(self.dataset)\n            num_train_epochs = self.args.num_train_epochs\n            max_steps = math.ceil(num_train_epochs * len_dataloader)\n            steps_in_epoch = len_dataloader","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/train/ppo/trainer.py#L185-L221","documentation":"The PPO trainer in LlamaFactory implements its own training loop (it does not reuse HuggingFace Trainer's inner loop), and checkpoint resumption for that custom loop is not implemented yet. Calling `ppo_train(resume_from_checkpoint=...)` with a non-None value is explicitly rejected at src/llamafactory/train/ppo/trainer.py:203. This is a deliberate guard so users do not silently get incorrect resume semantics.","triggerScenarios":"Running `llamafactory-cli train` with a PPO config and either passing `resume_from_checkpoint` in the training args or invoking `trainer.ppo_train(resume_from_checkpoint=<path>)` directly (e.g. from a custom script or via TrainingArguments.auto_find_batch_size-style flows that retry with a checkpoint path).","commonSituations":"A user's RLHF/PPO run is interrupted and they try to resume it the way they would resume an SFT run (`--resume_from_checkpoint checkpoint-xxx`). Any framework or wrapper that always passes a checkpoint path to train() will trip this on the PPO stage.","solutions":["Start the PPO run from scratch instead of resuming: remove resume_from_checkpoint from the config/command.","If using a wrapper that always passes a checkpoint, patch it to pass None for the ppo stage.","Preserve what you can manually: keep the same model/adapter inputs so the base weights are unchanged, and accept that PPO optimizer/step state restarts.","Watch LlamaFactory releases; the message states resume support is planned for a future version."],"exampleFix":"# before\ntrainer.ppo_train(resume_from_checkpoint=\"output/ppo_run/checkpoint-500\")\n\n# after (PPO restarts from current weights, no step-state resume)\ntrainer.ppo_train(resume_from_checkpoint=None)","handlingStrategy":"validation","validationCode":"def can_resume_ppo(trainer, resume_from_checkpoint):\n    return resume_from_checkpoint is None","typeGuard":null,"tryCatchPattern":"try:\n    trainer.ppo_train(resume_from_checkpoint=None)\nexcept ValueError as e:\n    if \"resume_from_checkpoint\" in str(e):\n        trainer.ppo_train(resume_from_checkpoint=None)  # restart clean\n    else:\n        raise","preventionTips":["Never pass resume_from_checkpoint for the ppo stage; treat PPO runs as non-resumable.","In wrappers, branch on finetuning_args.stage before forwarding checkpoint paths."],"tags":["ppo","reinforcement-learning","checkpoint","resume"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}