Skip to content

Commit e0420b3

Browse files
authored
fix: allow merge lora on pre-quantized model (axolotl-ai-cloud#2511)
* fix: allow merge lora on pre-quantized model * fix: remove unused sections per comment
1 parent 9f986f5 commit e0420b3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/axolotl/cli/merge_lora.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ def do_merge_lora(*, cfg: DictDefault) -> None:
3232

3333
LOG.info("Running merge of LoRA with base model...")
3434
model = model.merge_and_unload(progressbar=True)
35-
model.to(dtype=cfg.torch_dtype)
35+
try:
36+
model.to(dtype=cfg.torch_dtype)
37+
except ValueError as e:
38+
LOG.warning("Failed to convert model to dtype %s", cfg.torch_dtype)
39+
LOG.warning("Ignore this if the base_model is pre-quantized.")
40+
LOG.warning("Error raised: %s", e)
41+
3642
model.generation_config.do_sample = True
3743

3844
if cfg.local_rank == 0:

src/axolotl/utils/models.py

-6
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,6 @@ def check_model_config(cfg: DictDefault, model_config: PretrainedConfig):
151151
"Please make sure to point to a GPTQ model."
152152
)
153153

154-
if not cfg.gptq and quant_config_exists and not cfg.load_in_4bit:
155-
raise ValueError(
156-
"model_config.quantization_config is set but `gptq` flag is not. "
157-
"Please use the `gptq` flag to train quantized model or point to a non-quantized model."
158-
)
159-
160154
lora_modules_to_save = get_linear_embedding_layers(model_config.model_type)
161155
if (
162156
cfg.adapter

0 commit comments

Comments
 (0)