[Text-to-video] Add torch.compile()
compatibility
#3949
Merged
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 #3915
Description
torch.compile()
for therepeat_interleave()
function was added in a nightly build. See: pytorch/pytorch#99929.So, once I upgraded to Torch 2.1 nightly, the issue went away. However, there were other issues which are fixed in this PR. The PR takes inspiration from #3313.
Even though we're able to successfully compile the model, it takes a hefty amount of time after
torch.compile()
is called on the UNet:The first call
pipe
is really time-consuming which is understandable because that is when the compiled UNet model is also used for the first time. But even in the subsequent calls, the timing doesn't seem to improve much. In my experiments, I actually found the runtime to be performing much better withouttorch.compile()
.Let me know if anything is unclear.
I leaving the outputs of the progress bars:
With
torch.compile()
Without
torch.compile()
My explorations can be found in this Colab Notebook.