Skip to content

Fix LTXVAudioVideoMask negative mask padding - #654

Open
Booyaka101 wants to merge 1 commit into
kijai:mainfrom
Booyaka101:fix/ltxv-audiovideomask-negative-mask-pad
Open

Fix LTXVAudioVideoMask negative mask padding#654
Booyaka101 wants to merge 1 commit into
kijai:mainfrom
Booyaka101:fix/ltxv-audiovideomask-negative-mask-pad

Conversation

@Booyaka101

Copy link
Copy Markdown

Fixes #615.

LTXVAudioVideoMask crashes with Trying to create tensor with negative dimension when an existing noise_mask has more frames than the padded samples.

In the existing-mask pad branch the guard checks that the samples grew (samples.shape[2] > original_samples.shape[2]), but the padding amount is samples.shape[2] - mask.shape[2]. When the incoming noise_mask already has more frames than the padded samples, that subtraction is negative and torch.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 - mask and pad only when it is positive, otherwise trim the mask to the sample length (matching the existing truncate behaviour). Applied to both branches.

Verified with a CPU repro of the exact shape arithmetic (samples padded to fewer frames than the existing mask):

before: RuntimeError: zeros: Dimension size must be non-negative
after:  samples=(1, 128, 6, 640) mask=(1, 1, 6, 640)  (mask frames == samples frames)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trying to create tensor with negative dimension -32: [1, 1, -32, 640]

1 participant