Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pr_modular_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
python utils/check_copies.py
python utils/check_dummies.py
python utils/check_support_list.py
python utils/check_forward_call_docstrings.py
make deps_table_check_updated
- name: Check if failure
if: ${{ failure() }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
python utils/check_copies.py
python utils/check_dummies.py
python utils/check_support_list.py
python utils/check_forward_call_docstrings.py
make deps_table_check_updated
- name: Check if failure
if: ${{ failure() }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr_tests_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
python utils/check_copies.py
python utils/check_dummies.py
python utils/check_support_list.py
python utils/check_forward_call_docstrings.py
make deps_table_check_updated
- name: Check if failure
if: ${{ failure() }}
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ repo-consistency:
python utils/check_dummies.py
python utils/check_repo.py
python utils/check_inits.py
python utils/check_forward_call_docstrings.py

# this target runs checks on all files

Expand Down Expand Up @@ -74,6 +75,10 @@ fix-copies:
modular-autodoctrings:
python utils/modular_auto_docstring.py

# Verify forward() / __call__() arguments are documented in their docstrings
check-forward-call-docstrings:
python utils/check_forward_call_docstrings.py

# Run tests for the library

test:
Expand Down
4 changes: 4 additions & 0 deletions src/diffusers/models/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ def forward(self, x: torch.Tensor) -> list[torch.Tensor]:
each representing information extracted at a different scale from the input. The length of the list is
determined by the number of downsample blocks in the Adapter, as specified by the `channels` and
`num_res_blocks` parameters during initialization.
Args:
x (`torch.Tensor`):
The input tensor to process through the adapter model.
"""
return self.adapter(x)

Expand Down
3 changes: 3 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_asym_kl.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
6 changes: 6 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,12 @@ def tiled_decode(self, z: torch.Tensor, return_dict: bool = True) -> DecoderOutp
return DecoderOutput(sample=decoded)

def forward(self, sample: torch.Tensor, return_dict: bool = True) -> torch.Tensor:
r"""
Args:
sample (`torch.Tensor`): Input sample.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
"""
encoded = self.encode(sample, return_dict=False)[0]
decoded = self.decode(encoded, return_dict=False)[0]
if not return_dict:
Expand Down
3 changes: 3 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
11 changes: 11 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,17 @@ def forward(
return_dict: bool = True,
generator: torch.Generator | None = None,
) -> torch.Tensor | torch.Tensor:
r"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
if sample_posterior:
Expand Down
11 changes: 11 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,17 @@ def forward(
return_dict: bool = True,
generator: torch.Generator | None = None,
) -> tuple[torch.Tensor] | DecoderOutput:
r"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
if sample_posterior:
Expand Down
3 changes: 3 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_flux2.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,9 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,13 @@ def forward(
"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
posterior = self.encode(sample).latent_dist
if sample_posterior:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,9 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,9 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
3 changes: 3 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_kvae.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,9 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
11 changes: 11 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_kvae_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,17 @@ def forward(
return_dict: bool = True,
generator: Optional[torch.Generator] = None,
) -> Union[DecoderOutput, torch.Tensor]:
r"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
if sample_posterior:
Expand Down
13 changes: 13 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_ltx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,19 @@ def forward(
return_dict: bool = True,
generator: torch.Generator | None = None,
) -> torch.Tensor | torch.Tensor:
r"""
Args:
sample (`torch.Tensor`): Input sample.
temb (`torch.Tensor`, *optional*):
Optional timestep embedding tensor used to condition the decoder.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
if sample_posterior:
Expand Down
17 changes: 17 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_ltx2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,23 @@ def forward(
return_dict: bool = True,
generator: torch.Generator | None = None,
) -> torch.Tensor | torch.Tensor:
r"""
Args:
sample (`torch.Tensor`): Input sample.
temb (`torch.Tensor`, *optional*):
Optional timestep embedding tensor used to condition the decoder.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
encoder_causal (`bool`, *optional*):
Whether the encoder should use causal convolutions. If `None`, falls back to the model default.
decoder_causal (`bool`, *optional*):
Whether the decoder should use causal convolutions. If `None`, falls back to the model default.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x, causal=encoder_causal).latent_dist
if sample_posterior:
Expand Down
11 changes: 11 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_ltx2_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,17 @@ def forward(
return_dict: bool = True,
generator: torch.Generator | None = None,
) -> DecoderOutput | torch.Tensor:
r"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
posterior = self.encode(sample).latent_dist
if sample_posterior:
z = posterior.sample(generator=generator)
Expand Down
3 changes: 3 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_magvit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
11 changes: 11 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_mochi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,17 @@ def forward(
return_dict: bool = True,
generator: torch.Generator | None = None,
) -> torch.Tensor | torch.Tensor:
r"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
if sample_posterior:
Expand Down
5 changes: 5 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_qwenimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,8 +1043,13 @@ def forward(
"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
num_frames (`int`, *optional*, defaults to 1):
The number of frames to decode per batch.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
5 changes: 5 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_wan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,8 +1416,13 @@ def forward(
"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
11 changes: 11 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_longcat_audio_dit.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,17 @@ def forward(
return_dict: bool = True,
generator: torch.Generator | None = None,
) -> LongCatAudioDiTVaeDecoderOutput | tuple[torch.Tensor]:
r"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `False`):
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`LongCatAudioDiTVaeDecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
latents = self.encode(sample, sample_posterior=sample_posterior, return_dict=True, generator=generator).latents
decoded = self.decode(latents, return_dict=True).sample
if not return_dict:
Expand Down
3 changes: 3 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_oobleck.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ def forward(
Whether to sample from the posterior.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`OobleckDecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
posterior = self.encode(x).latent_dist
Expand Down
9 changes: 9 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_rae.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,15 @@ def decode(self, z: torch.Tensor, return_dict: bool = True) -> DecoderOutput | t
def forward(
self, sample: torch.Tensor, return_dict: bool = True, generator: torch.Generator | None = None
) -> DecoderOutput | tuple[torch.Tensor]:
r"""
Args:
sample (`torch.Tensor`): Input sample.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
latents = self.encode(sample, return_dict=False, generator=generator)[0]
decoded = self.decode(latents, return_dict=False)[0]
if not return_dict:
Expand Down
13 changes: 13 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_vidtok.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,19 @@ def forward(
return_dict: bool = True,
generator: Optional[torch.Generator] = None,
) -> Union[torch.Tensor, DecoderOutput]:
r"""
Args:
sample (`torch.Tensor`): Input sample.
sample_posterior (`bool`, *optional*, defaults to `True`):
Whether to sample from the posterior.
encoder_mode (`bool`, *optional*, defaults to `False`):
If `True`, only run the encoder and return the encoded latent without decoding.
return_dict (`bool`, *optional*, defaults to `True`):
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
generator (`torch.Generator`, *optional*):
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
deterministic.
"""
x = sample
res = 1 if self.is_causal else 0
if self.is_causal:
Expand Down
Loading
Loading