Skip to content

Commit b6e5a28

Browse files
authored
Merge branch 'main' into wan-pipeline
2 parents 4bdfa35 + 5a47442 commit b6e5a28

Some content is hidden

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

41 files changed

+235
-188
lines changed

docs/source/en/modular_diffusers/loop_sequential_pipeline_blocks.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ specific language governing permissions and limitations under the License.
1212

1313
# LoopSequentialPipelineBlocks
1414

15-
[`~modular_pipelines.LoopSequentialPipelineBlocks`] are a multi-block type that composes other [`~modular_pipelines.ModularPipelineBlocks`] together in a loop. Data flows circularly, using `intermediate_inputs` and `intermediate_outputs`, and each block is run iteratively. This is typically used to create a denoising loop which is iterative by default.
15+
[`~modular_pipelines.LoopSequentialPipelineBlocks`] are a multi-block type that composes other [`~modular_pipelines.ModularPipelineBlocks`] together in a loop. Data flows circularly, using `inputs` and `intermediate_outputs`, and each block is run iteratively. This is typically used to create a denoising loop which is iterative by default.
1616

1717
This guide shows you how to create [`~modular_pipelines.LoopSequentialPipelineBlocks`].
1818

@@ -21,7 +21,6 @@ This guide shows you how to create [`~modular_pipelines.LoopSequentialPipelineBl
2121
[`~modular_pipelines.LoopSequentialPipelineBlocks`], is also known as the *loop wrapper* because it defines the loop structure, iteration variables, and configuration. Within the loop wrapper, you need the following variables.
2222

2323
- `loop_inputs` are user provided values and equivalent to [`~modular_pipelines.ModularPipelineBlocks.inputs`].
24-
- `loop_intermediate_inputs` are intermediate variables from the [`~modular_pipelines.PipelineState`] and equivalent to [`~modular_pipelines.ModularPipelineBlocks.intermediate_inputs`].
2524
- `loop_intermediate_outputs` are new intermediate variables created by the block and added to the [`~modular_pipelines.PipelineState`]. It is equivalent to [`~modular_pipelines.ModularPipelineBlocks.intermediate_outputs`].
2625
- `__call__` method defines the loop structure and iteration logic.
2726

@@ -90,4 +89,4 @@ Add more loop blocks to run within each iteration with [`~modular_pipelines.Loop
9089

9190
```py
9291
loop = LoopWrapper.from_blocks_dict({"block1": LoopBlock(), "block2": LoopBlock})
93-
```
92+
```

docs/source/en/modular_diffusers/pipeline_block.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,7 @@ A [`~modular_pipelines.ModularPipelineBlocks`] requires `inputs`, and `intermedi
3737
]
3838
```
3939

40-
- `intermediate_inputs` are values typically created from a previous block but it can also be directly provided if no preceding block generates them. Unlike `inputs`, `intermediate_inputs` can be modified.
41-
42-
Use `InputParam` to define `intermediate_inputs`.
43-
44-
```py
45-
user_intermediate_inputs = [
46-
InputParam(name="processed_image", type_hint="torch.Tensor", description="image that has been preprocessed and normalized"),
47-
]
48-
```
49-
50-
- `intermediate_outputs` are new values created by a block and added to the [`~modular_pipelines.PipelineState`]. The `intermediate_outputs` are available as `intermediate_inputs` for subsequent blocks or available as the final output from running the pipeline.
40+
- `intermediate_outputs` are new values created by a block and added to the [`~modular_pipelines.PipelineState`]. The `intermediate_outputs` are available as `inputs` for subsequent blocks or available as the final output from running the pipeline.
5141

5242
Use `OutputParam` to define `intermediate_outputs`.
5343

@@ -65,8 +55,8 @@ The intermediate inputs and outputs share data to connect blocks. They are acces
6555

6656
The computation a block performs is defined in the `__call__` method and it follows a specific structure.
6757

68-
1. Retrieve the [`~modular_pipelines.BlockState`] to get a local view of the `inputs` and `intermediate_inputs`.
69-
2. Implement the computation logic on the `inputs` and `intermediate_inputs`.
58+
1. Retrieve the [`~modular_pipelines.BlockState`] to get a local view of the `inputs`
59+
2. Implement the computation logic on the `inputs`.
7060
3. Update [`~modular_pipelines.PipelineState`] to push changes from the local [`~modular_pipelines.BlockState`] back to the global [`~modular_pipelines.PipelineState`].
7161
4. Return the components and state which becomes available to the next block.
7262

@@ -76,7 +66,7 @@ def __call__(self, components, state):
7666
block_state = self.get_block_state(state)
7767

7868
# Your computation logic here
79-
# block_state contains all your inputs and intermediate_inputs
69+
# block_state contains all your inputs
8070
# Access them like: block_state.image, block_state.processed_image
8171

8272
# Update the pipeline state with your updated block_states
@@ -112,4 +102,4 @@ def __call__(self, components, state):
112102
unet = components.unet
113103
vae = components.vae
114104
scheduler = components.scheduler
115-
```
105+
```

docs/source/en/modular_diffusers/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ from diffusers.modular_pipelines import ComponentsManager
183183
components = ComponentManager()
184184

185185
dd_pipeline = dd_blocks.init_pipeline("YiYiXu/modular-demo-auto", components_manager=components, collection="diffdiff")
186-
dd_pipeline.load_default_componenets(torch_dtype=torch.float16)
186+
dd_pipeline.load_componenets(torch_dtype=torch.float16)
187187
dd_pipeline.to("cuda")
188188
```
189189

