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

How to save the quanted model #50

Open
cquxl opened this issue Nov 8, 2024 · 2 comments
Open

How to save the quanted model #50

cquxl opened this issue Nov 8, 2024 · 2 comments

Comments

@cquxl
Copy link

cquxl commented Nov 8, 2024

There are some same problems when saving quanted model , coding is here:
if args.save_model:
model.save_pretrained(args.save_model)
tokenizer.save_pretrained(args.save_model)
Could you please provide the right method to save the quanted model?

@sashkboos
Copy link
Collaborator

Thanks @cquxl for your issue.

what is the problem with that? What is the error you get while saving the model?

@cquxl
Copy link
Author

cquxl commented Nov 9, 2024

Thanks for your reply.

  1. After saving model using the above code, it occurs some problems like "ValueError: You are trying to save a non contiguous tensor".
  2. Then, I correct it by using the following code " if args.save_model:
    for name, param in model.named_parameters():
    if not param.is_contiguous():
    param.data = param.data.contiguous()
    model.save_pretrained(args.save_model)
    tokenizer.save_pretrained(args.save_model)", which can save the model. However, if I use "transformers.
    AutoModelForCausalLM.from_pretrained("saved model ")" to load the model, it occurs another problem:"ValueError: Trying to set a tensor of shape torch.Size([1]) in "weight" (which has shape torch.Size([8192])), this looks incorrect.".
    Could you please tell me how to save the quanted model like OmniQuant, and then use the quanted model for evaluation by lm_eval.

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