{"record":{"id":"4feca6993a27d379","repo":"hiyouga/LlamaFactory","slug":"adapter-is-only-valid-for-the-lora-method","errorCode":null,"errorMessage":"Adapter is only valid for the LoRA method.","messagePattern":"Adapter is only valid for the LoRA method\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/hparams/parser.py","lineNumber":233,"sourceCode":"        transformers.utils.logging.enable_default_handler()\n        transformers.utils.logging.enable_explicit_format()\n\n\ndef _set_env_vars() -> None:\n    if is_torch_npu_available():\n        # avoid JIT compile on NPU devices, see https://zhuanlan.zhihu.com/p/660875458\n        torch.npu.set_compile_mode(jit_compile=is_env_enabled(\"NPU_JIT_COMPILE\"))\n        # avoid use fork method on NPU devices, see https://github.com/hiyouga/LLaMA-Factory/issues/7447\n        os.environ[\"VLLM_WORKER_MULTIPROC_METHOD\"] = \"spawn\"\n\n\ndef _verify_model_args(\n    model_args: \"ModelArguments\",\n    data_args: \"DataArguments\",\n    finetuning_args: \"FinetuningArguments\",\n) -> None:\n    if model_args.adapter_name_or_path is not None and finetuning_args.finetuning_type != \"lora\":\n        raise ValueError(\"Adapter is only valid for the LoRA method.\")\n\n    if model_args.quantization_bit is not None:\n        if finetuning_args.finetuning_type not in [\"lora\", \"oft\"]:\n            raise ValueError(\"Quantization is only compatible with the LoRA or OFT method.\")\n\n        if finetuning_args.pissa_init:\n            raise ValueError(\"Please use scripts/pissa_init.py to initialize PiSSA for a quantized model.\")\n\n        if model_args.resize_vocab:\n            raise ValueError(\"Cannot resize embedding layers of a quantized model.\")\n\n        if model_args.adapter_name_or_path is not None and finetuning_args.create_new_adapter:\n            raise ValueError(\"Cannot create new adapter upon a quantized model.\")\n\n        if model_args.adapter_name_or_path is not None and len(model_args.adapter_name_or_path) != 1:\n            raise ValueError(\"Quantized model only accepts a single adapter. Merge them first.\")\n\n","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/hparams/parser.py#L215-L251","documentation":"Raised by _verify_model_args when adapter_name_or_path is set but finetuning_type is not 'lora'. Adapters in LlamaFactory are LoRA (or OFT-style) delta weights; loading them only makes sense when the run itself uses the LoRA method, so any other finetuning_type combined with an adapter path is rejected.","triggerScenarios":"A YAML with adapter_name_or_path: saves/lora_v1 while finetuning_type: full (or freeze); _verify_model_args runs during get_train_args/get_infer_args before model loading.","commonSituations":"Continuing from a LoRA run but flipping to full finetuning while leaving the adapter path behind; or eval configs that set the adapter but forget finetuning_type: lora.","solutions":["Set `finetuning_type: lora` when specifying `adapter_name_or_path`.","Or remove `adapter_name_or_path` if you truly want full/freeze finetuning from the base weights."],"exampleFix":"# before (yaml)\nfinetuning_type: full\nadapter_name_or_path: saves/lora_v1\n\n# after (yaml)\nfinetuning_type: lora\nadapter_name_or_path: saves/lora_v1","handlingStrategy":"validation","validationCode":"if cfg.get('adapter_name_or_path') and cfg.get('finetuning_type') != 'lora':\n    raise SystemExit('adapters require finetuning_type: lora')","typeGuard":"def uses_adapter_with_lora(cfg: dict) -> bool:\n    return not cfg.get('adapter_name_or_path') or cfg.get('finetuning_type') == 'lora'","tryCatchPattern":null,"preventionTips":["Pair adapter paths with finetuning_type: lora in shared YAML snippets.","Clean unused keys when changing finetuning_type."],"tags":["lora","adapter","config","llamafactory"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}