Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 7.3k
migrate to transformers v5#12976
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
Uh oh!
There was an error while loading. Please reload this page.
migrate to transformers v5
#12976
Changes from all commits
039324ac152b18f8e50fac5e023fd0f279c96f0804ea90a7437cfcee926db24cec02097b55da83dcb97c084c9594ea43ee7f2cd5b62bf2b03513163387befd2fe9f98e1249d2c2d8273a21a6ac5274ffd515dd064dff3180eaa35f6e8e7bafefd0f4b4b707e7a0739c2bee621f9bdc09079e0e37eb51e9ea815e55fefef98568200c3249d710ef226e12d87ea3fc01c4455f14eac4988240299067fc00712205008f0786a104aa69ea27dd36c2e10aafafb249e9308598f5af2576e40a4425f61a5367cf743e58a44ba88d176bb1ba91ad9fe0792acb34420fa768ad19dd85c89c67ac4319da7ae89b1b8170f644ade26d0b1034ae76c45cbb37bff5825c9bc7b6e9aa1a698b34ea5b4fb7a744a58326ec4e576dbe6404dcFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -48,6 +48,7 @@ | ||
| torch.nn.ConvTranspose2d, | ||
| torch.nn.ConvTranspose3d, | ||
| torch.nn.Linear, | ||
| torch.nn.Embedding, | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happening because of the way weight loading is done in v5. | ||
| # TODO(aryan): look into torch.nn.LayerNorm, torch.nn.GroupNorm later, seems to be causing some issues with CogVideoX | ||
| # because of double invocation of the same norm layer in CogVideoXLayerNorm | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -287,6 +287,9 @@ def _get_prompt_embeds( | ||
| truncation=True, | ||
| padding="max_length", | ||
| ) | ||
| input_ids = ( | ||
| input_ids["input_ids"] if not isinstance(input_ids, list) and "input_ids" in input_ids else input_ids | ||
| ) | ||
Comment on lines
+290
to
+292
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Internal discussion https://huggingface.slack.com/archives/C014N4749J9/p1768537424692669 | ||
| input_ids = torch.LongTensor(input_ids) | ||
| input_ids_batch.append(input_ids) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -20,15 +20,19 @@ def test_load_from_config_diffusers_with_subfolder(self, mock_load_config): | ||
| side_effect=[EnvironmentError("File not found"), {"model_type": "clip_text_model"}], | ||
| ) | ||
| def test_load_from_config_transformers_with_subfolder(self, mock_load_config): | ||
| model = AutoModel.from_pretrained("hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder") | ||
| model = AutoModel.from_pretrained( | ||
| "hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder", use_safetensors=False | ||
| ) | ||
Comment on lines
+23
to
+25
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Internal discussion: https://huggingface.slack.com/archives/C014N4749J9/p1768462040821759 | ||
| assert isinstance(model, CLIPTextModel) | ||
| def test_load_from_config_without_subfolder(self): | ||
| model = AutoModel.from_pretrained("hf-internal-testing/tiny-random-longformer") | ||
| assert isinstance(model, LongformerModel) | ||
| def test_load_from_model_index(self): | ||
| model = AutoModel.from_pretrained("hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder") | ||
| model = AutoModel.from_pretrained( | ||
| "hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder", use_safetensors=False | ||
| ) | ||
| assert isinstance(model, CLIPTextModel) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -19,7 +19,7 @@ | ||
| import numpy as np | ||
| import torch | ||
| from huggingface_hub import hf_hub_download | ||
| from transformers import T5EncoderModel, T5TokenizerFast | ||
| from transformers import AutoConfig, T5EncoderModel, T5TokenizerFast | ||
| from diffusers import ( | ||
| AutoencoderKL, | ||
| @@ -89,7 +89,8 @@ def get_dummy_components(self): | ||
| scheduler = FlowMatchEulerDiscreteScheduler() | ||
| torch.manual_seed(0) | ||
| text_encoder = T5EncoderModel.from_pretrained("hf-internal-testing/tiny-random-t5") | ||
| config = AutoConfig.from_pretrained("hf-internal-testing/tiny-random-t5") | ||
| text_encoder = T5EncoderModel(config) | ||
Comment on lines
+92
to
+93
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. | ||
| tokenizer = T5TokenizerFast.from_pretrained("hf-internal-testing/tiny-random-t5") | ||
| components = { | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal discussion: https://huggingface.slack.com/archives/C014N4749J9/p1768474502541349