* Bump the actions group with 17 updates (#12) Bumps the actions group with 17 updates: | Package | From | To | | --- | --- | --- | | [actions/checkout](https://github.com/actions/checkout) | `6` | `7` | | [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4.6.2` | `7.0.1` | | [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) | `3.12.0` | `4.2.0` | | [docker/login-action](https://github.com/docker/login-action) | `3.7.0` | `4.6.0` | | [docker/build-push-action](https://github.com/docker/build-push-action) | `6.19.2` | `7.3.0` | | [huggingface/doc-builder/.github/workflows/build_main_documentation.yml](https://github.com/huggingface/doc-builder) | `e60a538eea9817ab312196d0d233604b01697265` | `af49b8dc3859c3d80c7220c8c0ba146431132e49` | | [actions/setup-python](https://github.com/actions/setup-python) | `5.6.0` | `7.0.0` | | [huggingface/doc-builder/.github/workflows/build_pr_documentation.yml](https://github.com/huggingface/doc-builder) | `e60a538eea9817ab312196d0d233604b01697265` | `af49b8dc3859c3d80c7220c8c0ba146431132e49` | | [anthropics/claude-code-action](https://github.com/anthropics/claude-code-action) | `1.0.155` | `1.0.193` | | [huggingface/security-workflows/.github/workflows/codeql-reusable.yml](https://github.com/huggingface/security-workflows) | `1.1.0` | `1.2.0` | | [actions/download-artifact](https://github.com/actions/download-artifact) | `4.3.0` | `8.0.1` | | [actions/labeler](https://github.com/actions/labeler) | `5.0.0` | `7.0.0` | | [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) | `1.13.0` | `1.14.2` | | [huggingface/tailscale-action](https://github.com/huggingface/tailscale-action) | `7d53c9737e53934c30290b5524d1c9b4a7c98c8a` | `07d36e4c3b68707bd3fe070dbb96f03f993a6efd` | | [trufflesecurity/trufflehog](https://github.com/trufflesecurity/trufflehog) | `3.94.2` | `3.97.0` | | [crate-ci/typos](https://github.com/crate-ci/typos) | `1.42.1` | `1.49.0` | | [huggingface/doc-builder/.github/workflows/upload_pr_documentation.yml](https://github.com/huggingface/doc-builder) | `9ad2de8582b56c017cb530c1165116d40433f1c6` | `af49b8dc3859c3d80c7220c8c0ba146431132e49` | Updates `actions/checkout` from 6 to 7 - [Release notes](https://github.com/actions/checkout/releases) - [Commits](https://github.com/actions/checkout/compare/v6...v7) Updates `actions/upload-artifact` from 4.6.2 to 7.0.1 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4.6.2...v7.0.1) Updates `docker/setup-buildx-action` from 3.12.0 to 4.2.0 - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](8d2750c68a...bb05f3f551) Updates `docker/login-action` from 3.7.0 to 4.6.0 - [Release notes](https://github.com/docker/login-action/releases) - [Commits](c94ce9fb46...dbcb813823) Updates `docker/build-push-action` from 6.19.2 to 7.3.0 - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](10e90e3645...53b7df96c9) Updates `huggingface/doc-builder/.github/workflows/build_main_documentation.yml` from e60a538eea9817ab312196d0d233604b01697265 to af49b8dc3859c3d80c7220c8c0ba146431132e49 - [Release notes](https://github.com/huggingface/doc-builder/releases) - [Commits](e60a538eea...af49b8dc38) Updates `actions/setup-python` from 5.6.0 to 7.0.0 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v5.6.0...v7) Updates `huggingface/doc-builder/.github/workflows/build_pr_documentation.yml` from e60a538eea9817ab312196d0d233604b01697265 to af49b8dc3859c3d80c7220c8c0ba146431132e49 - [Release notes](https://github.com/huggingface/doc-builder/releases) - [Commits](e60a538eea...af49b8dc38) Updates `anthropics/claude-code-action` from 1.0.155 to 1.0.193 - [Release notes](https://github.com/anthropics/claude-code-action/releases) - [Commits](80b3182633...9d7150bc8a) Updates `huggingface/security-workflows/.github/workflows/codeql-reusable.yml` from 1.1.0 to 1.2.0 - [Release notes](https://github.com/huggingface/security-workflows/releases) - [Commits](dc6ca34688...e0d40aaf3c) Updates `actions/download-artifact` from 4.3.0 to 8.0.1 - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v4.3.0...3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c) Updates `actions/labeler` from 5.0.0 to 7.0.0 - [Release notes](https://github.com/actions/labeler/releases) - [Commits](8558fd7429...bf12e9b00b) Updates `pypa/gh-action-pypi-publish` from 1.13.0 to 1.14.2 - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](ed0c53931b...dc37677b2e) Updates `huggingface/tailscale-action` from 7d53c9737e53934c30290b5524d1c9b4a7c98c8a to 07d36e4c3b68707bd3fe070dbb96f03f993a6efd - [Release notes](https://github.com/huggingface/tailscale-action/releases) - [Commits](7d53c9737e...07d36e4c3b) Updates `trufflesecurity/trufflehog` from 3.94.2 to 3.97.0 - [Release notes](https://github.com/trufflesecurity/trufflehog/releases) - [Commits](6bd2d14f7a...bcfcf73aaf) Updates `crate-ci/typos` from 1.42.1 to 1.49.0 - [Release notes](https://github.com/crate-ci/typos/releases) - [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md) - [Commits](65120634e7...8a48f81b6c) Updates `huggingface/doc-builder/.github/workflows/upload_pr_documentation.yml` from 9ad2de8582b56c017cb530c1165116d40433f1c6 to af49b8dc3859c3d80c7220c8c0ba146431132e49 - [Release notes](https://github.com/huggingface/doc-builder/releases) - [Commits](9ad2de8582...af49b8dc38) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: actions/upload-artifact dependency-version: 7.0.1 dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: docker/setup-buildx-action dependency-version: 4.2.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: docker/login-action dependency-version: 4.6.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: docker/build-push-action dependency-version: 7.3.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: huggingface/doc-builder/.github/workflows/build_main_documentation.yml dependency-version: af49b8dc3859c3d80c7220c8c0ba146431132e49 dependency-type: direct:production dependency-group: actions - dependency-name: actions/setup-python dependency-version: 7.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: huggingface/doc-builder/.github/workflows/build_pr_documentation.yml dependency-version: af49b8dc3859c3d80c7220c8c0ba146431132e49 dependency-type: direct:production dependency-group: actions - dependency-name: anthropics/claude-code-action dependency-version: 1.0.193 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions - dependency-name: huggingface/security-workflows/.github/workflows/codeql-reusable.yml dependency-version: 1.2.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: actions/download-artifact dependency-version: 8.0.1 dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: actions/labeler dependency-version: 7.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions - dependency-name: pypa/gh-action-pypi-publish dependency-version: 1.14.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: huggingface/tailscale-action dependency-version: 07d36e4c3b68707bd3fe070dbb96f03f993a6efd dependency-type: direct:production dependency-group: actions - dependency-name: trufflesecurity/trufflehog dependency-version: 3.97.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: crate-ci/typos dependency-version: 1.49.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: actions - dependency-name: huggingface/doc-builder/.github/workflows/upload_pr_documentation.yml dependency-version: af49b8dc3859c3d80c7220c8c0ba146431132e49 dependency-type: direct:production dependency-group: actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Scope GITHUB_TOKEN permissions per job (#16) A job with no `permissions:` block inherits whatever the repository hands out. Each block added here grants what that job's own steps need and nothing more. Co-authored-by: hf-security-analysis[bot] <265538906+hf-security-analysis[bot]@users.noreply.github.com> * Pin GitHub Actions to commit SHAs (#17) A tag is mutable: whoever controls the action's repository can move `v4` to different code, and the next run picks it up with no diff to review. Pinning to the commit SHA freezes the code that runs today. Co-authored-by: hf-security-analysis[bot] <265538906+hf-security-analysis[bot]@users.noreply.github.com> * Bump doc-builder workflow pin (#22) * Bump doc-builder pin to 9fc8a41 in build_documentation.yml Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Bump doc-builder pin to 9fc8a41 in build_pr_documentation.yml Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Bump doc-builder pin to 9fc8a41 in upload_pr_documentation.yml Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * Add FLUX.3 image: Flux3Transformer2DModel and modular text-to-image / image-to-image pipeline Adds the FLUX.3 image transformer, the modular pipeline (text-to-image and image-to-image with one prompt per call and one or more reference images), Flux3ImageProcessor, the converter for BFL's model package, tests and docs. Verified against BFL's reference on the real checkpoint (integration-notes/parity_bf16.py, temporary folder). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * integration-notes: ship the knight example image with the doc examples Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * integration-notes: drop the tokenizer config workaround (not needed with transformers 5.x) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Address review: rename the mode channel dict and the final norm, name the reference workflow image_conditioned, document the guidance scale Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Add the step-distilled FLUX.3 image model (flow map) - transformer: `flow_map` config and `target_timestep_embedder`; forward takes `target_timestep` (the timestep each step jumps to), added to the modulation of every mode and the final layer - convert script: map `ref_time_in.*` and read `flow_map` from the package config - modular: dedicated `Flux3Distilled*` blocks (text encoder, text input, text RoPE inputs, denoiser) with no guider and no negative prompt, 16 steps by default; `Flux3DistilledAutoBlocks` and `Flux3DistilledModularPipeline` - tests for the flow-map transformer path and the distilled modular pipeline - docs: step-distilled section and autodoc entries Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Add the step-distilled examples script Same four cases as flux3_examples.py, run against the distilled Hub repo. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * feat: add a single file support in Flux3 image. (#32) * Warn about the denoiser input fields that are not passed to the transformer Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Document reproducible generation with user-provided latents Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Run the QK norm and RoPE in fp32 with a single cast back, matching the BFL implementation Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * parity script: run against the Hub repos and print the imported diffusers source Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * Wrap a forward docstring line for the doc-builder style check Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * support lora loading (including ostris) in flux3 image pipeline. (#25) * feat: support loading and performing inference with single-file formatted FP8 and NVFP4 checkpoints (#24) * feat: support loading siungle file format checkpoints including quants. * remove updates.patch * remove fluff. * feat: add a single file support in Flux3 image. * bfl prefix * version guard. * prpoagate changes. * add tests * doc mods and remove integration notes * remove script for quant --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> * add LoRA training for Flux 3 image small * tests: clarify FLUX3_TINY_REPO comment The tiny repo is uploaded to hf-internal-testing and the env var is a local-dev escape hatch, not a pre-PR TODO. * examples/flux3: drop unused args and dead class Remove the text-encoder weight-decay arg from both trainers (neither trains the text encoder) and, from the img2img trainer, the prior-preservation leftovers (--class_data_dir, --sample_batch_size, PromptDataset) that it never uses. * bump yarn example rank to 32 in flux3 small readme * Document <ref_image_n> references and layout prompts for FLUX.3 Matches the prompt grammar in BFL's reference inference code (bfl-hf-flux3-confidential#3): references are addressed as <ref_image_n> in the order passed to image, and regions can be placed with a trailing JSON list of id / bbox / desc (from / src_bbox / tgt_bbox when editing). * examples/flux3: set klein model id, document ref image prompts, clean leftover refs * point flux3 image docs at the klein release model ids * fix: TestFlux3DistilledModularPipelineWorkflow::test_workflow_defaults test (#35) * fix checkpoint ids in the flux3 docs. (#38) * [docs] update pipe loading with vae fp32 dtype (#39) * update pipe loading with vae fp32 dtype * updating `load_componenets` * use actual ckpts. (#42) * flux3 klein example: rename from "small" and fix caption dropout for long prompts (#41) * examples/flux3: rename small trainer, tests and readme files to klein * examples/flux3: fix caption dropout shape mismatch for prompts longer than the pad window * examples/flux3: add caption dropout to the i2i trainer * examples/flux3: complete the klein rename (test class names, example output dirs) * examples/flux3: guard against train_batch_size>1 with variable-length captions * update flux3.md (#43) * examples/flux3: support train_batch_size>1 and prior preservation with variable-length captions (#44) * doc * autodocstrings. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: hf-security-analysis[bot] <265538906+hf-security-analysis[bot]@users.noreply.github.com> Co-authored-by: Pauline Bailly-Masson <155966238+paulinebm@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: yiyixuxu <yixu310@gmail.com> Co-authored-by: linoytsaban <linoy.tsaban@gmail.com> Co-authored-by: apolinário <joaopaulo.passos@gmail.com> Co-authored-by: Linoy Tsaban <57615435+linoytsaban@users.noreply.github.com> Co-authored-by: Aritra Roy Gosthipaty <aritra.born2fly@gmail.com> Co-authored-by: Yumeng Li <109459218+YumengLi007@users.noreply.github.com>
Generating the documentation
To generate the documentation, you first have to build it. Several packages are necessary to build the doc, you can install them with the following command, at the root of the code repository:
pip install -e ".[docs]"
Then you need to install our open source documentation builder tool:
pip install git+https://github.com/huggingface/doc-builder
NOTE
You only need to generate the documentation to inspect it locally (if you're planning changes and want to check how they look before committing for instance). You don't have to commit the built documentation.
Previewing the documentation
To preview the docs, first install the watchdog module with:
pip install watchdog
Then run the following command:
doc-builder preview {package_name} {path_to_docs}
For example:
doc-builder preview diffusers docs/source/en
The docs will be viewable at http://localhost:3000. You can also preview the docs once you have opened a PR. You will see a bot add a comment to a link where the documentation with your changes lives.
NOTE
The preview command only works with existing doc files. When you add a completely new file, you need to update _toctree.yml & restart preview command (ctrl-c to stop it & call doc-builder preview ... again).
Adding a new element to the navigation bar
Accepted files are Markdown (.md).
Create a file with its extension and put it in the source directory. You can then link it to the toc-tree by putting
the filename without the extension in the _toctree.yml file.
Renaming section headers and moving sections
It helps to keep the old links working when renaming the section header and/or moving sections from one document to another. This is because the old links are likely to be used in Issues, Forums, and Social media and it'd make for a much more superior user experience if users reading those months later could still easily navigate to the originally intended information.
Therefore, we simply keep a little map of moved sections at the end of the document where the original section was. The key is to preserve the original anchor.
So if you renamed a section from: "Section A" to "Section B", then you can add at the end of the file:
Sections that were moved:
[ <a href="#section-b">Section A</a><a id="section-a"></a> ]
and of course, if you moved it to another file, then:
Sections that were moved:
[ <a href="../new-file#section-b">Section A</a><a id="section-a"></a> ]
Use the relative style to link to the new file so that the versioned docs continue to work.
For an example of a rich moved section set please see the very end of the transformers Trainer doc.
Writing Documentation - Specification
The huggingface/diffusers documentation follows the
Google documentation style for docstrings,
although we can write them directly in Markdown.
Adding a new tutorial
Adding a new tutorial or section is done in two steps:
- Add a new Markdown (.md) file under
docs/source/<languageCode>. - Link that file in
docs/source/<languageCode>/_toctree.ymlon the correct toc-tree.
Make sure to put your new file under the proper section. It's unlikely to go in the first section (Get Started), so depending on the intended targets (beginners, more advanced users, or researchers) it should go in sections two, three, or four.
Adding a new pipeline/scheduler
When adding a new pipeline:
- Create a file
xxx.mdunderdocs/source/<languageCode>/api/pipelines(don't hesitate to copy an existing file as template). - Link that file in
docs/source/<languageCode>/_toctree.ymlunder the API > Pipelines section. - Write a short overview of the diffusion model:
- Overview with paper & authors
- Paper abstract
- Tips and tricks and how to use it best
- Possible an end-to-end example of how to use it
- Add all the pipeline classes that should be linked in the diffusion model. These classes should be added using our Markdown syntax. By default as follows:
[[autodoc]] XXXPipeline
- all
- __call__
This will include every public method of the pipeline that is documented, as well as the __call__ method that is not documented by default. If you just want to add additional methods that are not documented, you can put the list of all methods to add in a list that contains all.
[[autodoc]] XXXPipeline
- all
- __call__
- enable_attention_slicing
- disable_attention_slicing
- enable_xformers_memory_efficient_attention
- disable_xformers_memory_efficient_attention
You can follow the same process to create a new scheduler under the docs/source/<languageCode>/api/schedulers folder.
Writing source documentation
Values that should be put in code should either be surrounded by backticks: `like so`. Note that argument names
and objects like True, None, or any strings should usually be put in code.
When mentioning a class, function, or method, it is recommended to use our syntax for internal links so that our tool adds a link to its documentation with this syntax: [`XXXClass`] or [`function`]. This requires the class or function to be in the main package.
If you want to create a link to some internal class or function, you need to
provide its path. For instance: [`pipelines.ImagePipelineOutput`]. This will be converted into a link with
pipelines.ImagePipelineOutput in the description. To get rid of the path and only keep the name of the object you are
linking to in the description, add a ~: [`~pipelines.ImagePipelineOutput`] will generate a link with ImagePipelineOutput in the description.
The same works for methods so you can either use [`XXXClass.method`] or [`~XXXClass.method`].
Defining arguments in a method
Arguments should be defined with the Args: (or Arguments: or Parameters:) prefix, followed by a line return and
an indentation. The argument should be followed by its type, with its shape if it is a tensor, a colon, and its
description:
Args:
n_layers (`int`): The number of layers of the model.
If the description is too long to fit in one line, another indentation is necessary before writing the description after the argument.
Here's an example showcasing everything so far:
Args:
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary.
Indices can be obtained using [`AlbertTokenizer`]. See [`~PreTrainedTokenizer.encode`] and
[`~PreTrainedTokenizer.__call__`] for details.
[What are input IDs?](https://huggingface.co/docs/transformers/main/en/glossary#input-ids)
For optional arguments or arguments with defaults we follow the following syntax: imagine we have a function with the following signature:
def my_function(x: str=None, a: float=3.14):
then its documentation should look like this:
Args:
x (`str`, *optional*):
This argument controls ...
a (`float`, *optional*, defaults to `3.14`):
This argument is used to ...
Note that we always omit the "defaults to `None`" when None is the default for any argument. Also note that even
if the first line describing your argument type and its default gets long, you can't break it on several lines. You can
however write as many lines as you want in the indented description (see the example above with input_ids).
Writing a multi-line code block
Multi-line code blocks can be useful for displaying examples. They are done between two lines of three backticks as usual in Markdown:
```
# first line of code
# second line
# etc
```
Writing a return block
The return block should be introduced with the Returns: prefix, followed by a line return and an indentation.
The first line should be the type of the return, followed by a line return. No need to indent further for the elements
building the return.
Here's an example of a single value return:
Returns:
`List[int]`: A list of integers in the range [0, 1] --- 1 for a special token, 0 for a sequence token.
Here's an example of a tuple return, comprising several objects:
Returns:
`tuple(torch.Tensor)` comprising various elements depending on the configuration ([`BertConfig`]) and inputs:
- ** loss** (*optional*, returned when `masked_lm_labels` is provided) `torch.Tensor` of shape `(1,)` --
Total loss is the sum of the masked language modeling loss and the next sequence prediction (classification) loss.
- **prediction_scores** (`torch.Tensor` of shape `(batch_size, sequence_length, config.vocab_size)`) --
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
Adding an image
Due to the rapidly growing repository, it is important to make sure that no files that would significantly weigh down the repository are added. This includes images, videos, and other non-text files. We prefer to leverage a hf.co hosted dataset like
the ones hosted on hf-internal-testing in which to place these files and reference
them by URL. We recommend putting them in the following dataset: huggingface/documentation-images.
If an external contribution, feel free to add the images to your PR and ask a Hugging Face member to migrate your images
to this dataset.
Styling the docstring
We have an automatic script running with the make style command that will make sure that:
- the docstrings fully take advantage of the line width
- all code examples are formatted using black, like the code of the Transformers library
This script may have some weird failures if you made a syntax mistake or if you uncover a bug. Therefore, it's
recommended to commit your changes before running make style, so you can revert the changes done by that script
easily.