Skip to content

Commit e87b2a7

Browse files
sayakpaulstevhliuclaudegithub-actions[bot]
authored
[docs] Follow ups for consistent forward docstrings (#13779)
* feat: allow docstring checker to fix unused args in docstrings. * feat: check for returns, too. * [docs] add missing Returns sections to forward/__call__ docstrings (#13830) Adds a Returns: section to the 43 model forward() and pipeline __call__() methods flagged by utils/check_forward_call_docstrings.py, which requires a Returns: section whenever the method has a non-None return annotation. Descriptions reflect the actual return statements (Output dataclass when return_dict=True, plain tuple otherwise; bare tensors / lists where applicable) and reuse each file's existing doc-builder link form. Also reformats a malformed single-line Returns: in pipeline_aura_flow.py that the check could not detect. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * Apply style fixes --------- Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 537b7fc commit e87b2a7

43 files changed

Lines changed: 412 additions & 8 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/diffusers/models/adapter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ def forward(self, xs: torch.Tensor, adapter_weights: list[float] | None = None)
8484
adapter_weights (`list[float]`, *optional*, defaults to None):
8585
A list of floats representing the weights which will be multiplied by each adapter's output before
8686
summing them together. If `None`, equal weights will be used for all adapters.
87+
88+
Returns:
89+
`list[torch.Tensor]`:
90+
A list of feature tensors, one per scale, obtained by summing the per-scale features of each adapter
91+
weighted by `adapter_weights`.
8792
"""
8893
if adapter_weights is None:
8994
adapter_weights = torch.tensor([1 / self.num_adapter] * self.num_adapter)
@@ -273,6 +278,11 @@ def forward(self, x: torch.Tensor) -> list[torch.Tensor]:
273278
Args:
274279
x (`torch.Tensor`):
275280
The input tensor to process through the adapter model.
281+
282+
Returns:
283+
`list[torch.Tensor]`:
284+
A list of feature tensors, each representing information extracted at a different scale from the input.
285+
The length of the list equals the number of downsample blocks in the adapter.
276286
"""
277287
return self.adapter(x)
278288

src/diffusers/models/autoencoders/autoencoder_asym_kl.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ def forward(
169169
generator (`torch.Generator`, *optional*):
170170
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
171171
deterministic.
172+
173+
Returns:
174+
[`DecoderOutput`] or `tuple`:
175+
If `return_dict` is True, a [`DecoderOutput`] is returned, otherwise a plain `tuple` is returned.
172176
"""
173177
x = sample
174178
posterior = self.encode(x).latent_dist

src/diffusers/models/autoencoders/autoencoder_dc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,11 @@ def forward(self, sample: torch.Tensor, return_dict: bool = True) -> torch.Tenso
711711
sample (`torch.Tensor`): Input sample.
712712
return_dict (`bool`, *optional*, defaults to `True`):
713713
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
714+
715+
Returns:
716+
[`~models.vae.DecoderOutput`] or `tuple`:
717+
If `return_dict` is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
718+
returned.
714719
"""
715720
encoded = self.encode(sample, return_dict=False)[0]
716721
decoded = self.decode(encoded, return_dict=False)[0]

src/diffusers/models/autoencoders/autoencoder_kl.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ def forward(
427427
generator (`torch.Generator`, *optional*):
428428
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
429429
deterministic.
430+
431+
Returns:
432+
[`~models.vae.DecoderOutput`] or `tuple`:
433+
If `return_dict` is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
434+
returned.
430435
"""
431436
x = sample
432437
posterior = self.encode(x).latent_dist

src/diffusers/models/autoencoders/autoencoder_kl_allegro.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,11 @@ def forward(
10541054
Whether or not to return a [`DecoderOutput`] instead of a plain tuple.
10551055
generator (`torch.Generator`, *optional*):
10561056
PyTorch random number generator.
1057+
1058+
Returns:
1059+
[`~models.vae.DecoderOutput`] or `tuple`:
1060+
If `return_dict` is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
1061+
returned.
10571062
"""
10581063
x = sample
10591064
posterior = self.encode(x).latent_dist

src/diffusers/models/autoencoders/autoencoder_kl_cogvideox.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,11 @@ def forward(
14191419
generator (`torch.Generator`, *optional*):
14201420
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
14211421
deterministic.
1422+
1423+
Returns:
1424+
[`~models.vae.DecoderOutput`] or `tuple`:
1425+
If `return_dict` is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
1426+
returned.
14221427
"""
14231428
x = sample
14241429
posterior = self.encode(x).latent_dist

src/diffusers/models/autoencoders/autoencoder_kl_cosmos.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,11 @@ def forward(
10881088
generator (`torch.Generator`, *optional*):
10891089
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
10901090
deterministic.
1091+
1092+
Returns:
1093+
[`~models.vae.DecoderOutput`] or `tuple`:
1094+
If `return_dict` is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
1095+
returned.
10911096
"""
10921097
x = sample
10931098
posterior = self.encode(x).latent_dist

src/diffusers/models/autoencoders/autoencoder_kl_flux2.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ def forward(
444444
generator (`torch.Generator`, *optional*):
445445
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
446446
deterministic.
447+
448+
Returns:
449+
[`~models.vae.DecoderOutput`] or `tuple`:
450+
If `return_dict` is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
451+
returned.
447452
"""
448453
x = sample
449454
posterior = self.encode(x).latent_dist

src/diffusers/models/autoencoders/autoencoder_kl_hunyuan_video.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,11 @@ def forward(
10641064
generator (`torch.Generator`, *optional*):
10651065
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
10661066
deterministic.
1067+
1068+
Returns:
1069+
[`~models.vae.DecoderOutput`] or `tuple`:
1070+
If `return_dict` is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
1071+
returned.
10671072
"""
10681073
x = sample
10691074
posterior = self.encode(x).latent_dist

src/diffusers/models/autoencoders/autoencoder_kl_hunyuanimage.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,11 @@ def forward(
681681
generator (`torch.Generator`, *optional*):
682682
A [`torch.Generator`](https://pytorch.org/docs/stable/generated/torch.Generator.html) to make sampling
683683
deterministic.
684+
685+
Returns:
686+
[`~models.vae.DecoderOutput`] or `tuple`:
687+
If `return_dict` is True, a [`~models.vae.DecoderOutput`] is returned, otherwise a plain `tuple` is
688+
returned.
684689
"""
685690
posterior = self.encode(sample).latent_dist
686691
if sample_posterior:

0 commit comments

Comments
 (0)