Skip to content

Commit 4d89a88

Browse files
yiyixuxuclaudesayakpaul
authored
[modular] detect stale auto docstrings in CI + regenerate current ones (#14241)
* Regenerate stale modular auto docstrings Mechanical output of `python utils/modular_auto_docstring.py src/diffusers/modular_pipelines --fix_and_overwrite` on current main. These docstrings drifted because the CI check only verifies a docstring exists, not that its content matches the current block declarations. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Make auto docstring check detect stale content, not just missing docstrings Check mode now regenerates each # auto_docstring docstring the same way --fix_and_overwrite does (generate -> insert -> ruff/doc-builder format, on a temp copy) and compares with the checked-in file, reporting the stale classes. Works like check_copies: forgetting to run the fixer now fails CI on the PR that caused the drift, including when the causing change is in another file (leaf block declarations, templates, specs). The check now imports diffusers to evaluate doc properties, so the check_auto_docs CI job moves to the torch container with the test job's dependency install. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
1 parent 6afdfd9 commit 4d89a88

14 files changed

Lines changed: 198 additions & 119 deletions

.github/workflows/pr_modular_tests.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,19 @@ jobs:
8686
run: |
8787
echo "Repo consistency check failed. Please ensure the right dependency versions are installed with 'pip install -e .[quality]' and run 'make fix-copies'" >> $GITHUB_STEP_SUMMARY
8888
check_auto_docs:
89-
runs-on: ubuntu-22.04
89+
# the check regenerates each docstring from the block declarations, which requires importing diffusers —
90+
# so this job runs in the torch container rather than a lint-only environment
91+
runs-on:
92+
group: aws-highmemory-32-plus
93+
container:
94+
image: diffusers/diffusers-pytorch-cpu
9095
steps:
9196
- uses: actions/checkout@v6
92-
- name: Set up Python
93-
uses: actions/setup-python@v6
94-
with:
95-
python-version: "3.10"
9697
- name: Install dependencies
9798
run: |
98-
pip install --upgrade pip
99-
pip install .[quality]
99+
printf 'tokenizers<0.23.0\ntorch==2.10.0\ntorchvision==0.25.0\ntorchaudio==2.10.0\n' > "$UV_OVERRIDE"
100+
uv pip install -e ".[quality]"
101+
uv pip uninstall transformers huggingface_hub && UV_PRERELEASE=allow uv pip install -U transformers@git+https://github.com/huggingface/transformers.git
100102
- name: Check auto docs
101103
run: make modular-autodoctrings
102104
- name: Check if failure

src/diffusers/modular_pipelines/anima/modular_blocks_anima.py

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ def outputs(self):
128128
# auto_docstring
129129
class AnimaImg2ImgCoreDenoiseStep(SequentialPipelineBlocks):
130130
"""
131-
Denoise block for Anima image-to-image generation. Expects ``image_latents`` already in state (produced by
132-
``AnimaImg2ImgVaeEncoderStep`` upstream).
131+
Denoise block for Anima image-to-image generation. Uses image_latents already in state from
132+
AnimaImg2ImgVaeEncoderStep.
133133
134134
Components:
135135
text_conditioner (`AnimaTextConditioner`) transformer (`CosmosTransformer3DModel`) scheduler
@@ -155,7 +155,7 @@ class AnimaImg2ImgCoreDenoiseStep(SequentialPipelineBlocks):
155155
num_images_per_prompt (`int`, *optional*, defaults to 1):
156156
The number of images to generate per prompt.
157157
image_latents (`Tensor`):
158-
Encoded image latents from ``AnimaImg2ImgVaeEncoderStep``.
158+
image latents used to guide the image generation. Can be generated from vae_encoder step.
159159
height (`int`, *optional*):
160160
The height in pixels of the generated image.
161161
width (`int`, *optional*):
@@ -165,7 +165,7 @@ class AnimaImg2ImgCoreDenoiseStep(SequentialPipelineBlocks):
165165
sigmas (`list`, *optional*):
166166
Custom sigmas for the denoising process.
167167
strength (`float`, *optional*, defaults to 0.9):
168-
Strength for img2img transformation.
168+
Strength for img2img/inpainting.
169169
generator (`Generator`, *optional*):
170170
Torch generator for deterministic generation.
171171
latents (`Tensor`, *optional*):
@@ -203,15 +203,13 @@ def outputs(self):
203203
# auto_docstring
204204
class AnimaAutoCoreDenoiseStep(AutoPipelineBlocks):
205205
"""
206-
Denoise step that selects between text-to-image and image-to-image denoising based on whether ``image_latents`` is
207-
present in state. - `AnimaCoreDenoiseStep` (text2image) is used when no ``image_latents`` are present. -
208-
`AnimaImg2ImgCoreDenoiseStep` (img2img) is used when ``image_latents`` are present (set upstream by
209-
``AnimaAutoVaeImageEncoderStep``).
206+
Denoise step that selects between text-to-image and image-to-image denoising based on whether image_latents is
207+
present in state. - `AnimaCoreDenoiseStep` (text2image) is used when no image_latents are present. -
208+
`AnimaImg2ImgCoreDenoiseStep` (img2img) is used when image_latents are present.
210209
211210
Components:
212-
text_conditioner (`AnimaTextConditioner`) transformer (`CosmosTransformer3DModel`) vae
213-
(`AutoencoderKLQwenImage`) scheduler (`FlowMatchEulerDiscreteScheduler`) image_processor
214-
(`VaeImageProcessor`) guider (`ClassifierFreeGuidance`)
211+
text_conditioner (`AnimaTextConditioner`) transformer (`CosmosTransformer3DModel`) scheduler
212+
(`FlowMatchEulerDiscreteScheduler`) guider (`ClassifierFreeGuidance`)
215213
216214
Inputs:
217215
qwen_prompt_embeds (`Tensor`):
@@ -233,21 +231,21 @@ class AnimaAutoCoreDenoiseStep(AutoPipelineBlocks):
233231
num_images_per_prompt (`int`, *optional*, defaults to 1):
234232
The number of images to generate per prompt.
235233
image_latents (`Tensor`, *optional*):
236-
Encoded image latents. When present in state, img2img denoising is selected.
234+
image latents used to guide the image generation. Can be generated from vae_encoder step.
237235
height (`int`, *optional*):
238236
The height in pixels of the generated image.
239237
width (`int`, *optional*):
240238
The width in pixels of the generated image.
241-
latents (`Tensor`, *optional*):
242-
Pre-generated noisy latents for image generation.
243-
generator (`Generator`, *optional*):
244-
Torch generator for deterministic generation.
245-
num_inference_steps (`int`, *optional*, defaults to 50):
239+
num_inference_steps (`int`):
246240
The number of denoising steps.
247241
sigmas (`list`, *optional*):
248242
Custom sigmas for the denoising process.
249243
strength (`float`, *optional*, defaults to 0.9):
250-
Strength for img2img transformation.
244+
Strength for img2img/inpainting.
245+
generator (`Generator`, *optional*):
246+
Torch generator for deterministic generation.
247+
latents (`Tensor`):
248+
Pre-generated noisy latents for image generation.
251249
**denoiser_input_fields (`None`, *optional*):
252250
The conditional model inputs for the Anima denoiser.
253251
@@ -273,26 +271,29 @@ def description(self) -> str:
273271
# auto_docstring
274272
class AnimaAutoVaeImageEncoderStep(AutoPipelineBlocks):
275273
"""
276-
VAE Image Encoder step that encodes the input image to produce ``image_latents``. This step is skipped when no
277-
image is provided (text-to-image workflow).
274+
VAE Image Encoder step that encodes the input image to produce image_latents. Skipped when no image is provided
275+
(text-to-image workflow).
278276
279277
Components:
280278
vae (`AutoencoderKLQwenImage`) image_processor (`VaeImageProcessor`)
281279
282280
Inputs:
283-
image (`Image`, *optional*):
284-
Input image for image-to-image generation. When provided, the image is encoded to ``image_latents``. When
285-
not provided, this step is skipped.
281+
image (`Image | list`, *optional*):
282+
Reference image(s) for denoising. Can be a single image or list of images.
286283
height (`int`, *optional*):
287-
Height of the output image.
284+
The height in pixels of the generated image.
288285
width (`int`, *optional*):
289-
Width of the output image.
286+
The width in pixels of the generated image.
290287
generator (`Generator`, *optional*):
291288
Torch generator for deterministic generation.
292289
293290
Outputs:
294291
image_latents (`Tensor`):
295-
Encoded image latents used by ``AnimaAutoCoreDenoiseStep`` to trigger img2img denoising.
292+
Encoded image latents.
293+
height (`int`):
294+
Image height used for generation.
295+
width (`int`):
296+
Image width used for generation.
296297
"""
297298

298299
block_classes = [AnimaImg2ImgVaeEncoderStep]
@@ -314,13 +315,13 @@ class AnimaAutoBlocks(SequentialPipelineBlocks):
314315
315316
Supported workflows:
316317
- `text2image`: requires `prompt`
317-
- `img2img`: requires `prompt`, `image`
318+
- `img2img`: requires `image`, `prompt`
318319
319320
Components:
320321
text_encoder (`Qwen3Model`) tokenizer (`Qwen2Tokenizer`) t5_tokenizer (`T5Tokenizer`) guider
321-
(`ClassifierFreeGuidance`) text_conditioner (`AnimaTextConditioner`) transformer (`CosmosTransformer3DModel`)
322-
scheduler (`FlowMatchEulerDiscreteScheduler`) vae (`AutoencoderKLQwenImage`) image_processor
323-
(`VaeImageProcessor`)
322+
(`ClassifierFreeGuidance`) vae (`AutoencoderKLQwenImage`) image_processor (`VaeImageProcessor`)
323+
text_conditioner (`AnimaTextConditioner`) transformer (`CosmosTransformer3DModel`) scheduler
324+
(`FlowMatchEulerDiscreteScheduler`)
324325
325326
Inputs:
326327
prompt (`str`):
@@ -329,24 +330,26 @@ class AnimaAutoBlocks(SequentialPipelineBlocks):
329330
The prompt or prompts not to guide the image generation.
330331
max_sequence_length (`int`, *optional*, defaults to 512):
331332
Maximum sequence length for prompt encoding.
332-
num_images_per_prompt (`int`, *optional*, defaults to 1):
333-
The number of images to generate per prompt.
334333
image (`Image | list`, *optional*):
335-
Reference image(s) for image-to-image generation. When provided, img2img workflow is used.
334+
Reference image(s) for denoising. Can be a single image or list of images.
336335
height (`int`, *optional*):
337336
The height in pixels of the generated image.
338337
width (`int`, *optional*):
339338
The width in pixels of the generated image.
340-
latents (`Tensor`, *optional*):
341-
Pre-generated noisy latents for image generation.
342339
generator (`Generator`, *optional*):
343340
Torch generator for deterministic generation.
344-
num_inference_steps (`int`, *optional*, defaults to 50):
341+
num_images_per_prompt (`int`, *optional*, defaults to 1):
342+
The number of images to generate per prompt.
343+
image_latents (`Tensor`, *optional*):
344+
image latents used to guide the image generation. Can be generated from vae_encoder step.
345+
num_inference_steps (`int`):
345346
The number of denoising steps.
346347
sigmas (`list`, *optional*):
347348
Custom sigmas for the denoising process.
348349
strength (`float`, *optional*, defaults to 0.9):
349-
How much to transform the reference image (img2img only).
350+
Strength for img2img/inpainting.
351+
latents (`Tensor`):
352+
Pre-generated noisy latents for image generation.
350353
**denoiser_input_fields (`None`, *optional*):
351354
The conditional model inputs for the Anima denoiser.
352355
output_type (`str`, *optional*, defaults to pil):

src/diffusers/modular_pipelines/cosmos/modular_blocks_cosmos3.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ class Cosmos3AutoTextEncoderStep(AutoPipelineBlocks):
123123
Components:
124124
video_processor (`VideoProcessor`) text_tokenizer (`AutoTokenizer`)
125125
126+
Configs:
127+
default_use_system_prompt (default: True) enable_safety_checker (default: True)
128+
126129
Inputs:
127130
control_videos (`dict`, *optional*):
128131
Mapping of hint name (edge/blur/depth/seg/wsm) to the control video for that modality.
@@ -140,9 +143,8 @@ class Cosmos3AutoTextEncoderStep(AutoPipelineBlocks):
140143
The text prompt that guides Cosmos3 generation.
141144
negative_prompt (`str`, *optional*):
142145
The negative text prompt used for classifier-free guidance.
143-
use_system_prompt (`bool`, *optional*):
144-
Whether to prepend the system prompt. Defaults to the pipeline configuration for standard and action
145-
workflows and to True for transfer.
146+
use_system_prompt (`bool`, *optional*, defaults to True):
147+
Whether to prepend the Cosmos3 transfer system prompt.
146148
action (`CosmosActionCondition`, *optional*):
147149
Action-conditioning metadata and its reference visual input.
148150
fps (`float`, *optional*, defaults to 24.0):
@@ -368,6 +370,9 @@ class Cosmos3VisionCoreDenoiseStep(SequentialPipelineBlocks):
368370
Components:
369371
transformer (`Cosmos3OmniTransformer`) scheduler (`UniPCMultistepScheduler`)
370372
373+
Configs:
374+
use_native_flow_schedule (default: False)
375+
371376
Inputs:
372377
cond_input_ids (`None`):
373378
Token IDs for the conditional prompt.
@@ -436,6 +441,9 @@ class Cosmos3VisionSoundCoreDenoiseStep(SequentialPipelineBlocks):
436441
Components:
437442
transformer (`Cosmos3OmniTransformer`) scheduler (`UniPCMultistepScheduler`)
438443
444+
Configs:
445+
use_native_flow_schedule (default: False)
446+
439447
Inputs:
440448
cond_input_ids (`None`):
441449
Token IDs for the conditional prompt.
@@ -517,6 +525,9 @@ class Cosmos3VisionActionCoreDenoiseStep(SequentialPipelineBlocks):
517525
Components:
518526
transformer (`Cosmos3OmniTransformer`) scheduler (`UniPCMultistepScheduler`)
519527
528+
Configs:
529+
use_native_flow_schedule (default: False)
530+
520531
Inputs:
521532
cond_input_ids (`None`):
522533
Token IDs for the conditional prompt.
@@ -602,6 +613,9 @@ class Cosmos3VisionSoundActionCoreDenoiseStep(SequentialPipelineBlocks):
602613
Components:
603614
transformer (`Cosmos3OmniTransformer`) scheduler (`UniPCMultistepScheduler`)
604615
616+
Configs:
617+
use_native_flow_schedule (default: False)
618+
605619
Inputs:
606620
cond_input_ids (`None`):
607621
Token IDs for the conditional prompt.
@@ -962,6 +976,9 @@ class Cosmos3AutoCoreDenoiseStep(ConditionalPipelineBlocks):
962976
transformer (`Cosmos3OmniTransformer`) vae (`AutoencoderKLWan`) video_processor (`VideoProcessor`) scheduler
963977
(`UniPCMultistepScheduler`)
964978
979+
Configs:
980+
use_native_flow_schedule (default: False)
981+
965982
Inputs:
966983
cond_input_ids (`None`):
967984
Token IDs for the conditional prompt.
@@ -1149,6 +1166,10 @@ class Cosmos3OmniBlocks(SequentialPipelineBlocks):
11491166
(`Cosmos3OmniTransformer`) scheduler (`UniPCMultistepScheduler`) sound_tokenizer
11501167
(`Cosmos3AVAEAudioTokenizer`)
11511168
1169+
Configs:
1170+
default_use_system_prompt (default: True) enable_safety_checker (default: True) use_native_flow_schedule
1171+
(default: False)
1172+
11521173
Inputs:
11531174
control_videos (`dict`, *optional*):
11541175
Mapping of hint name (edge/blur/depth/seg/wsm) to the control video for that modality.
@@ -1166,9 +1187,8 @@ class Cosmos3OmniBlocks(SequentialPipelineBlocks):
11661187
The text prompt that guides Cosmos3 generation.
11671188
negative_prompt (`str`, *optional*):
11681189
The negative text prompt used for classifier-free guidance.
1169-
use_system_prompt (`bool`, *optional*):
1170-
Whether to prepend the system prompt. Defaults to the pipeline configuration for standard and action
1171-
workflows and to True for transfer.
1190+
use_system_prompt (`bool`, *optional*, defaults to True):
1191+
Whether to prepend the Cosmos3 transfer system prompt.
11721192
action (`CosmosActionCondition`, *optional*):
11731193
Action-conditioning metadata and its reference visual input.
11741194
fps (`float`, *optional*, defaults to 24.0):

src/diffusers/modular_pipelines/cosmos/modular_blocks_cosmos3_distilled.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ class Cosmos3DistilledBlocks(SequentialPipelineBlocks):
165165
(`Cosmos3OmniTransformer`) scheduler (`FlowMatchEulerDiscreteScheduler`)
166166
167167
Configs:
168-
is_distilled (default: True) distilled_sigmas (default: None)
168+
default_use_system_prompt (default: True) enable_safety_checker (default: True) is_distilled (default: True)
169+
distilled_sigmas (default: None)
169170
170171
Inputs:
171172
prompt (`str`):

src/diffusers/modular_pipelines/ernie_image/modular_blocks_ernie_image.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ErnieImageAutoPromptEnhancerStep(ConditionalPipelineBlocks):
3636
- If `use_pe` is `None` or `False`, the step is skipped.
3737
3838
Components:
39-
pe (`AutoModelForCausalLM`) pe_tokenizer (`AutoTokenizer`)
39+
pe (`Ministral3ForCausalLM`) pe_tokenizer (`AutoTokenizer`)
4040
4141
Inputs:
4242
prompt (`str`, *optional*):
@@ -140,9 +140,10 @@ class ErnieImageAutoBlocks(SequentialPipelineBlocks):
140140
- `text2image`: requires `prompt`
141141
142142
Components:
143-
pe (`AutoModelForCausalLM`) pe_tokenizer (`AutoTokenizer`) text_encoder (`AutoModel`) tokenizer
143+
pe (`Ministral3ForCausalLM`) pe_tokenizer (`AutoTokenizer`) text_encoder (`Mistral3Model`) tokenizer
144144
(`AutoTokenizer`) guider (`ClassifierFreeGuidance`) transformer (`ErnieImageTransformer2DModel`) scheduler
145145
(`FlowMatchEulerDiscreteScheduler`) vae (`AutoencoderKLFlux2`) pachifier (`ErnieImagePachifier`)
146+
image_processor (`VaeImageProcessor`)
146147
147148
Inputs:
148149
prompt (`str`, *optional*):

src/diffusers/modular_pipelines/flux/modular_blocks_flux.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class FluxAutoBlocks(SequentialPipelineBlocks):
521521
522522
Components:
523523
text_encoder (`CLIPTextModel`) tokenizer (`CLIPTokenizer`) text_encoder_2 (`T5EncoderModel`) tokenizer_2
524-
(`T5TokenizerFast`) image_processor (`VaeImageProcessor`) vae (`AutoencoderKL`) scheduler
524+
(`T5Tokenizer`) image_processor (`VaeImageProcessor`) vae (`AutoencoderKL`) scheduler
525525
(`FlowMatchEulerDiscreteScheduler`) transformer (`FluxTransformer2DModel`)
526526
527527
Inputs:

src/diffusers/modular_pipelines/flux/modular_blocks_flux_kontext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ class FluxKontextAutoBlocks(SequentialPipelineBlocks):
521521
522522
Components:
523523
text_encoder (`CLIPTextModel`) tokenizer (`CLIPTokenizer`) text_encoder_2 (`T5EncoderModel`) tokenizer_2
524-
(`T5TokenizerFast`) image_processor (`VaeImageProcessor`) vae (`AutoencoderKL`) scheduler
524+
(`T5Tokenizer`) image_processor (`VaeImageProcessor`) vae (`AutoencoderKL`) scheduler
525525
(`FlowMatchEulerDiscreteScheduler`) transformer (`FluxTransformer2DModel`)
526526
527527
Inputs:

src/diffusers/modular_pipelines/flux2/modular_blocks_flux2_klein.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,8 @@ class Flux2KleinAutoBlocks(SequentialPipelineBlocks):
330330
- `image_conditioned`: requires `image`, `prompt`
331331
332332
Components:
333-
text_encoder (`Qwen3ForCausalLM`) tokenizer (`Qwen2TokenizerFast`) image_processor (`Flux2ImageProcessor`)
334-
vae (`AutoencoderKLFlux2`) scheduler (`FlowMatchEulerDiscreteScheduler`) transformer
335-
(`Flux2Transformer2DModel`)
333+
text_encoder (`Qwen3ForCausalLM`) tokenizer (`Qwen2Tokenizer`) image_processor (`Flux2ImageProcessor`) vae
334+
(`AutoencoderKLFlux2`) scheduler (`FlowMatchEulerDiscreteScheduler`) transformer (`Flux2Transformer2DModel`)
336335
337336
Configs:
338337
is_distilled (default: True)

src/diffusers/modular_pipelines/flux2/modular_blocks_flux2_klein_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ class Flux2KleinBaseAutoBlocks(SequentialPipelineBlocks):
343343
- `image_conditioned`: requires `image`, `prompt`
344344
345345
Components:
346-
text_encoder (`Qwen3ForCausalLM`) tokenizer (`Qwen2TokenizerFast`) guider (`ClassifierFreeGuidance`)
346+
text_encoder (`Qwen3ForCausalLM`) tokenizer (`Qwen2Tokenizer`) guider (`ClassifierFreeGuidance`)
347347
image_processor (`Flux2ImageProcessor`) vae (`AutoencoderKLFlux2`) scheduler
348348
(`FlowMatchEulerDiscreteScheduler`) transformer (`Flux2Transformer2DModel`)
349349

0 commit comments

Comments
 (0)