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

trainer save_model ValueError You are trying to save a non contiguous tensor #1582

Open
smilieSushmitha opened this issue Nov 9, 2024 · 2 comments

Comments

@smilieSushmitha
Copy link

Describe the bug
Fine-tuning mt5 model, and trying to save the fine-tuned model is throwing a ValueError: You are trying to save a non contiguous tensor:

To Reproduce
Attaching a notebook to reproduce the issue: Colab

Expected behavior
Model.train() should train the model and should save the model to the output directory

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot 2024-11-08 131354

Desktop (please complete the following information):
Run on google Colab
Select:

  1. Runtime type: Python 3
  2. Hardware accelerator: T4

image

Cause of Error:
In the Hugging Face transformers repository, the PR #27064 - "Safetensors serialization by default" updates the save_pretrained() method in transformers/src/transformers/modeling_utils.py to set the safe_serialization argument to True by default. However, the simpletransformers library's model.train_model() function does not currently offer a way to pass a different value for safe_serialization to the save_pretrained() method, which limits control over this setting when saving models.

Please help me with a workaround to this issue

@PaulTran47
Copy link

Thanks for bringing this issue up. Correct me if I'm wrong, but reading your issue sounds familiar to an issue I came across with model.train several months ago when using the latest version of transformers.

Since that time until now, the "workaround" I've been using is downgrading transformers to 4.42.4. Your explanation of the error added a lot of clarity, but I don't know if what I've been doing is satisfactory for the time being.

@smilieSushmitha
Copy link
Author

Thanks a lot for the work around!
It Worked 👍

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