{"record":{"id":"2b2fd0b4c8f836e5","repo":"hiyouga/LlamaFactory","slug":"unsloth-does-not-support-lora-reward-model","errorCode":null,"errorMessage":"Unsloth does not support lora reward model.","messagePattern":"Unsloth does not support lora reward model\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/hparams/parser.py","lineNumber":461,"sourceCode":"            raise ValueError(\"Megatron Bridge arguments are missing. Please set USE_MEGATRON_BRIDGE=1.\")\n        _validate_megatron_bridge_parallel_args(mb_args, training_args.world_size)\n        finetuning_args.megatron_bridge_args = mb_args\n\n    if finetuning_args.stage in [\"rm\", \"ppo\"] and training_args.load_best_model_at_end:\n        raise ValueError(\"RM and PPO stages do not support `load_best_model_at_end`.\")\n\n    if finetuning_args.stage == \"ppo\":\n        if not training_args.do_train:\n            raise ValueError(\"PPO training does not support evaluation, use the SFT stage to evaluate models.\")\n\n        if model_args.shift_attn:\n            raise ValueError(\"PPO training is incompatible with S^2-Attn.\")\n\n        if finetuning_args.reward_model_type == \"lora\" and model_args.use_kt:\n            raise ValueError(\"KTransformers does not support lora reward model.\")\n\n        if finetuning_args.reward_model_type == \"lora\" and model_args.use_unsloth:\n            raise ValueError(\"Unsloth does not support lora reward model.\")\n\n        if training_args.report_to and any(\n            logger not in (\"wandb\", \"tensorboard\", \"trackio\", \"none\") for logger in training_args.report_to\n        ):\n            raise ValueError(\"PPO only accepts wandb, tensorboard, or trackio logger.\")\n\n    if not model_args.use_kt and training_args.parallel_mode == ParallelMode.NOT_DISTRIBUTED:\n        raise ValueError(\"Please launch distributed training with `llamafactory-cli` or `torchrun`.\")\n\n    if training_args.deepspeed and training_args.parallel_mode != ParallelMode.DISTRIBUTED:\n        raise ValueError(\"Please use `FORCE_TORCHRUN=1` to launch DeepSpeed training.\")\n\n    if training_args.max_steps == -1 and data_args.streaming:\n        raise ValueError(\"Please specify `max_steps` in streaming mode.\")\n\n    if training_args.do_train and data_args.dataset is None:\n        raise ValueError(\"Please specify dataset for training.\")\n","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/hparams/parser.py#L443-L479","documentation":"For PPO with a LoRA reward model (reward_model_type == 'lora'), the Unsloth acceleration backend (model_args.use_unsloth) is unsupported — Unsloth patches the model for training the policy and cannot attach the separate LoRA reward adapter. The parser rejects the combination up front.","triggerScenarios":"stage: ppo together with reward_model_type: lora and use_unsloth: true in model_args, passed to llamafactory-cli train / run_exp().","commonSituations":"Enabling Unsloth for memory-efficient single-GPU PPO while reusing a LoRA reward model from an RM run; 'enable all accelerators' configs that set use_unsloth unconditionally.","solutions":["Merge the LoRA reward model into its base (llamafactory-cli export) and use reward_model_type: full with the merged path, keeping use_unsloth for the policy.","Or set use_unsloth: false and run standard LoRA PPO with the LoRA reward model.","Retrain the RM with full finetuning for a checkpoint that works in either setup."],"exampleFix":"# before\nstage: ppo\nreward_model: saves/rm_lora\nreward_model_type: lora\nuse_unsloth: true\n\n# after\nstage: ppo\nreward_model: saves/rm_merged_full\nreward_model_type: full\nuse_unsloth: true","handlingStrategy":"validation","validationCode":"if cfg.get(\"stage\") == \"ppo\" and cfg.get(\"reward_model_type\") == \"lora\" and cfg.get(\"use_unsloth\"):\n    raise SystemExit(\"Unsloth cannot serve a LoRA reward model; merge the RM LoRA via export or disable use_unsloth\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not blanket-enable use_unsloth in shared config templates; make it an explicit per-run choice.","Keep a merged full-format reward model artifact next to every LoRA RM checkpoint for PPO compatibility."],"tags":["ppo","unsloth","reward-model","lora","config"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}