LTX2: Refactor forward function for better VRAM efficiency and fix spatial inpainting#12046
Merged
comfyanonymous merged 3 commits intoComfy-Org:masterfrom Jan 23, 2026
Merged
LTX2: Refactor forward function for better VRAM efficiency and fix spatial inpainting#12046comfyanonymous merged 3 commits intoComfy-Org:masterfrom
comfyanonymous merged 3 commits intoComfy-Org:masterfrom
Conversation
Spatial inpainting not compatible with the compression
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.
There are a lot of intermediate tensors that can be freed before the heavier operations like feedforward activation and video attention, I've been testing this through custom patch node for few days now without any issues.
I'm aware FFN could additionally be chunked, but it doesn't seem possible to do without affecting the model output in every situation, especially when something like fp8 matmuls are used. So that remains optional memory saving through custom nodes.
Before and after at 1024x1024 x 497:
Output remains unchanged, and speed difference is within margin of error, tested in Windows on 4090:
Also realized that my previous memory optimization broke spatial inpainting, so I added bit of code to detect if spatial mask is used and in that case just revert to the old behavior, which is of course going to negate memory savings. However that's bit of an edge case as overall functionality of spatial masking remains questionable, and mostly the model is used with only temporal masks.