Skip to content

Conversation

@younesbelkada
Copy link
Contributor

@younesbelkada younesbelkada commented Sep 20, 2022

What does this PR do?

This PR adds more documentation on Flax modules
I am planning to add documentation only on modules that are documented on PyTorch modeling files, this includes

Inside attention_flax.py file:

  • FlaxAttentionBlock
  • FlaxBasicTransformerBlock
  • FlaxSpatialTransformer
  • FlaxGluFeedForward
  • FlaxGEGLU

Inside embeddings_flax.py file:

  • FlaxTimestepEmbedding
  • FlaxTimesteps

Inside unet_2d_condition_flax.py file:

  • FlaxCrossAttnDownBlock2D
  • FlaxDownBlock2D
  • FlaxCrossAttnUpBlock2D
  • FlaxUpBlock2D
  • FlaxUNetMidBlock2DCrossAttn

Inside vae_flax.py file:

  • FlaxUpsample2D
  • FlaxDownsample2D
  • FlaxResnetBlock2D
  • FlaxAttentionBlock
  • FlaxUpEncoderBlock2D
  • FlaxUNetMidBlock2D
  • FlaxEncoder
  • FlaxDecoder
  • FlaxDiagonalGaussianDistribution
  • FlaxAutoencoderKL

Questions

Do we put the paragraph

This model is a Flax Linen [flax.linen.Module](https://flax.readthedocs.io/en/latest/flax.linen.html#module)
    subclass. Use it as a regular Flax linen Module and refer to the Flax documentation for all matter related to
    general usage and behavior.

    Finally, this model supports inherent JAX features such as:
    - [Just-In-Time (JIT) compilation](https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit)
    - [Automatic Differentiation](https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation)
    - [Vectorization](https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap)
    - [Parallelization](https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap)

on each nn.Module as we do it in transformers or it's too redundant?

cc @patrickvonplaten @mishig25

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 20, 2022

The documentation is not available anymore as the PR was closed or merged.

@mishig25
Copy link
Contributor

mishig25 commented Sep 20, 2022

I put them inside the docs page ea8cbdb

should be clear what's going on here

for example, you can see here now that flax docs are rendered in

@mishig25
Copy link
Contributor

to preview locally (quikcer):

  1. Install doc-builder on your system if not already:
git clone https://github.com/huggingface/doc-builder.git
cd doc-builder
pip install -e .

then run:

doc-builder preview diffusers ~/Desktop/diffusers/docs/source/

(obv, change the path based on your system)

Tuple containing the number of output channels for each block
layers_per_block (:obj:`int`, *optional*, defaults to `2`):
Number of Resnet layer for each block
norm_num_groups (:obj:`int`, *optional*, defaults to `2`):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This argument seems to be never used 🤔 Seems to be corresponding to resnet_groups in vae.py but not sure about here

Copy link
Member

Choose a reason for hiding this comment

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

I opened #621 to fix this separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot @pcuenca 💪

Activation function
latent_channels (:obj:`int`, *optional*, defaults to `4`):
Latent space channels
norm_num_groups (:obj:`int`, *optional*, defaults to `2`):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same comment as above

@younesbelkada
Copy link
Contributor Author

cc @patil-suraj with #595 being merged I think this is ready for review 🔥 (I cannot somehow request review here)

@patrickvonplaten
Copy link
Contributor

Wow super cool!

@patrickvonplaten
Copy link
Contributor

Wow this is super cool!

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Great effort @younesbelkada ! Looks good to me for merge

Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

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

Amazing work! Very comprehensive and detailed, thanks a lot!

- [Just-In-Time (JIT) compilation](https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit)
- [Automatic Differentiation](https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation)
- [Vectorization](https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap)
- [Parallelization](https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap)
Copy link
Member

Choose a reason for hiding this comment

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

👍 ❤️

@younesbelkada
Copy link
Contributor Author

Thank you very much @patrickvonplaten @pcuenca ! 💯
Let me know if you see anything else that we can add, maybe more references to academic papers for some architectures?

@pcuenca
Copy link
Member

pcuenca commented Sep 23, 2022

I think it already looks great :) But if you think it's useful to add more references just go for it and merge when you are done :)

@younesbelkada
Copy link
Contributor Author

Perfect looks good to me too! I can't somehow merge nor approve, I think that I don't have the rights on this repo so feel free to merge whenever you want 💪 🔥

@pcuenca pcuenca merged commit 8b0be93 into huggingface:main Sep 23, 2022
prathikr pushed a commit to prathikr/diffusers that referenced this pull request Oct 26, 2022
* documenting `attention_flax.py` file

* documenting `embeddings_flax.py`

* documenting `unet_blocks_flax.py`

* Add new objs to doc page

* document `vae_flax.py`

* Apply suggestions from code review

* modify `unet_2d_condition_flax.py`

* make style

* Apply suggestions from code review

* make style

* Apply suggestions from code review

* fix indent

* fix typo

* fix indent unet

* Update src/diffusers/models/vae_flax.py

* Apply suggestions from code review

Co-authored-by: Pedro Cuenca <[email protected]>

Co-authored-by: Mishig Davaadorj <[email protected]>
Co-authored-by: Pedro Cuenca <[email protected]>
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* documenting `attention_flax.py` file

* documenting `embeddings_flax.py`

* documenting `unet_blocks_flax.py`

* Add new objs to doc page

* document `vae_flax.py`

* Apply suggestions from code review

* modify `unet_2d_condition_flax.py`

* make style

* Apply suggestions from code review

* make style

* Apply suggestions from code review

* fix indent

* fix typo

* fix indent unet

* Update src/diffusers/models/vae_flax.py

* Apply suggestions from code review

Co-authored-by: Pedro Cuenca <[email protected]>

Co-authored-by: Mishig Davaadorj <[email protected]>
Co-authored-by: Pedro Cuenca <[email protected]>
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.

5 participants