Skip to content

Commit 0ba183b

Browse files
Merge branch 'main' into fix/npu-rmsnorm-and-attn-mask-main
2 parents 2152d96 + 6f2010e commit 0ba183b

377 files changed

Lines changed: 4300 additions & 4144 deletions

File tree

Some content is hidden

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

.ai/AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Strive to write code as simple and explicit as possible.
3737
Task-specific guides live in `.ai/skills/` and are loaded on demand by AI agents. Available skills include:
3838

3939
- [model-integration](./skills/model-integration/SKILL.md) (adding/converting pipelines)
40+
- [custom-blocks](./skills/custom-blocks/SKILL.md) (packaging a `ModularPipelineBlocks` subclass for the Hub)
41+
- [diffusers-cli](./skills/diffusers-cli/SKILL.md) (running pipelines, inspecting schemas, and using the Diffusers CLI)
4042
- [self-review](./skills/self-review/SKILL.md) (pre-PR self-review against the project rules)
4143

4244
## Self-review before a PR

.ai/modular.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,19 @@ OutputParam(
235235

236236
If a template's predefined description doesn't fit (e.g. the `"latents"` output template means "Denoised latents", which is wrong for the noisy latents out of a prepare-latents step) — drop the template and declare the field directly with an accurate description. See gotcha #5.
237237

238+
**Declare defaults in the `InputParam`, not inside `__call__`.**
239+
240+
```python
241+
# yes
242+
InputParam(name="num_frames", type_hint=int, default=189)
243+
244+
# no — works, but the assembled pipeline is not aware of it
245+
if block_state.num_frames is None:
246+
block_state.num_frames = 189
247+
```
248+
249+
A declared default is part of the block's contract, so the assembled pipeline is aware of it: the generated docstring shows it and `default_call_parameters` reports it. Resolved inside the body instead, the input renders as `*optional*` with no default, and nothing at the pipeline level can report what the block will actually do. Don't worry about branches of a conditional blockset declaring different defaults for the same input — each branch resolves its own at runtime. Resolve inside `__call__` only when the default is *computed* — derived from other inputs or component config (`height = components.default_sample_size * components.vae_scale_factor`). And when several blocks in a sequence share an input, declare the same default on each (or only on the first block that reads it): in a sequence the input is one shared value, so disagreeing declarations are silently resolved first-block-wins.
250+
238251
## ComponentSpec patterns
239252

240253
```python
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: New Model Request Reply
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
7+
jobs:
8+
reply:
9+
name: Point new model requests at Modular Diffusers
10+
# Match the heading the issue form renders for its first field rather than a label: template
11+
# labels are applied after the issue is created, so `github.event.issue.labels` is empty here.
12+
# Keep this string in sync with .github/ISSUE_TEMPLATE/new-model-addition.yml.
13+
if: >-
14+
github.repository == 'huggingface/diffusers' &&
15+
contains(github.event.issue.body, '### Model/Pipeline/Scheduler description')
16+
runs-on: ubuntu-latest
17+
permissions:
18+
issues: write
19+
steps:
20+
- name: Post Modular Diffusers guidance
21+
env:
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
GH_REPO: ${{ github.repository }}
24+
ISSUE_NUMBER: ${{ github.event.issue.number }}
25+
BODY: |
26+
Thanks for the request!
27+
28+
**How new model support works in Diffusers**
29+
30+
We're a small team, and our review queue shouldn't be what decides whether a model is usable in Diffusers. With [Modular Diffusers](https://huggingface.co/docs/diffusers/modular_diffusers/overview), a pipeline can live as remote code in any Hub repo and load straight from there with `from_pretrained`.
31+
32+
🛠️ **Want to bring this model to Diffusers?**
33+
34+
Please start with a Hub repo — you don't need anything from us to do that, and people can use it immediately. From there we decide how to support it: we might work with the authors, upstream an existing community version, or just point people at the one on the Hub. The pipelines we integrate are usually the ones people are already running.
35+
36+
Tag `@asomoza` when you have something to share — we'll give feedback on the implementation, help get it in front of people, and add the ones we like to our hand-picked [Modular Pipelines](https://huggingface.co/collections/diffusers/modular-pipelines) collection. Tell us where you hit friction along the way, too: confusing APIs, missing docs, bugs. That feedback is worth as much to us as the pipeline.
37+
38+
👋 **Are you an author of the model?** We'd love to hear from you — comment here and we'll help you pick the path that fits.
39+
40+
📚 [Quickstart](https://huggingface.co/docs/diffusers/modular_diffusers/quickstart) · [Building custom blocks](https://huggingface.co/docs/diffusers/modular_diffusers/custom_blocks) — template repo, and how to publish to the Hub · [Modular Pipelines](https://huggingface.co/collections/diffusers/modular-pipelines) and [Custom Blocks](https://huggingface.co/collections/diffusers/modular-diffusers-custom-blocks) — examples to crib from
41+
42+
*This is an automated message.*
43+
run: gh issue comment "$ISSUE_NUMBER" --body "$BODY"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Generating outputs is super easy with 🤗 Diffusers. To generate an image from
6565
from diffusers import DiffusionPipeline
6666
import torch
6767

68-
pipeline = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch.float16)
68+
pipeline = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", dtype=torch.float16)
6969
pipeline.to("cuda")
7070
pipeline("An image of a squirrel in Picasso style").images[0]
7171
```

benchmarks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ BenchmarkScenario(
5555
model_cls=FluxTransformer2DModel,
5656
model_init_kwargs={
5757
"pretrained_model_name_or_path": CKPT_ID,
58-
"torch_dtype": torch.bfloat16,
58+
"dtype": torch.bfloat16,
5959
"subfolder": "transformer",
6060
"quantization_config": BitsAndBytesConfig(load_in_8bit=True),
6161
},

docs/source/en/_toctree.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@
184184
title: NVIDIA ModelOpt
185185
- local: quantization/autoround
186186
title: AutoRound
187+
- local: quantization/sdnq
188+
title: SDNQ
187189
title: Quantization
188190
- isExpanded: false
189191
sections:
@@ -232,8 +234,6 @@
232234
title: How to contribute?
233235
- local: conceptual/ethical_guidelines
234236
title: Diffusers' Ethical Guidelines
235-
- local: conceptual/evaluation
236-
title: Evaluating Diffusion Models
237237
title: Resources
238238
- isExpanded: false
239239
sections:

docs/source/en/advanced_inference/outpaint.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ Load the inpainting ControlNet, ZoeDepth model, VAE and pass them to the [`Stabl
111111
```py
112112
controlnets = [
113113
ControlNetModel.from_pretrained(
114-
"destitech/controlnet-inpaint-dreamer-sdxl", torch_dtype=torch.float16, variant="fp16"
114+
"destitech/controlnet-inpaint-dreamer-sdxl", dtype=torch.float16, variant="fp16"
115115
),
116116
ControlNetModel.from_pretrained(
117-
"diffusers/controlnet-zoe-depth-sdxl-1.0", torch_dtype=torch.float16
117+
"diffusers/controlnet-zoe-depth-sdxl-1.0", dtype=torch.float16
118118
),
119119
]
120-
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16).to("cuda")
120+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", dtype=torch.float16).to("cuda")
121121
pipeline = StableDiffusionXLControlNetPipeline.from_pretrained(
122-
"SG161222/RealVisXL_V4.0", torch_dtype=torch.float16, variant="fp16", controlnet=controlnets, vae=vae
122+
"SG161222/RealVisXL_V4.0", dtype=torch.float16, variant="fp16", controlnet=controlnets, vae=vae
123123
).to("cuda")
124124

125125
def generate_image(prompt, negative_prompt, inpaint_image, zoe_image, seed: int = None):
@@ -173,7 +173,7 @@ Now that you have an initial outpainted image, load the [`StableDiffusionXLInpai
173173
```py
174174
pipeline = StableDiffusionXLInpaintPipeline.from_pretrained(
175175
"OzzyGT/RealVisXL_V4.0_inpainting",
176-
torch_dtype=torch.float16,
176+
dtype=torch.float16,
177177
variant="fp16",
178178
vae=vae,
179179
).to("cuda")

docs/source/en/api/models/allegro_transformer3d.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The model can be loaded with the following code snippet.
1818
```python
1919
from diffusers import AllegroTransformer3DModel
2020

21-
transformer = AllegroTransformer3DModel.from_pretrained("rhymes-ai/Allegro", subfolder="transformer", torch_dtype=torch.bfloat16).to("cuda")
21+
transformer = AllegroTransformer3DModel.from_pretrained("rhymes-ai/Allegro", subfolder="transformer", dtype=torch.bfloat16).to("cuda")
2222
```
2323

2424
## AllegroTransformer3DModel

docs/source/en/api/models/autoencoder_dc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Load a model in Diffusers format with [`~ModelMixin.from_pretrained`].
3636
```python
3737
from diffusers import AutoencoderDC
3838

39-
ae = AutoencoderDC.from_pretrained("mit-han-lab/dc-ae-f32c32-sana-1.0-diffusers", torch_dtype=torch.float32).to("cuda")
39+
ae = AutoencoderDC.from_pretrained("mit-han-lab/dc-ae-f32c32-sana-1.0-diffusers", dtype=torch.float32).to("cuda")
4040
```
4141

4242
## Load a model in Diffusers via `from_single_file`

docs/source/en/api/models/autoencoder_kl_hunyuan_video.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The model can be loaded with the following code snippet.
1818
```python
1919
from diffusers import AutoencoderKLHunyuanVideo
2020

21-
vae = AutoencoderKLHunyuanVideo.from_pretrained("hunyuanvideo-community/HunyuanVideo", subfolder="vae", torch_dtype=torch.float16)
21+
vae = AutoencoderKLHunyuanVideo.from_pretrained("hunyuanvideo-community/HunyuanVideo", subfolder="vae", dtype=torch.float16)
2222
```
2323

2424
## AutoencoderKLHunyuanVideo

0 commit comments

Comments
 (0)