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

peft==0.6.1 implicitly requires transformers>=4.30.0, but transformers version is not specified #1114

Closed
1 of 4 tasks
minotru opened this issue Nov 10, 2023 · 4 comments · Fixed by #1116
Closed
1 of 4 tasks

Comments

@minotru
Copy link

minotru commented Nov 10, 2023

System Info

Hi peft community,

We use peft in our project and yesterday tests started to fail in our CI with an error like:

/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/peft/peft_model.py:35: in <module>
    from transformers.pytorch_utils import id_tensor_storage
E   ImportError: cannot import name 'id_tensor_storage' from 'transformers.pytorch_utils' (/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/transformers/pytorch_utils.py)

Line from transformers.pytorch_utils import id_tensor_storage was added in peft==0.6.1 as a part of this PR by @younesbelkada: https://github.com/huggingface/peft/pull/1101/files#diff-95787fcc5356568929e383449ade2c1bac5da43deccab17318652b62ed171ae7R35

Function id_tensor_storage was added to transformers in version 4.30.0: huggingface/transformers@d68d666

So, it is required to have at least transformers==4.30.0 to use peft==0.6.1..

At the same time, peft does not set any version limits for transformers package: https://github.com/huggingface/peft/blob/main/setup.py#L46C10-L46C22

In my project's requirements.txt, we have a pinned version transformers==4.28.1. Because peft does not specify transformers version, pip is fine to install peft==0.6.1 and transformers==4.28.1, although it raises an ImportError in runtime later.

Possible solution: explicitly set transformers>=0.6.1 in setup.py.

Who can help?

@younesbelkada

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder
  • My own task or dataset (give details below)

Reproduction

conda create -n peft-reproduce python=3.10
conda activaate peft-reproduce
pip install transformers==4.28.1 peft==0.6.1
python
>>> import peft
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/anaconda3/envs/peft-reproduce/lib/python3.10/site-packages/peft/__init__.py", line 22, in <module>
    from .auto import (
  File "/opt/homebrew/anaconda3/envs/peft-reproduce/lib/python3.10/site-packages/peft/auto.py", line 31, in <module>
    from .mapping import MODEL_TYPE_TO_PEFT_MODEL_MAPPING
  File "/opt/homebrew/anaconda3/envs/peft-reproduce/lib/python3.10/site-packages/peft/mapping.py", line 23, in <module>
    from .peft_model import (
  File "/opt/homebrew/anaconda3/envs/peft-reproduce/lib/python3.10/site-packages/peft/peft_model.py", line 35, in <module>
    from transformers.pytorch_utils import id_tensor_storage
ImportError: cannot import name 'id_tensor_storage' from 'transformers.pytorch_utils' (/opt/homebrew/anaconda3/envs/peft-reproduce/lib/python3.10/site-packages/transformers/pytorch_utils.py)

### Expected behavior

`pip install` should fail if `transformers<4.30.0`
@younesbelkada
Copy link
Contributor

Thanks very much @minotru for reporting ! should be fixed by #1116

@younesbelkada
Copy link
Contributor

We'll also do a patch release soon

@minotru
Copy link
Author

minotru commented Nov 11, 2023

Hi @younesbelkada, thanks for such a fast fix!

Yet, I have a general question: why don't we specify a version range for transformers in setup.py?

Because the case with id_tensor_storage is just a one of many possible errors, when dependencies versions are not specified.

@BenjaminBossan
Copy link
Member

PEFT will typically be installed in conjunction with many other libraries, each with their own dependencies. If those are too restrictive when it comes to versions, it will be impossible to resolve the environment. Therefore, we strive to put as few limitations as possible on the requirements. If you are aware of anything else breaking with older transformers versions, please let us know.

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 a pull request may close this issue.

3 participants