Eliminate GPU sync overhead and CPU→GPU transfers across LTX2 pipeline#13564
Open
ViktoriiaRomanova wants to merge 1 commit intohuggingface:mainfrom
Open
Eliminate GPU sync overhead and CPU→GPU transfers across LTX2 pipeline#13564ViktoriiaRomanova wants to merge 1 commit intohuggingface:mainfrom
ViktoriiaRomanova wants to merge 1 commit intohuggingface:mainfrom
Conversation
…or creation across the LTX2 pipeline, transformer, scheduler, and connector logic. - Add set_begin_index(0) to schedulers to eliminate DtoH sync in _init_step_index - Replace torch.tensor(..., device=...) with on-device tensor construction for decode scaling - Move RoPE-related tensor creation to GPU to avoid memcpy overhead - Refactor connector padding logic using vectorized masking instead of list-based ops
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.
Fixes performance issues identified by profiling LTX2 with torch.profiler as part of #13401.
Optimises LTX2 by removing unnecessary GPU synchronisation points and replacing CPU tensor creation with on-device tensor operations across the decoding pipeline, transformer RoPE computations, scheduler, and connector padding logic.
Pipeline Denoising Optimisation
Before (eager mode):
Before (compile mode):


After (compile mode, no sync gap):
Transformer Model Optimisation
Replaced CPU tensor creation for patch sizes with on-device tensor construction.
Eliminates unnecessary CPU-to-GPU memcpy operations during RoPE coordinate preparation.
Connector Refactoring
Replaced list-comprehension-based padding logic with vectorised masking. This simplifies left-padding layout logic and eliminates unnecessary cudaStreamSynchronize calls.
Performance Results
Profiler trace
https://drive.google.com/drive/folders/1cZn1xw-8Eon22mA2zP1uoF1nE4YCC3Wo?usp=drive_link
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul @dg845