diff --git a/src/diffusers/modular_pipelines/modular_pipeline.py b/src/diffusers/modular_pipelines/modular_pipeline.py index 9bf1ddca3b98..b9dedcbc3552 100644 --- a/src/diffusers/modular_pipelines/modular_pipeline.py +++ b/src/diffusers/modular_pipelines/modular_pipeline.py @@ -515,6 +515,8 @@ def get_block_state(self, state: PipelineState) -> dict: for input_param in state_inputs: if input_param.name: value = state.get(input_param.name) + if input_param.required and value is None: + raise ValueError(f"Required input '{input_param.name}' is missing") if value is None: # if the value is None (not passed, or passed as None), the first block that reads it sets the # default at call time. For sequential blocks the default is already resolved at compile time @@ -522,9 +524,7 @@ def get_block_state(self, state: PipelineState) -> dict: # is only known at runtime: disagreeing branch defaults merge to None (see combine_inputs) and # the block that actually runs applies its own declared default here value = input_param.default - if input_param.required and value is None: - raise ValueError(f"Required input '{input_param.name}' is missing") - elif value is not None or (value is None and input_param.name not in data): + if value is not None or (value is None and input_param.name not in data): data[input_param.name] = value elif input_param.kwargs_type: