{"record":{"id":"7d8f212d1b7597f8","repo":"hiyouga/LlamaFactory","slug":"dora-is-not-compatible-with-ptq-quantized-models","errorCode":null,"errorMessage":"DoRA is not compatible with PTQ-quantized models.","messagePattern":"DoRA is not compatible with PTQ-quantized models\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/model/adapter.py","lineNumber":244,"sourceCode":"        logger.info_rank0(\"Loaded adapter(s): {}\".format(\",\".join(model_args.adapter_name_or_path)))\n\n    if is_trainable and adapter_to_resume is None:  # create new lora weights while training\n        if len(finetuning_args.lora_target) == 1 and finetuning_args.lora_target[0] == \"all\":\n            target_modules = find_all_linear_modules(model, finetuning_args.freeze_vision_tower)\n        else:\n            target_modules = finetuning_args.lora_target\n\n        if finetuning_args.use_llama_pro:\n            target_modules = find_expanded_modules(model, target_modules, finetuning_args.freeze_trainable_layers)\n\n        target_modules = patch_target_modules(model, finetuning_args, target_modules)\n\n        if (\n            finetuning_args.use_dora\n            and getattr(model, \"quantization_method\", None) is not None\n            and getattr(model, \"quantization_method\", None) != QuantizationMethod.BNB\n        ):\n            raise ValueError(\"DoRA is not compatible with PTQ-quantized models.\")\n\n        if model_args.resize_vocab and finetuning_args.additional_target is None:\n            input_embeddings = model.get_input_embeddings()\n            output_embeddings = model.get_output_embeddings()\n            module_names = set()\n            for name, module in model.named_modules():\n                if module in [input_embeddings, output_embeddings]:\n                    module_names.add(name.split(\".\")[-1])\n\n            finetuning_args.additional_target = module_names\n            logger.warning_rank0(\"Vocab has been resized, add {} to trainable params.\".format(\",\".join(module_names)))\n\n        if finetuning_args.finetuning_type == \"lora\":\n            peft_kwargs = {\n                \"r\": finetuning_args.lora_rank,\n                \"target_modules\": target_modules,\n                \"lora_alpha\": finetuning_args.lora_alpha,\n                \"lora_dropout\": finetuning_args.lora_dropout,","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/model/adapter.py#L226-L262","documentation":"Raised in _setup_lora_tuning when use_dora is true and the model was loaded with a quantization_method other than BNB (i.e. GPTQ/AWQ PTQ checkpoints). DoRA's weight-decomposed deltas need to modify base weights, which only works on bnb-quantized (QLoRA-style) models in this stack.","triggerScenarios":"Loading a GPTQ or AWQ model (model.hf_quantizer sets quantization_method) and setting use_dora: true with finetuning_type: lora.","commonSituations":"Swapping a QLoRA+DoRA config to a GPTQ checkpoint to save memory; enabling DoRA on an -AWQ/-GPTQ repo without realizing the quantizer type matters.","solutions":["Set use_dora: false for GPTQ/AWQ models (plain LoRA works).","Use an unquantized or bnb-quantized (quantization_bit: 4/8) model if you want DoRA — the check explicitly allows QuantizationMethod.BNB.","Switch to a GPTQ/AWQ path without DoRA, or dequantize/export the model first."],"exampleFix":"# before\nmodel_name_or_path: Qwen/Qwen2-7B-GPTQ-Int4\nuse_dora: true\n\n# after\nmodel_name_or_path: Qwen/Qwen2-7B\nquantization_bit: 4\nuse_dora: true","handlingStrategy":"validation","validationCode":"qm = getattr(model, \"quantization_method\", None)  # after loading\nif use_dora and qm is not None:\n    from peft.utils import QuantizationMethod\n    assert qm == QuantizationMethod.BNB, \\\n        \"DoRA needs unquantized or bnb-quantized weights; GPTQ/AWQ checkpoints are unsupported\"\n# before loading, a cheap proxy: assert model path is not a -GPTQ/-AWQ repo when use_dora","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pair DoRA only with unquantized or quantization_bit (bnb) checkpoints.","Recognize PTQ repos by the -GPTQ-/-AWQ- suffix in the model name and disable use_dora for them."],"tags":["dora","lora","gptq","awq","quantization"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}