Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry pick]disable lora #8721

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llm/merge_lora_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def merge():
config=config,
low_cpu_mem_usage=True,
)
lora_config.merge_weights = True
model = LoRAModel.from_pretrained(model=model, lora_path=args.lora_path, lora_config=lora_config)
model.merge()
model.eval()
model_state_dict = model.model.state_dict()
for key in list(model_state_dict):
Expand Down
7 changes: 4 additions & 3 deletions llm/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
AutoConfig,
AutoModelForCausalLM,
AutoTokenizer,
ChatGLMv2Tokenizer,
ChatGLMTokenizer,
ChatGLMv2Tokenizer,
LlamaTokenizer,
PretrainedModel,
PretrainedTokenizer,
Expand Down Expand Up @@ -242,7 +242,8 @@ def _preprocess(self, source):
padding=True,
# when use chat_template, it should not add special tokens
# chatglm2 prefix-tokens can not be tokenized into ids
add_special_tokens=self.tokenizer.chat_template is None or isinstance(self.tokenizer, (ChatGLMv2Tokenizer, ChatGLMTokenizer)),
add_special_tokens=self.tokenizer.chat_template is None
or isinstance(self.tokenizer, (ChatGLMv2Tokenizer, ChatGLMTokenizer)),
)
return tokenized_source

Expand Down Expand Up @@ -272,7 +273,6 @@ def __init__(
if config.lora_path is not None:
lora_config = LoRAConfig.from_pretrained(config.lora_path)
dtype = lora_config.dtype
lora_config.merge_weights = True
elif config.prefix_path is not None:
prefix_config = PrefixConfig.from_pretrained(config.prefix_path)
dtype = prefix_config.dtype
Expand All @@ -289,6 +289,7 @@ def __init__(
tensor_parallel_degree=self.tensor_parallel_degree,
tensor_parallel_rank=self.tensor_parallel_rank,
)
self.model.merge()

if config.lora_path is not None:
self.model = LoRAModel.from_pretrained(
Expand Down
8 changes: 1 addition & 7 deletions paddlenlp/peft/lora/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,5 @@
# limitations under the License.

from .lora_config import LoRAConfig
from .lora_layers import (
ColumnParallelLoRALinear,
ColumnParallelLoRAMergedLinear,
LoRALinear,
LoRAMergedLinear,
RowParallelLoRALinear,
)
from .lora_layers import ColumnParallelLoRALinear, LoRALinear, RowParallelLoRALinear
from .lora_model import LoRAModel
5 changes: 5 additions & 0 deletions paddlenlp/peft/lora/lora_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ def __post_init__(self):
"We will automatically set `use_quick_lora` to `False` to avoid potential inconsistencies."
)
self.use_quick_lora = False
if self.merge_weights:
logger.error(
"'merge_weights' is deprecated and will be removed in a future version. "
"Please apply model.merge() or model.unmerge() to merge/unmerge LoRA weight to base model."
)

@property
def scaling(self):
Expand Down
Loading
Loading