Repository navigation
Conversation
_get_t5_prompt_embeds sliced untruncated ids from tokenizer_max_length - 1 (the CLIP limit) instead of max_sequence_length, so the truncation warning for the T5 prompt decoded an empty string instead of the discarded suffix whenever max_sequence_length was smaller than the CLIP limit. Slice from max_sequence_length - 1 in the Flux and SD3 source methods and sync all '# Copied from' copies. Add regression tests asserting the warning contains the actual discarded T5 text (they fail before this change). Fixes huggingface#15495
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
_get_t5_prompt_embedsdecodes the discarded prompt suffix fromself.tokenizer_max_length - 1(the CLIP limit) instead ofmax_sequence_length. Whenmax_sequence_lengthis below the CLIP limit (for example 8), the slice is empty, so the truncation warning reports['']instead of the actually discarded T5 tokens.Reproduced on current main with the issue's tiny-flux-pipe example: the warning printed
[''], while the T5 tokenizer decodes the discarded suffix aso three four five six seven eight nine ten.Change
untruncated_ids[:, max_sequence_length - 1 : -1]in the two source methods (FluxPipeline._get_t5_prompt_embeds,StableDiffusion3Pipeline._get_t5_prompt_embeds), mirroring how the CLIP path usesself.tokenizer_max_length - 1.# Copied fromcopies withpython utils/check_copies.py --fix_and_overwrite(18 files, one line each).Tests
ruff formatandruff checkclean.Fixes #15495
Prepared with AI assistance; every test above was executed locally on CPU (PyTorch 2.14.1+cpu, transformers 5.20.2).