Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/diffusers/modular_pipelines/cosmos/before_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ def expected_configs(self) -> list[ConfigSpec]:
@property
def inputs(self) -> list[InputParam]:
return [
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
]

@property
Expand Down Expand Up @@ -1221,7 +1221,7 @@ def expected_components(self) -> list[ComponentSpec]:

@property
def inputs(self) -> list[InputParam]:
return [InputParam.template("num_inference_steps", required=True)]
return [InputParam.template("num_inference_steps")]

@property
def intermediate_outputs(self) -> list[OutputParam]:
Expand Down
2 changes: 1 addition & 1 deletion src/diffusers/modular_pipelines/cosmos/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def loop_expected_components(self) -> list[ComponentSpec]:
def loop_inputs(self) -> list[InputParam]:
return [
InputParam.template("timesteps", required=True),
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
InputParam(
name="num_warmup_steps", type_hint=int, required=True, description="Number of scheduler warmup steps."
),
Expand Down
4 changes: 2 additions & 2 deletions src/diffusers/modular_pipelines/krea2/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def expected_components(self) -> list[ComponentSpec]:
def inputs(self) -> list[InputParam]:
return [
InputParam(name="latents", required=True, type_hint=torch.Tensor, description="Packed image latents."),
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
InputParam(
name="prompt_embeds",
required=True,
Expand Down Expand Up @@ -256,7 +256,7 @@ def loop_inputs(self) -> list[InputParam]:
type_hint=torch.Tensor,
description="Denoising timesteps from set_timesteps.",
),
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
InputParam.template("attention_kwargs"),
]

Expand Down
4 changes: 2 additions & 2 deletions src/diffusers/modular_pipelines/ltx/before_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def inputs(self) -> list[InputParam]:
InputParam.template("latents"),
InputParam.template("num_images_per_prompt", name="num_videos_per_prompt"),
InputParam.template("generator"),
InputParam.template("batch_size", required=True),
InputParam.template("batch_size", required=True, default=None),
]

@property
Expand Down Expand Up @@ -342,7 +342,7 @@ def inputs(self) -> list[InputParam]:
InputParam.template("width", default=704),
InputParam("num_frames", type_hint=int, default=161),
InputParam.template("num_images_per_prompt", name="num_videos_per_prompt"),
InputParam.template("batch_size", required=True),
InputParam.template("batch_size", required=True, default=None),
]

@property
Expand Down
2 changes: 1 addition & 1 deletion src/diffusers/modular_pipelines/ltx/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def inputs(self) -> list[tuple[str, Any]]:
InputParam("decode_noise_scale", default=None),
InputParam.template("generator"),
InputParam.template("batch_size"),
InputParam.template("dtype", required=True),
InputParam.template("dtype", required=True, default=None),
]

@property
Expand Down
10 changes: 5 additions & 5 deletions src/diffusers/modular_pipelines/ltx/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def description(self) -> str:
def inputs(self) -> list[InputParam]:
return [
InputParam.template("latents", required=True),
InputParam.template("dtype", required=True),
InputParam.template("dtype", required=True, default=None),
]

@torch.no_grad()
Expand Down Expand Up @@ -95,7 +95,7 @@ def description(self) -> str:
def inputs(self) -> list[tuple[str, Any]]:
inputs = [
InputParam.template("attention_kwargs"),
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
InputParam("rope_interpolation_scale", type_hint=tuple),
InputParam.template("height"),
InputParam.template("width"),
Expand Down Expand Up @@ -207,7 +207,7 @@ def loop_expected_components(self) -> list[ComponentSpec]:
def loop_inputs(self) -> list[InputParam]:
return [
InputParam.template("timesteps", required=True),
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
]

@torch.no_grad()
Expand Down Expand Up @@ -271,7 +271,7 @@ def inputs(self) -> list[InputParam]:
return [
InputParam.template("latents", required=True),
InputParam("conditioning_mask", required=True, type_hint=torch.Tensor),
InputParam.template("dtype", required=True),
InputParam.template("dtype", required=True, default=None),
]

@torch.no_grad()
Expand Down Expand Up @@ -323,7 +323,7 @@ def description(self) -> str:
def inputs(self) -> list[tuple[str, Any]]:
inputs = [
InputParam.template("attention_kwargs"),
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
InputParam("rope_interpolation_scale", type_hint=tuple),
InputParam.template("height"),
InputParam.template("width"),
Expand Down
4 changes: 2 additions & 2 deletions src/diffusers/modular_pipelines/ltx2/decoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def inputs(self) -> list[tuple[str, Any]]:
"num_frames", type_hint=int, default=121, description="The number of frames in the generated video."
),
InputParam.template("generator"),
InputParam.template("dtype", required=True),
InputParam.template("dtype", required=True, default=None),
]

@property
Expand Down Expand Up @@ -250,7 +250,7 @@ def inputs(self) -> list[tuple[str, Any]]:
),
InputParam.template("generator"),
InputParam.template("batch_size"),
InputParam.template("dtype", required=True),
InputParam.template("dtype", required=True, default=None),
]

@property
Expand Down
4 changes: 2 additions & 2 deletions src/diffusers/modular_pipelines/ltx2/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def inputs(self) -> list[InputParam]:
# `audio_num_frames`, `video_coords`, `audio_coords` arrive tagged `denoiser_input_fields` upstream and
# are collected from the tagged dict (filtered against the transformer signature) in `__call__`.
InputParam.template("denoiser_input_fields"),
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
InputParam.template("height", default=512),
InputParam.template("width", default=704),
InputParam(
Expand Down Expand Up @@ -620,7 +620,7 @@ def loop_expected_components(self) -> list[ComponentSpec]:
def loop_inputs(self) -> list[InputParam]:
return [
InputParam("timesteps", type_hint=torch.Tensor, required=True),
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
]

@torch.no_grad()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ def expected_components(self) -> list[ComponentSpec]:
@property
def inputs(self) -> list[InputParam]:
return [
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
InputParam(
name="video_indices",
type_hint=torch.Tensor,
Expand Down
9 changes: 9 additions & 0 deletions src/diffusers/modular_pipelines/modular_pipeline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,15 @@ class InputParam:
# resolves its own default at runtime in `get_block_state`
defaults_by_block: dict[str, Any] = None

def __post_init__(self):
if self.required and self.default is not None:
logger.warning(
f"InputParam '{self.name}' is required and declares a default ({self.default!r}), which cannot both "
f"hold: a required input is never missing, so its default is unreachable. Dropping the default. Drop "
f"`required=True` instead if {self.default!r} is meant to be the real fallback."
)
self.default = None

def __repr__(self):
return f"<{self.name}: {'required' if self.required else 'optional'}, default={self.default}>"

Expand Down
2 changes: 1 addition & 1 deletion src/diffusers/modular_pipelines/qwenimage/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def loop_inputs(self) -> list[InputParam]:
type_hint=torch.Tensor,
description="The timesteps to use for the denoising process. Can be generated in set_timesteps step.",
),
InputParam.template("num_inference_steps", required=True),
InputParam.template("num_inference_steps"),
]

@torch.no_grad()
Expand Down
Loading