Skip to content

Conversation

@DavidBert
Copy link
Contributor

What does this PR do?

Fixes #12653
(changing for Rope dtype for float32 does not degrade quality)

Who can review?

@sayakpaul

def rope(self, pos: torch.Tensor, dim: int, theta: int) -> torch.Tensor:
assert dim % 2 == 0
scale = torch.arange(0, dim, 2, dtype=torch.float64, device=pos.device) / dim
scale = torch.arange(0, dim, 2, dtype=torch.float32, device=pos.device) / dim
Copy link
Member

Choose a reason for hiding this comment

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

Does it not affect any quality?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Images are not exactly identical but I think it is OK.
Left: float32, right: float64

image image image image image image

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, just to be a bit more future-proof, WDYT the change from https://github.com/huggingface/diffusers/pull/11316/files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I changed for what was suggested.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

Thanks!

@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
Copy link
Member

Failing tests are unrelated. Thanks for the quick fix!

@sayakpaul sayakpaul merged commit 01a5692 into huggingface:main Nov 15, 2025
7 of 11 checks passed
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.

PRX transformers version of rope has a float64 reference, breaks MPS (and npu ?)

3 participants