Update get_2d_sincos_pos_embed to use output_type='pt' for Diffusers compat#504
Merged
feifeibear merged 2 commits intoxdit-project:mainfrom Apr 23, 2025
Conversation
feifeibear
reviewed
Apr 21, 2025
| grid_size=(height, width), | ||
| base_size=self.module.base_size, | ||
| interpolation_scale=self.module.interpolation_scale, | ||
| device=latent.device, # Place tensor on the correct device directly |
Collaborator
There was a problem hiding this comment.
Does this change work with lower versions of diffusers, such as 0.32.0? If it's only compatible with 0.33.0, we could implement an if-else statement with a diffuser version check as the condition."
Contributor
Author
There was a problem hiding this comment.
Ooops, ignore the vanishing comments.
Good catch! I was in a bit of a hurry and didn't check when the arguments were added, haha. I confirmed it was 0.33.0, so I've updated it to use the simplified code conditionally.
Appreciate you pointing that out! Let me know if anything else is needed! Cheers!
feifeibear
approved these changes
Apr 23, 2025
fielding
added a commit
to fielding/xDiT
that referenced
this pull request
May 13, 2025
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.
Description
This PR addresses a deprecation warning in Diffusers 0.33.0 related to the
output_typeparameter inget_2d_sincos_pos_embed. The function now recommends usingoutput_type='pt'to return a PyTorch tensor directly, which is more efficient and avoids unnecessary conversions from NumPy.Changes
get_2d_sincos_pos_embedinxfuser/model_executor/layers/embeddings.pyto useoutput_type='pt'.deviceparameter to ensure the tensor is placed directly on the correct device, removing the need for manual device transfer.torch.from_numpyconversion and.to(latent.device)call, as they are no longer required these changes.Benefits
Testing
Cheers