From b5eefe5c4c084b63a12b023cae877fcd1914d4fc Mon Sep 17 00:00:00 2001 From: Erich Schubert Date: Tue, 9 Apr 2024 17:53:40 +0200 Subject: [PATCH 1/3] Pass additional_target to unsloth Fixes #3200 --- src/llmtuner/model/adapter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/llmtuner/model/adapter.py b/src/llmtuner/model/adapter.py index eb6d3878..861b8008 100644 --- a/src/llmtuner/model/adapter.py +++ b/src/llmtuner/model/adapter.py @@ -145,6 +145,8 @@ def init_adapter( from unsloth import FastLanguageModel # type: ignore unsloth_peft_kwargs = {"model": model, "max_seq_length": model_args.model_max_length} + if finetuning_args.additional_target: + unsloth_peft_kwargs["modules_to_save"] = finetuning_args.additional_target model = FastLanguageModel.get_peft_model(**peft_kwargs, **unsloth_peft_kwargs) else: lora_config = LoraConfig( From 2111b586b648caa150a8e41877c7fede75911da8 Mon Sep 17 00:00:00 2001 From: hoshi-hiyouga Date: Wed, 10 Apr 2024 00:57:30 +0800 Subject: [PATCH 2/3] Update adapter.py --- src/llmtuner/model/adapter.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/llmtuner/model/adapter.py b/src/llmtuner/model/adapter.py index 861b8008..bf206907 100644 --- a/src/llmtuner/model/adapter.py +++ b/src/llmtuner/model/adapter.py @@ -139,20 +139,18 @@ def init_adapter( "lora_alpha": finetuning_args.lora_alpha, "lora_dropout": finetuning_args.lora_dropout, "use_rslora": finetuning_args.use_rslora, + "modules_to_save": finetuning_args.additional_target, } if model_args.use_unsloth: from unsloth import FastLanguageModel # type: ignore - unsloth_peft_kwargs = {"model": model, "max_seq_length": model_args.model_max_length} - if finetuning_args.additional_target: - unsloth_peft_kwargs["modules_to_save"] = finetuning_args.additional_target + unsloth_peft_kwargs = {"model": model, "max_seq_length": model_args.model_max_length} model = FastLanguageModel.get_peft_model(**peft_kwargs, **unsloth_peft_kwargs) else: lora_config = LoraConfig( task_type=TaskType.CAUSAL_LM, inference_mode=False, - modules_to_save=finetuning_args.additional_target, use_dora=finetuning_args.use_dora, **peft_kwargs, ) From 98bc97d8d218182c026e9f57bbcbf40ab1e0bc87 Mon Sep 17 00:00:00 2001 From: hoshi-hiyouga Date: Wed, 10 Apr 2024 00:57:51 +0800 Subject: [PATCH 3/3] Update adapter.py --- src/llmtuner/model/adapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llmtuner/model/adapter.py b/src/llmtuner/model/adapter.py index bf206907..bf6f9381 100644 --- a/src/llmtuner/model/adapter.py +++ b/src/llmtuner/model/adapter.py @@ -145,7 +145,7 @@ def init_adapter( if model_args.use_unsloth: from unsloth import FastLanguageModel # type: ignore - unsloth_peft_kwargs = {"model": model, "max_seq_length": model_args.model_max_length} + unsloth_peft_kwargs = {"model": model, "max_seq_length": model_args.model_max_length} model = FastLanguageModel.get_peft_model(**peft_kwargs, **unsloth_peft_kwargs) else: lora_config = LoraConfig(