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

RuntimeError: self and mat2 must have the same dtype #43

Closed
baibaiw5 opened this issue May 26, 2023 · 4 comments
Closed

RuntimeError: self and mat2 must have the same dtype #43

baibaiw5 opened this issue May 26, 2023 · 4 comments

Comments

@baibaiw5
Copy link

---------pip package version
transformers-4.30.0.dev0
accelerate 0.20.0.dev0
bitsandbytes 0.39.0
peft-0.3.0.dev0

----------python cmd
python qlora.py --model_name_or_path /home/bmb/models/facebook/opt-125m

---------error
Traceback (most recent call last):
File "/home/bmb/projects/qlora/qlora.py", line 766, in
train()
File "/home/bmb/projects/qlora/qlora.py", line 728, in train
train_result = trainer.train(resume_from_checkpoint=checkpoint_dir)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/transformers/trainer.py", line 1696, in train
return inner_training_loop(
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/transformers/trainer.py", line 1972, in _inner_training_loop
tr_loss_step = self.training_step(model, inputs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/transformers/trainer.py", line 2786, in training_step
loss = self.compute_loss(model, inputs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/transformers/trainer.py", line 2818, in compute_loss
outputs = model(**inputs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/peft/peft_model.py", line 678, in forward
return self.base_model(
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/transformers/models/opt/modeling_opt.py", line 945, in forward
outputs = self.model.decoder(
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/transformers/models/opt/modeling_opt.py", line 703, in forward
layer_outputs = torch.utils.checkpoint.checkpoint(
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/torch/utils/checkpoint.py", line 249, in checkpoint
return CheckpointFunction.apply(function, preserve, *args)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/torch/utils/checkpoint.py", line 107, in forward
outputs = run_function(*args)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/transformers/models/opt/modeling_opt.py", line 699, in custom_forward
return module(*inputs, output_attentions, None)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/transformers/models/opt/modeling_opt.py", line 331, in forward
hidden_states, self_attn_weights, present_key_value = self.self_attn(
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/accelerate/hooks.py", line 165, in new_forward
output = old_forward(*args, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/transformers/models/opt/modeling_opt.py", line 174, in forward
query_states = self.q_proj(hidden_states) * self.scaling
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "/home/bmb/anaconda3/envs/qlora/lib/python3.10/site-packages/peft/tuners/lora.py", line 565, in forward
result = F.linear(x, transpose(self.weight, self.fan_in_fan_out), bias=self.bias)
RuntimeError: self and mat2 must have the same dtype

@taishan1994
Copy link

pip install -q -U git+https://github.com/huggingface/peft.git
peft version should be 0.4.0.dev0

@baibaiw5
Copy link
Author

pip install -q -U git+https://github.com/huggingface/peft.git peft version should be 0.4.0.dev0

I used to install 0.4.0.dev0 and I meet the following problem: lora weights are not saved correctly
#41

@taishan1994
Copy link

pip install -q -U git+https://github.com/huggingface/peft.git peft version should be 0.4.0.dev0

I used to install 0.4.0.dev0 and I meet the following problem: lora weights are not saved correctly #41

maybe you can try this: #44

@baibaiw5
Copy link
Author

peft version should be 0.4.0.dev0

Thank you.Now the checkpoint can be saved correctly

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

2 participants