Use torch in get_3d_rotary_pos_embed/_allegro#10161
Use torch in get_3d_rotary_pos_embed/_allegro#10161yiyixuxu merged 1 commit intohuggingface:mainfrom
torch in get_3d_rotary_pos_embed/_allegro#10161Conversation
|
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. |
|
hi @hlky |
a-r-r-o-w
left a comment
There was a problem hiding this comment.
The changes look good to me, but probably need to be mindful if this will affect downstream repositories that rely on these functions. There are atleast two that come to mind immediately:
- https://github.com/kijai/ComfyUI-CogVideoXWrapper/blob/795f8b05659dfa5ec6b216fb698bcca6fda34fdb/pipeline_cogvideox.py#L286
- https://github.com/a-r-r-o-w/cogvideox-factory/blob/80d1150a0e233a1b2b98dd0367c06276989d049c/training/utils.py#L217
There are probably a lot more usages. I think it is a safe change since the repositories that already rely on these methods are doing the device casting after the tensors are returned. Should be okay to merge if slow tests pass IMO!
|
Downstream usage of get_3d_rotary_pos_embed - looks like these handle device casting so should be ok. Will update after slow tests are run. |
|
Cogvideo slow test - passes except 1 OOM, unrelated, same OOM here |
What does this PR do?
Refactors get_3d_rotary_pos_embed and get_3d_rotary_pos_embed_allegro to use torch instead of numpy, and adds device argument so that tensors can be created on e.g. cuda.
Usage of get_3d_rotary_pos_embed and get_3d_rotary_pos_embed_allegro is updated to pass device where applicable (we don't specify device during initialization so we don't pass device to the function when used from init, the device from weights would just be cpu)
torch and numpy versions match numerically.
Reproduction get_3d_rotary_pos_embed
Reproduction get_3d_rotary_pos_embed_allegro
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.