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

[gptj] support older pytorch version #22325

Merged
merged 5 commits into from
Mar 23, 2023
Merged

[gptj] support older pytorch version #22325

merged 5 commits into from
Mar 23, 2023

Conversation

stas00
Copy link
Contributor

@stas00 stas00 commented Mar 23, 2023

Unbreak 2 issues introduced by #22069 . I validated that this version works even with pt-1.9, which is the new lowest version supported by transformers since #22291

Fixes:

E             File "/mnt/nvme0/code/huggingface/transformers-master/examples/pytorch/language-modeling/run_clm.py", line 412, in main
E               model = AutoModelForCausalLM.from_pretrained(
E             File "/mnt/nvme0/code/huggingface/transformers-master/src/transformers/models/auto/auto_factory.py", line 470, in from_pretrained
E               model_class = _get_model_class(config, cls._model_mapping)
E             File "/mnt/nvme0/code/huggingface/transformers-master/src/transformers/models/auto/auto_factory.py", line 360, in _get_model_class
E               supported_models = model_mapping[type(config)]
E             File "/mnt/nvme0/code/huggingface/transformers-master/src/transformers/models/auto/auto_factory.py", line 602, in __getitem__
E               return self._load_attr_from_module(model_type, model_name)
E             File "/mnt/nvme0/code/huggingface/transformers-master/src/transformers/models/auto/auto_factory.py", line 616, in _load_attr_from_module
E               return getattribute_from_module(self._modules[module_name], attr)
E             File "/mnt/nvme0/code/huggingface/transformers-master/src/transformers/models/auto/auto_factory.py", line 561, in getattribute_from_module
E               if hasattr(module, attr):
E             File "/mnt/nvme0/code/huggingface/transformers-master/src/transformers/utils/import_utils.py", line 1109, in __getattr__
E               module = self._get_module(self._class_to_module[name])
E             File "/mnt/nvme0/code/huggingface/transformers-master/src/transformers/utils/import_utils.py", line 1121, in _get_module
E               raise RuntimeError(
E           RuntimeError: Failed to import transformers.models.gptj.modeling_gptj because of the following error (look up to see its traceback):
E           module 'torch' has no attribute 'fx'

credits for the fix: @mrwyattii

and:

E             File "/mnt/nvme0/code/huggingface/transformers-master/src/transformers/models/gptj/modeling_gptj.py", line 61, in create_sinusoidal_positions
E               return torch.concat((torch.sin(sinusoid_inp), torch.cos(sinusoid_inp)), dim=1)
E           AttributeError: module 'torch' has no attribute 'concat'

credits for the fix: @njhill

@stas00 stas00 marked this pull request as ready for review March 23, 2023 00:29
@stas00 stas00 requested a review from sgugger March 23, 2023 00:29
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 23, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

src/transformers/models/gptj/modeling_gptj.py Show resolved Hide resolved
@stas00 stas00 merged commit 61f79b2 into main Mar 23, 2023
@stas00 stas00 deleted the gptj-older-pytorch-support branch March 23, 2023 01:35
@stas00
Copy link
Contributor Author

stas00 commented Mar 23, 2023

Thank you for the quick review, Sylvain.

@njhill
Copy link
Contributor

njhill commented Mar 23, 2023

Thank you @stas00 @sgugger and sorry again for the breakage.

@stas00
Copy link
Contributor Author

stas00 commented Mar 23, 2023

You haven't done anything wrong, Nick. It's just very difficult to instantly test all the different variations. We have more indepth multi-version CI running on a daily basis, so usually any missed problems get detected on the next day.

And thank you for your contribution!

raghavanone pushed a commit to raghavanone/transformers that referenced this pull request Apr 5, 2023
* [gptj] support older pytorch version

* contributor

* contributor

* make copies

---------

Co-authored-by: Michael Wyatt <michaelwyatt@microsoft.com>
Co-authored-by: Nick Hill <nickhill@us.ibm.com>
novice03 pushed a commit to novice03/transformers that referenced this pull request Jun 23, 2023
* [gptj] support older pytorch version

* contributor

* contributor

* make copies

---------

Co-authored-by: Michael Wyatt <michaelwyatt@microsoft.com>
Co-authored-by: Nick Hill <nickhill@us.ibm.com>
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

Successfully merging this pull request may close these issues.

None yet

5 participants