Skip to content

Commit cbdb637

Browse files
authored
Fix model offloading and training tests + prevent examples timeout (#14091)
Fix AutoencoderVidTok output format and skip training tests on unsupported hardware
1 parent 72eb60c commit cbdb637

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/diffusers/models/autoencoders/autoencoder_vidtok.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,5 +1502,5 @@ def forward(
15021502
dec = dec[:, :, :-time_padding, :, :]
15031503

15041504
if not return_dict:
1505-
return dec
1505+
return (dec,)
15061506
return DecoderOutput(sample=dec)

tests/models/autoencoders/test_models_autoencoder_vidtok.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
import pytest
1716
import torch
1817

1918
from diffusers import AutoencoderVidTok
@@ -80,7 +79,6 @@ def get_dummy_inputs(self) -> dict:
8079

8180

8281
class TestAutoencoderVidTok(AutoencoderVidTokTesterConfig, ModelTesterMixin):
83-
@pytest.mark.skip("VidTok output structure not compatible with recursive output check.")
8482
def test_outputs_equivalence(self):
8583
super().test_outputs_equivalence()
8684

tests/models/testing_utils/training.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,14 @@ def test_mixed_precision_training(self):
210210

211211
# Test with bfloat16
212212
if torch.device(torch_device).type != "cpu":
213-
model.zero_grad()
214-
with torch.amp.autocast(device_type=torch.device(torch_device).type, dtype=torch.bfloat16):
215-
output = model(**inputs_dict, return_dict=False)[0]
213+
if torch.device(torch_device).type == "cuda" and not torch.cuda.is_bf16_supported():
214+
pytest.skip("bfloat16 training is not supported on this GPU.")
215+
else:
216+
model.zero_grad()
217+
with torch.amp.autocast(device_type=torch.device(torch_device).type, dtype=torch.bfloat16):
218+
output = model(**inputs_dict, return_dict=False)[0]
216219

217-
noise = torch.randn((output.shape[0],) + self.output_shape).to(torch_device)
218-
loss = torch.nn.functional.mse_loss(output, noise)
220+
noise = torch.randn((output.shape[0],) + self.output_shape).to(torch_device)
221+
loss = torch.nn.functional.mse_loss(output, noise)
219222

220-
loss.backward()
223+
loss.backward()

0 commit comments

Comments
 (0)