docs/source/en/modular_diffusers/sequential_pipeline_blocks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ specific language governing permissions and limitations under the License.
1212

1313
# SequentialPipelineBlocks
1414

15-
[`~modular_pipelines.SequentialPipelineBlocks`] are a multi-block type that composes other [`~modular_pipelines.ModularPipelineBlocks`] together in a sequence. Data flows linearly from one block to the next using `intermediate_inputs` and `intermediate_outputs`. Each block in [`~modular_pipelines.SequentialPipelineBlocks`] usually represents a step in the pipeline, and by combining them, you gradually build a pipeline.
15+
[`~modular_pipelines.SequentialPipelineBlocks`] are a multi-block type that composes other [`~modular_pipelines.ModularPipelineBlocks`] together in a sequence. Data flows linearly from one block to the next using `inputs` and `intermediate_outputs`. Each block in [`~modular_pipelines.SequentialPipelineBlocks`] usually represents a step in the pipeline, and by combining them, you gradually build a pipeline.
1616

1717
This guide shows you how to connect two blocks into a [`~modular_pipelines.SequentialPipelineBlocks`].
1818

19-
Create two [`~modular_pipelines.ModularPipelineBlocks`]. The first block, `InputBlock`, outputs a `batch_size` value and the second block, `ImageEncoderBlock` uses `batch_size` as `intermediate_inputs`.
19+
Create two [`~modular_pipelines.ModularPipelineBlocks`]. The first block, `InputBlock`, outputs a `batch_size` value and the second block, `ImageEncoderBlock` uses `batch_size` as `inputs`.
2020

2121
<hfoptions id="sequential">
2222
<hfoption id="InputBlock">
@@ -110,4 +110,4 @@ Inspect the sub-blocks in [`~modular_pipelines.SequentialPipelineBlocks`] by cal
110110
```py
111111
print(blocks)
112112
print(blocks.doc)
113-
```
113+
```

examples/community/img2img_inpainting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def check_size(image, height, width):
4545
raise ValueError(f"Image size should be {height}x{width}, but got {h}x{w}")
4646

4747

48-
def overlay_inner_image(image, inner_image, paste_offset: Tuple[int] = (0, 0)):
48+
def overlay_inner_image(image, inner_image, paste_offset: Tuple[int, ...] = (0, 0)):
4949
inner_image = inner_image.convert("RGBA")
5050
image = image.convert("RGB")
5151

examples/community/matryoshka.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,16 +1966,21 @@ def __init__(
19661966
center_input_sample: bool = False,
19671967
flip_sin_to_cos: bool = True,
19681968
freq_shift: int = 0,
1969-
down_block_types: Tuple[str] = (
1969+
down_block_types: Tuple[str, ...] = (
19701970
"CrossAttnDownBlock2D",
19711971
"CrossAttnDownBlock2D",
19721972
"CrossAttnDownBlock2D",
19731973
"DownBlock2D",
19741974
),
19751975
mid_block_type: Optional[str] = "UNetMidBlock2DCrossAttn",
1976-
up_block_types: Tuple[str] = ("UpBlock2D", "CrossAttnUpBlock2D", "CrossAttnUpBlock2D", "CrossAttnUpBlock2D"),
1976+
up_block_types: Tuple[str, ...] = (
1977+
"UpBlock2D",
1978+
"CrossAttnUpBlock2D",
1979+
"CrossAttnUpBlock2D",
1980+
"CrossAttnUpBlock2D",
1981+
),
19771982
only_cross_attention: Union[bool, Tuple[bool]] = False,
1978-
block_out_channels: Tuple[int] = (320, 640, 1280, 1280),
1983+
block_out_channels: Tuple[int, ...] = (320, 640, 1280, 1280),
19791984
layers_per_block: Union[int, Tuple[int]] = 2,
19801985
downsample_padding: int = 1,
19811986
mid_block_scale_factor: float = 1,
@@ -2294,10 +2299,10 @@ def __init__(
22942299

22952300
def _check_config(
22962301
self,
2297-
down_block_types: Tuple[str],
2298-
up_block_types: Tuple[str],
2302+
down_block_types: Tuple[str, ...],
2303+
up_block_types: Tuple[str, ...],
22992304
only_cross_attention: Union[bool, Tuple[bool]],
2300-
block_out_channels: Tuple[int],
2305+
block_out_channels: Tuple[int, ...],
23012306
layers_per_block: Union[int, Tuple[int]],
23022307
cross_attention_dim: Union[int, Tuple[int]],
23032308
transformer_layers_per_block: Union[int, Tuple[int], Tuple[Tuple[int]]],

examples/community/pipeline_faithdiff_stable_diffusion_xl.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,16 +438,21 @@ def __init__(
438438
center_input_sample: bool = False,
439439
flip_sin_to_cos: bool = True,
440440
freq_shift: int = 0,
441-
down_block_types: Tuple[str] = (
441+
down_block_types: Tuple[str, ...] = (
442442
"CrossAttnDownBlock2D",
443443
"CrossAttnDownBlock2D",
444444
"CrossAttnDownBlock2D",
445445
"DownBlock2D",
446446
),
447447
mid_block_type: Optional[str] = "UNetMidBlock2DCrossAttn",
448-
up_block_types: Tuple[str] = ("UpBlock2D", "CrossAttnUpBlock2D", "CrossAttnUpBlock2D", "CrossAttnUpBlock2D"),
448+
up_block_types: Tuple[str, ...] = (
449+
"UpBlock2D",
450+
"CrossAttnUpBlock2D",
451+
"CrossAttnUpBlock2D",
452+
"CrossAttnUpBlock2D",
453+
),
449454
only_cross_attention: Union[bool, Tuple[bool]] = False,
450-
block_out_channels: Tuple[int] = (320, 640, 1280, 1280),
455+
block_out_channels: Tuple[int, ...] = (320, 640, 1280, 1280),
451456
layers_per_block: Union[int, Tuple[int]] = 2,
452457
downsample_padding: int = 1,
453458
mid_block_scale_factor: float = 1,

scripts/convert_sana_controlnet_to_diffusers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from diffusers import (
1111
SanaControlNetModel,
1212
)
13-
from diffusers.models.modeling_utils import load_model_dict_into_meta
13+
from diffusers.models.model_loading_utils import load_model_dict_into_meta
1414
from diffusers.utils.import_utils import is_accelerate_available
1515

1616

scripts/convert_sana_to_diffusers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
SanaTransformer2DModel,
2121
SCMScheduler,
2222
)
23-
from diffusers.models.modeling_utils import load_model_dict_into_meta
23+
from diffusers.models.model_loading_utils import load_model_dict_into_meta
2424
from diffusers.utils.import_utils import is_accelerate_available
2525

2626

scripts/convert_sd3_to_diffusers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from diffusers import AutoencoderKL, SD3Transformer2DModel
99
from diffusers.loaders.single_file_utils import convert_ldm_vae_checkpoint
10-
from diffusers.models.modeling_utils import load_model_dict_into_meta
10+
from diffusers.models.model_loading_utils import load_model_dict_into_meta
1111
from diffusers.utils.import_utils import is_accelerate_available
1212

1313

0 commit comments

Comments
 (0)