Fix LTXVAudioVideoMask negative mask padding - #654
Open
Booyaka101 wants to merge 1 commit into
Open
Conversation
When an existing noise_mask has more frames than the padded samples, the mask-pad branch computed torch.zeros with a negative frame count (samples.shape[2] - mask.shape[2] < 0), raising 'Trying to create tensor with negative dimension'. Guard the pad amount: pad only when positive, otherwise trim the mask to the sample length. Applied to both the video (5D) and audio (4D) branches. Fixes kijai#615
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 #615.
LTXVAudioVideoMaskcrashes withTrying to create tensor with negative dimensionwhen an existingnoise_maskhas more frames than the padded samples.In the existing-mask
padbranch the guard checks that the samples grew (samples.shape[2] > original_samples.shape[2]), but the padding amount issamples.shape[2] - mask.shape[2]. When the incomingnoise_maskalready has more frames than the padded samples, that subtraction is negative andtorch.zeros(..., negative, ...)raises. The reporter's[1, 1, -32, 640]is the audio branch (4D); the video branch (5D) has the same defect.Fix: compute
extra = samples - maskand pad only when it is positive, otherwise trim the mask to the sample length (matching the existingtruncatebehaviour). Applied to both branches.Verified with a CPU repro of the exact shape arithmetic (samples padded to fewer frames than the existing mask):