Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Utils] add utilities for checking if certain utilities are properly documented #7763

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

sayakpaul
Copy link
Member

What does this PR do?

We have a bunch of attention processors, normalization layers, and activation layers in the codebase and they have thin documentation. This is fine because users can always see their usage in the context of a model or a pipeline to get the fuller picture.

But since we document them in separate pages too, (such as this, this, and this), I think it makes sense to ensure these docs properly reflect what all we support.

This PR adds utilities to do that. @stevhliu I think you will like it :-)

@sayakpaul
Copy link
Member Author

@stevhliu any idea why the doc build fails?

@stevhliu
Copy link
Member

I'm not sure, the formatting all looks correct to me but for reason autodoc.py can't find them! cc @mishig25 have you encountered this before?

@sayakpaul
Copy link
Member Author

@mishig25 a gentle ping.

@mishig25
Copy link
Contributor

mishig25 commented May 2, 2024

let me check

Comment on lines 37 to 39
## LayerNorm

[[autodoc]] models.normalization.LayerNorm
Copy link
Contributor

@mishig25 mishig25 May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LayerNorm is the reason why doc-builder is not building.

I've inspected a bit.
All other norms are diffuser defined classes:

>>> import diffusers
>>> diffusers.models.normalization.GlobalResponseNorm
<class 'diffusers.models.normalization.GlobalResponseNorm'>

whereas LayerNorm seems to be alias to pytorch defined class (and doc-builder autodoc does not work with pytorch defined classes):

>>> import diffusers
>>> diffusers.models.normalization.LayerNorm
<class 'torch.nn.modules.normalization.LayerNorm'>

LayerNorm = nn.LayerNorm

Therefore, as a simple fix: I'd suggest replacing [[autodoc]] models.normalization.LayerNorm with something like: You can also use LayerNorm and add markdown link to pytorch layernorm doc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mishig25. I think it'd be okay to remove LayerNorm from our doc because our implementation is really a special case and is already supported in the latest versions of PyTorch.

@HuggingFaceDocBuilderDev

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
Copy link
Member Author

@stevhliu @yiyixuxu this is ready for review.

Copy link
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

src/diffusers/models/normalization.py Outdated Show resolved Hide resolved
src/diffusers/models/normalization.py Outdated Show resolved Hide resolved
src/diffusers/models/normalization.py Outdated Show resolved Hide resolved
src/diffusers/models/normalization.py Outdated Show resolved Hide resolved
src/diffusers/models/normalization.py Outdated Show resolved Hide resolved
src/diffusers/models/normalization.py Outdated Show resolved Hide resolved
src/diffusers/models/normalization.py Outdated Show resolved Hide resolved
src/diffusers/models/normalization.py Outdated Show resolved Hide resolved
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
@sayakpaul
Copy link
Member Author

Gentle ping @yiyixuxu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants