{"record":{"id":"7e171fa9af75b45d","repo":"hiyouga/LlamaFactory","slug":"megatron-bridge-only-supports-full-and-lora-fi","errorCode":null,"errorMessage":"Megatron Bridge only supports `full` and `lora` finetuning.","messagePattern":"Megatron Bridge only supports `full` and `lora` finetuning\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/hparams/parser.py","lineNumber":437,"sourceCode":"        if training_args.predict_with_generate:\n            raise ValueError(\"`predict_with_generate` cannot be set as True except SFT.\")\n\n        if data_args.neat_packing:\n            raise ValueError(\"`neat_packing` cannot be set as True except SFT.\")\n\n        if data_args.train_on_prompt or data_args.mask_history:\n            raise ValueError(\"`train_on_prompt` or `mask_history` cannot be set as True except SFT.\")\n\n    if finetuning_args.stage == \"sft\" and training_args.do_predict and not training_args.predict_with_generate:\n        raise ValueError(\"Please enable `predict_with_generate` to save model predictions.\")\n\n    if finetuning_args.use_megatron_bridge:\n        if finetuning_args.use_mca or finetuning_args.use_hyper_parallel:\n            raise ValueError(\"Megatron Bridge cannot be used together with MCA or HyperParallel.\")\n        if finetuning_args.stage not in [\"pt\", \"sft\"]:\n            raise ValueError(\"Megatron Bridge only supports the `pt` and `sft` stages.\")\n        if finetuning_args.finetuning_type not in [\"full\", \"lora\"]:\n            raise ValueError(\"Megatron Bridge only supports `full` and `lora` finetuning.\")\n        if model_args.quantization_bit is not None:\n            raise ValueError(\"Quantized models are not supported with Megatron Bridge.\")\n        if training_args.deepspeed is not None:\n            raise ValueError(\"Megatron Bridge is incompatible with DeepSpeed.\")\n        if mb_args is None:\n            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.\")","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/hparams/parser.py#L419-L455","documentation":"Megatron Bridge supports full fine-tuning and LoRA only. Other finetuning types such as freeze (and OFT or PiSSA variants) have no Megatron-side implementation, so the parser validates finetuning_type is in ['full', 'lora'] when the bridge is enabled.","triggerScenarios":"USE_MEGATRON_BRIDGE=1 with finetuning_type: freeze (or any value other than full/lora) in the YAML, submitted via llamafactory-cli train.","commonSituations":"Users coming from freeze-tuning workflows on the HF path who switch to Megatron for speed; configs that default finetuning_type: freeze for parameter-efficient experiments.","solutions":["Set finetuning_type: lora (or full) in the config when using Megatron Bridge.","If freeze-tuning is required, unset USE_MEGATRON_BRIDGE and run on the standard backend.","For LoRA on bridge, also provide the usual lora_rank/lora_target settings."],"exampleFix":"# before\nexport USE_MEGATRON_BRIDGE=1\nfinetuning_type: freeze\n\n# after\nexport USE_MEGATRON_BRIDGE=1\nfinetuning_type: lora","handlingStrategy":"validation","validationCode":"import os\n\nif os.environ.get(\"USE_MEGATRON_BRIDGE\") == \"1\" and cfg.get(\"finetuning_type\") not in (\"full\", \"lora\"):\n    raise SystemExit(\"Megatron Bridge supports only full/lora finetuning\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include finetuning_type in the backend-compatibility matrix your config linter enforces.","Default new Megatron configs to finetuning_type: lora unless full FT is intended."],"tags":["megatron","config","finetuning-type","validation"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}