diffusers
[tests] refactor vae tests
#9808
Merged

[tests] refactor vae tests #9808

sayakpaul merged 24 commits into main from vae-tests
sayakpaul
sayakpaul327 days ago (edited 327 days ago)

What does this PR do?

Internal thread: https://huggingface.slack.com/archives/C065E480NN9/p1730203711189419.

Tears apart test_models_vae.py to break the tests in accordance with the Autoencoder model classes we have under src/diffusers/models/autoencoders.

Didn't include Allegro as it's undergoing some refactoring love from Aryan. Discussed internally.

Some comments inline.

sayakpaul add: autoencoderkl tests
8c3e8712
sayakpaul autoencodertiny.
8c5c5432
sayakpaul fix
409caefb
HuggingFaceDocBuilderDev
HuggingFaceDocBuilderDev327 days ago

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

sayakpaul asymmetric autoencoder.
6178385c
sayakpaul more
a9de100b
sayakpaul integration tests for stable audio decoder.
4b5b4b03
sayakpaul consistency decoder vae tests
97bab4c6
sayakpaul remove grad check from consistency decoder.
9819f8a2
sayakpaul cog
11ed2fd2
sayakpaul
sayakpaul commented on 2024-10-30
src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py
14681468 else:
14691469 z = posterior.mode()
1470 dec = self.decode(z)
1470
dec = self.decode(z).sample
sayakpaul327 days ago

Otherwise we return a tuple of DecoderOutput when return_dict=False.

sayakpaul
sayakpaul commented on 2024-10-30
src/diffusers/models/autoencoders/autoencoder_kl_temporal_decoder.py
sayakpaul327 days ago

Unused.

sayakpaul
sayakpaul commented on 2024-10-30
src/diffusers/models/autoencoders/autoencoder_tiny.py
310310 self, x: torch.Tensor, generator: Optional[torch.Generator] = None, return_dict: bool = True
311311 ) -> Union[DecoderOutput, Tuple[torch.Tensor]]:
312312 if self.use_slicing and x.shape[0] > 1:
313
output = [self._tiled_decode(x_slice) if self.use_tiling else self.decoder(x) for x_slice in x.split(1)]
313
output = [
314
self._tiled_decode(x_slice) if self.use_tiling else self.decoder(x_slice) for x_slice in x.split(1)
315
]
sayakpaul327 days ago

Should use x_slice and not x.

a-r-r-o-w327 days ago

Could maybe further refactor this to how the current implementations of Cog/Mochi are with _decode method. A bit easier to understand code flow that way

sayakpaul327 days ago

Yeah sure feel free to club those in your PR.

sayakpaul bye test_models_vae.py
86c03534
sayakpaul
sayakpaul commented on 2024-10-30
Conversation is marked as resolved
Show resolved
tests/models/autoencoders/test_models_autoencoder_kl_allegro.py
75 inputs_dict = self.dummy_input
76 return init_dict, inputs_dict
77
78
# TODO: @a-r-r-o-w
sayakpaul327 days ago

Cc: @a-r-r-o-w this seems to be common in Allegro:

TypeError: encode() got an unexpected keyword argument 'local_batch_size' allegro vae.

Could you please check?

a-r-r-o-w327 days ago

My bad, I forgot to fix the forward implementation, and made changes only to the encode and decode ones.

LMK when you're taking a break, so I push changes to fix this (or would a separate PR to this branch be more suitable?)

sayakpaul fix
9c679485
sayakpaul fix
ee835bc7
sayakpaul Merge branch 'main' into vae-tests
a157dae2
sayakpaul remove allegro
4d0bae25
sayakpaul fixes
19515bcb
sayakpaul sayakpaul marked this pull request as ready for review 327 days ago
sayakpaul sayakpaul requested a review from DN6 DN6 327 days ago
sayakpaul sayakpaul requested a review from a-r-r-o-w a-r-r-o-w 327 days ago
sayakpaul remove tests/models/autoencoders/test_models_vae.py
786fd5be
sayakpaul
sayakpaul315 days ago

@DN6 a gentle ping.

sayakpaul sayakpaul changed the title [WIP] [tests] refactor vae tests [tests] refactor vae tests 315 days ago
sayakpaul fixes
d67e63ba
sayakpaul fixes
ac8f7e12
sayakpaul
sayakpaul commented on 2024-11-12
src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py
434434 temb,
435435 zq,
436 conv_cache=conv_cache.get(conv_cache_key),
436
conv_cache.get(conv_cache_key),
sayakpaul314 days ago (edited 314 days ago)

Because the torch.utils.checkpoint.checkpoint() method doesn't have any conv_cache argument.

sayakpaul
sayakpaul commented on 2024-11-12
tests/models/test_modeling_common.py
sayakpaul314 days ago

Because these are supported.

sayakpaul Merge branch 'main' into vae-tests
bfe23ffb
sayakpaul
sayakpaul308 days ago

@a-r-r-o-w @DN6 a gentle ping.

sayakpaul Merge branch 'main' into vae-tests
364659b0
sayakpaul Merge branch 'main' into vae-tests
a400bc91
sayakpaul Merge branch 'main' into vae-tests
c79170de
sayakpaul rebase
d55ed945
DN6 Merge branch 'main' into vae-tests
fb8aa886
DN6
DN6 approved these changes on 2024-12-04
sayakpaul sayakpaul merged c1926cef into main 292 days ago
sayakpaul sayakpaul deleted the vae-tests branch 292 days ago
sayakpaul
sayakpaul292 days ago

@a-r-r-o-w merging this to unblock you and will let you add any left over tests. Hopefully, that is okay.

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone