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

the model before lora load and after lora load is diff #16

Open
danieltanhx opened this issue Aug 31, 2023 · 1 comment
Open

the model before lora load and after lora load is diff #16

danieltanhx opened this issue Aug 31, 2023 · 1 comment

Comments

@danieltanhx
Copy link

the model in point 1 and point 2 shown below is diff, i've compared their respective generated text.. it's really different.

1.just aft 4bit training->gen = pipeline('text-generation', model=model, tokenizer=tokenizer, max_length=max_length)

2.model = PeftModel.from_pretrained(base_model, new_model)
model = model.merge_and_unload()
gen = pipeline('text-generation', model=model, tokenizer=tokenizer, max_length=max_length)

@danieltanhx
Copy link
Author

danieltanhx commented Sep 1, 2023

found the bug "PLS remove model = model.merge_and_unload() and reuse the original 4bit base model instead of the fp16 base model". Details is in artidoro/qlora#254

compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
bnb_config = BitsAndBytesConfig(
load_in_4bit=use_4bit,
bnb_4bit_quant_type=bnb_4bit_quant_type,
bnb_4bit_compute_dtype=compute_dtype,
bnb_4bit_use_double_quant=use_nested_quant,
)
base_model = AutoModelForCausalLM.from_pretrained(
model_name,
quantization_config=bnb_config,
device_map=device_map
)
base_model.config.use_cache = False
base_model.config.pretraining_tp = 1
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = "right"
model = PeftModel.from_pretrained(base_model, new_model)
#model = model.merge_and_unload() MUST remove due to artidoro/qlora#254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant