-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use torch
in get_2d_rotary_pos_embed
#10155
base: main
Are you sure you want to change the base?
Conversation
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. |
Downstream usage - should be ok, this was already returning |
did we run hunyuan test? |
Checkpoint used in the slow test is 404
|
just run its docstring example manually would be fine for now |
There a slight change to the image. import torch
from diffusers import HunyuanDiTPipeline
pipe = HunyuanDiTPipeline.from_pretrained(
"Tencent-Hunyuan/HunyuanDiT-Diffusers", torch_dtype=torch.float16
)
pipe.to("cuda")
prompt = "An astronaut riding a horse"
image = pipe(prompt, generator=torch.Generator("cuda").manual_seed(0)).images[0] |
Unclear why though, I'll run the test again. Edit: I haven't ran the reproduction on CUDA, might account for the difference. >>> torch.abs(image_rotary_emb[0].flatten() - image_rotary_emb_np[0].flatten()).max()
tensor(0.)
>>> torch.abs(image_rotary_emb[1].flatten() - image_rotary_emb_np[1].flatten()).max()
tensor(0.) |
Yes there's a very minor difference when we create the tensors on CUDA.
It's below PyTorch's tolerance for float32 though https://pytorch.org/docs/stable/testing.html cc @yiyixuxu |
af5ecd9
to
f2e7731
Compare
I've added |
What does this PR do?
Refactors
get_2d_rotary_pos_embed
to usetorch
instead ofnumpy
, and addsdevice
argument so that tensors can be created on e.g.cuda
.Usage of
get_2d_rotary_pos_embed
in HunyuanDiT pipelines is updated to passdevice
.torch
andnumpy
versions match numerically.Reproduction
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@sayakpaul @yiyixuxu