Workaround for Transformers 4.49.0 component loading dtype issue #1815
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 does this PR do?
Fixes issue with Transformers 4.49.0 not loading assigned
dtype
in some diffusers componentsTransformers release 4.49.0 has an issue that it fails to properly load assigned component dtype for some components.
This bug was created here:
https://github.com/huggingface/transformers/blob/v4.49.0/src/transformers/modeling_utils.py#L1461
Which changed from older transformers:
https://github.com/huggingface/transformers/blob/v4.46.3/src/transformers/modeling_utils.py#L1508
This bug has been fixed since in 4.50.0dev here:
huggingface/transformers#36335
@regisss If we will still update Optimum-Habana transformers to release 4.49.0, then we need also fix from this PR which enforces assigned
dtype
in afrom_pretrained
wrapper for diffusers pipelinesFix Test
Easiest to test is to check text_encoder
dtype
which sometimes fails to get assigneddtype
:Before fix
Note incorrect types (FP16) for SDXL 2nd text encoder, SD3 1st and 2nd text encoder, and mlperf SDXL 2nd text encoder.
After fix
All types are BF16 as expected