Skip to content

Comments

migrate to transformers v5#12976

Merged
sayakpaul merged 80 commits intomainfrom
transformers-v5-pr
Feb 24, 2026
Merged

migrate to transformers v5#12976
sayakpaul merged 80 commits intomainfrom
transformers-v5-pr

Conversation

@sayakpaul
Copy link
Member

@sayakpaul sayakpaul commented Jan 14, 2026

What does this PR do?

Migrate to transformers v5 and perform the changes necessary to facilitate that.

Bunch of inline comments to make the reviewers aware of internal discussions.

@sayakpaul sayakpaul requested a review from DN6 January 14, 2026 09:23
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@sayakpaul sayakpaul marked this pull request as draft January 15, 2026 12:05
@sayakpaul sayakpaul changed the title switch to transformers main again. [main] switch to transformers main again. Jan 15, 2026
@sayakpaul sayakpaul changed the title [main] switch to transformers main again. [wip] switch to transformers main again. Jan 15, 2026
logger.addHandler(stream_handler)


@unittest.skipIf(is_transformers_version(">=", "4.57.5"), "Size mismatch")
Copy link
Member Author

Choose a reason for hiding this comment

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

torch.nn.ConvTranspose2d,
torch.nn.ConvTranspose3d,
torch.nn.Linear,
torch.nn.Embedding,
Copy link
Member Author

Choose a reason for hiding this comment

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

Happening because of the way weight loading is done in v5.

Comment on lines +23 to +25
model = AutoModel.from_pretrained(
"hf-internal-testing/tiny-stable-diffusion-torch", subfolder="text_encoder", use_safetensors=False
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +281 to +283
input_ids = (
input_ids["input_ids"] if not isinstance(input_ids, list) and "input_ids" in input_ids else input_ids
)
Copy link
Member Author

Choose a reason for hiding this comment

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

inputs = {
"prompt": "dance monkey",
"negative_prompt": "",
"negative_prompt": "bad",
Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise, the corresponding tokenizer outputs:

negative_prompt=[' ']
prompt=[' ']
text_input_ids=tensor([], size=(1, 0), dtype=torch.int64)

which leads to:

E       RuntimeError: cannot reshape tensor of 0 elements into shape [1, 0, -1, 8] because the unspecified dimension size -1 can be any value and is ambiguous

@sayakpaul
Copy link
Member Author

sayakpaul commented Jan 20, 2026

Hmm, https://github.com/huggingface/diffusers/actions/runs/21354964855/job/61460242386?pr=12976 fails on this PR but passes without any regrets on this https://github.com/huggingface/diffusers/actions/runs/21344761402/job/61450173169?pr=12996. So, I am not sure at this point what's happening TBH. Other failures seem to be already existing and well-known.

@sayakpaul sayakpaul marked this pull request as ready for review February 20, 2026 05:19
@sayakpaul sayakpaul changed the title [wip] migrate to transformers v5 migrate to transformers v5 Feb 20, 2026
@sayakpaul
Copy link
Member Author

Merging.

@sayakpaul sayakpaul merged commit 5e94d62 into main Feb 24, 2026
31 of 33 checks passed
@sayakpaul sayakpaul deleted the transformers-v5-pr branch February 24, 2026 05:24
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.

3 participants