[bugfix] Fix STFT dtype mismatch - #1419
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the forward pass in ltx2_audio_vae.py to cast self.forward_basis to the data type of y before performing the 1D convolution. The reviewer suggested using self.forward_basis.to(y) instead of self.forward_basis.to(y.dtype) to ensure both the device and data type are matched, preventing potential device mismatch errors.
| left_pad = max(0, self.win_length - self.hop_length) | ||
| y = F.pad(y, (left_pad, 0)) | ||
| spec = F.conv1d(y, self.forward_basis, stride=self.hop_length, padding=0) | ||
| spec = F.conv1d(y, self.forward_basis.to(y.dtype), stride=self.hop_length, padding=0) |
There was a problem hiding this comment.
Using self.forward_basis.to(y) is more robust than self.forward_basis.to(y.dtype) because it automatically matches both the device and the data type of y. This prevents potential runtime errors due to device mismatches if y and self.forward_basis happen to be on different devices.
| spec = F.conv1d(y, self.forward_basis.to(y.dtype), stride=self.hop_length, padding=0) | |
| spec = F.conv1d(y, self.forward_basis.to(y), stride=self.hop_length, padding=0) |
|
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 PR merge requirementsWaiting for
This rule is failing.
|
Pre-commit checks failedHi @kevin314, the pre-commit checks have failed. To fix them locally: # Install pre-commit if you haven't already
uv pip install pre-commit
pre-commit install
# Run all checks and auto-fix what's possible
pre-commit run --all-filesCommon fixes:
After fixing, commit and push the changes. The checks will re-run automatically. For future commits, |
|
/merge |
Changes
Test Plan
# Commands you ranTest Results
Test output
Checklist
pre-commit run --all-filesand fixed all issuesFor model/pipeline changes, also check: