You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/modular_diffusers/modular_diffusers_states.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,20 +12,20 @@ specific language governing permissions and limitations under the License.
12
12
13
13
# Block states
14
14
15
-
Blocks rely on the [`PipelineState`] and [`BlockState`] data structures for communicating and sharing data.
15
+
Blocks rely on the [`~modular_pipelines.PipelineState`] and [`~modular_pipelines.BlockState`] data structures for communicating and sharing data.
16
16
17
17
| State | Description |
18
18
|-------|-------------|
19
-
|`PipelineState`| Maintains the overall data required for a pipeline's execution and allows blocks to read and update its data. |
20
-
|`BlockState`| Allows each block to perform its computation with the necessary data from `inputs` and `intermediate_inputs`|
19
+
|[`~modular_pipelines.PipelineState`]| Maintains the overall data required for a pipeline's execution and allows blocks to read and update its data. |
20
+
|[`~modular_pipelines.BlockState`]| Allows each block to perform its computation with the necessary data from `inputs` and `intermediate_inputs`|
21
21
22
22
This guide explains how states work and how they connect blocks.
23
23
24
24
## PipelineState
25
25
26
-
The [`PipelineState`] is a global state container for all pipeline blocks. It maintains the complete runtime state of the pipeline and provides a structured way for blocks to read from and write to shared data.
26
+
The [`~modular_pipelines.PipelineState`] is a global state container for all pipeline blocks. It maintains the complete runtime state of the pipeline and provides a structured way for blocks to read from and write to shared data.
27
27
28
-
There are two dict's in [`PipelineState`] for structuring data.
28
+
There are two dict's in [`~modular_pipelines.PipelineState`] for structuring data.
29
29
30
30
- The `inputs` dict is an **immutable** state containing a copy of user provided values. A value added to `inputs` cannot be changed. Blocks can read from `inputs` but cannot write to it.
31
31
- The `intermediates` dict is a **mutable** state containing variables that are passed between blocks and can be modified by them.
@@ -46,7 +46,7 @@ PipelineState(
46
46
47
47
## BlockState
48
48
49
-
The [`BlockState`] is a local view of the relevant variables, `inputs` and `intermediate_inputs`, that an individual pipeline block needs from [`PipelineState`] for performing it's computations.
49
+
The [`~modular_pipelines.BlockState`] is a local view of the relevant variables, `inputs` and `intermediate_inputs`, that an individual pipeline block needs from [`~modular_pipelines.PipelineState`] for performing it's computations.
50
50
51
51
You can access these variables directly as attributes like `block_state.image`.
52
52
@@ -56,7 +56,7 @@ BlockState(
56
56
)
57
57
```
58
58
59
-
When a block's `__call__` method is executed, it retrieves the [`BlockState`] with `self.get_block_state(state)`, performs it's operations, and updates [`PipelineState`] with `self.set_block_state(state, block_state)`.
59
+
When a block's `__call__` method is executed, it retrieves the [`BlockState`] with `self.get_block_state(state)`, performs it's operations, and updates [`~modular_pipelines.PipelineState`] with `self.set_block_state(state, block_state)`.
[`PipelineState`] and [`BlockState`] interaction is defined by a block's `inputs`, `intermediate_inputs`, and `intermediate_outputs`.
75
+
[`~modular_pipelines.PipelineState`] and [`BlockState`] interaction is defined by a block's `inputs`, `intermediate_inputs`, and `intermediate_outputs`.
76
76
77
-
-`inputs`, a block can modify an input - like `block_state.image` - but the change is local to the [`BlockState`] and won't affect the original image in [`PipelineState`].
78
-
-`intermediate_inputs`, is often values created from a previous block. When a block modifies `intermediate_inputs` - like `batch_size` - this change is reflected in both the [`BlockState`] and [`PipelineState`]. Any subsequent blocks are also affected.
77
+
-`inputs`, a block can modify an input - like `block_state.image` - but the change is local to the [`~modular_pipelines.BlockState`] and won't affect the original image in [`~modular_pipelines.PipelineState`].
78
+
-`intermediate_inputs`, is often values created from a previous block. When a block modifies `intermediate_inputs` - like `batch_size` - this change is reflected in both the [`~modular_pipelines.BlockState`] and [`~modular_pipelines.PipelineState`]. Any subsequent blocks are also affected.
79
79
80
80
If a previous block doesn't provide an `intermediate_inputs`, then the pipeline makes it available as a user input. However, the value is still a mutable intermediate state.
81
81
82
-
-`intermediate_outputs`, is a new variable that a block creates from `intermediate_inputs`. It is added to the [`PipelineState`]'s `intermediates` dict and available as an `intermediate_inputs` for subsequent blocks or accessed by users as a final output from the pipeline.
82
+
-`intermediate_outputs`, is a new variable that a block creates from `intermediate_inputs`. It is added to the [`~modular_pipelines.PipelineState`]'s `intermediates` dict and available as an `intermediate_inputs` for subsequent blocks or accessed by users as a final output from the pipeline.
83
83
84
-
If a variable is modified in `block_state` but not declared as an `intermediate_outputs`, it won't be added to [`PipelineState`].
84
+
If a variable is modified in `block_state` but not declared as an `intermediate_outputs`, it won't be added to [`~modular_pipelines.PipelineState`].
Copy file name to clipboardExpand all lines: docs/source/en/modular_diffusers/pipeline_block.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,20 +12,20 @@ specific language governing permissions and limitations under the License.
12
12
13
13
# PipelineBlock
14
14
15
-
[`PipelineBlock`] is the basic block for building a [`ModularPipeline`]. It defines what components, inputs/outputs, and computation a block should perform for a specific step in a pipeline. A [`PipelineBlock`] connects with other blocks, using [state](./modular_diffusers_states), to enable the modular construction of workflows.
15
+
[`~modular_pipelines.PipelineBlock`] is the basic block for building a [`ModularPipeline`]. It defines what components, inputs/outputs, and computation a block should perform for a specific step in a pipeline. A [`~modular_pipelines.PipelineBlock`] connects with other blocks, using [state](./modular_diffusers_states), to enable the modular construction of workflows.
16
16
17
-
A [`PipelineBlock`] on it's own can't be run to generate anything. It is a blueprint for what a step should do in a pipeline. To actually run and execute a pipeline, the [`PipelineBlock`] needs to be converted into a [`ModularPipeline`].
17
+
A [`~modular_pipelines.PipelineBlock`] on it's own can't be run to generate anything. It is a blueprint for what a step should do in a pipeline. To actually run and execute a pipeline, the [`~modular_pipelines.PipelineBlock`] needs to be converted into a [`ModularPipeline`].
18
18
19
-
This guide will show you how to create a [`PipelineBlock`].
19
+
This guide will show you how to create a [`~modular_pipelines.PipelineBlock`].
20
20
21
21
## Inputs and outputs
22
22
23
23
> [!TIP]
24
24
> Refer to the [Block states](./modular_diffusers_states) guide if you aren't familiar with how state works in Modular Diffusers.
25
25
26
-
A [`PipelineBlock`] requires `inputs`, `intermediate_inputs`, and `intermediate_outputs`.
26
+
A [`~modular_pipelines.PipelineBlock`] requires `inputs`, `intermediate_inputs`, and `intermediate_outputs`.
27
27
28
-
-`inputs` are values provided by a user and they are retrieved from the [`PipelineState`], which means `inputs` can't be modified. This is useful because some workflows resize an image, but the original image is still required. The [`PipelineState`] maintains the original image.
28
+
-`inputs` are values provided by a user and they are retrieved from the [`~modular_pipelines.PipelineState`], which means `inputs` can't be modified. This is useful because some workflows resize an image, but the original image is still required. The [`~modular_pipelines.PipelineState`] maintains the original image.
29
29
30
30
Use `InputParam` to define `inputs`.
31
31
@@ -47,7 +47,7 @@ A [`PipelineBlock`] requires `inputs`, `intermediate_inputs`, and `intermediate_
47
47
]
48
48
```
49
49
50
-
-`intermediate_outputs` are new values created by a block and added to the [`PipelineState`]. The `intermediate_outputs` are available as`intermediate_inputs`for subsequent blocks or available as the final output from running the pipeline.
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.
51
51
52
52
Use `OutputParam` to define `intermediate_outputs`.
53
53
@@ -65,9 +65,9 @@ The intermediate inputs and outputs work together to connect blocks by sharing d
65
65
66
66
The computation a block performs is defined in the `__call__` method which follows a specific structure.
67
67
68
-
1. Retrieve the [`BlockState`] to get a local view of the `inputs`and`intermediate_inputs` it needs from [`PipelineState`].
68
+
1. Retrieve the [`~modular_pipelines.BlockState`] to get a local view of the `inputs`and`intermediate_inputs` it needs from [`~modular_pipelines.PipelineState`].
69
69
2. Implement the computation logic on the `inputs`and`intermediate_inputs`.
70
-
3. Update [`PipelineState`] to push changes from the local [`BlockState`] back to the global [`PipelineState`].
70
+
3. Update [`~modular_pipelines.PipelineState`] to push changes from the local [`~modular_pipelines.BlockState`] back to the global [`~modular_pipelines.PipelineState`].
71
71
4. Return the components and state which becomes available to the next block.
The components and pipeline-level configs a block needs are specified in [`ComponentSpec`] and [`ConfigSpec`].
89
+
The components and pipeline-level configs a block needs are specified in [`ComponentSpec`] and [`~modular_pipelines.ConfigSpec`].
90
90
91
91
-[`ComponentSpec`] contains the expected components used by a block. You need the `name` of the component and ideally a `type_hint` that specifies exactly what the component is.
92
-
-[`ConfigSpec`] contains pipeline-level settings that control behavior across all blocks.
92
+
-[`~modular_pipelines.ConfigSpec`] contains pipeline-level settings that control behavior across all blocks.
0 commit comments