Skip to content

Fix InputParam required flag silently ignored when a non-None default is set - #14402

Open
Sravan1011 wants to merge 1 commit into
huggingface:mainfrom
Sravan1011:fix-modular-required-default-14388
Open

Fix InputParam required flag silently ignored when a non-None default is set#14402
Sravan1011 wants to merge 1 commit into
huggingface:mainfrom
Sravan1011:fix-modular-required-default-14388

Conversation

@Sravan1011

@Sravan1011 Sravan1011 commented Aug 6, 2026

Copy link
Copy Markdown

Summary

  • Fixes Modular: required=True is silently ignored when an InputParam carries a default #14388: ModularPipelineBlocks.get_block_state() substituted input_param.default before checking input_param.required, so a required input with a non-None default never raised when omitted.
  • This is easy to hit via InputParam.template("x", required=True), since the template's own default (e.g. num_inference_steps defaults to 50) carries over unless explicitly overridden with default=None.
  • Fix: move the required check ahead of the default substitution in get_block_state, so it always tests the raw value passed by the caller rather than the value after the fallback default has been applied.

Note for maintainers

Several existing blocks declare InputParam.template(..., required=True) for templates that carry a non-None default (e.g. num_inference_steps in krea2, cosmos, minimax_h3, qwenimage, ltx; batch_size and dtype in ltx). With this fix, those inputs now actually enforce required=True at runtime (previously they silently fell back to the template default). This is the correct behavior per the reported bug, but flagging it here in case any of those sites intended the default to be the real fallback rather than required=True. Happy to follow up with a stricter guard (e.g. rejecting required=True plus a non-None default in InputParam.__post_init__) plus a pass over those sites if maintainers prefer that direction -- filing this narrower fix first since it corrects the actual runtime bug with minimal risk.

Test plan

  • Verified the fixed check order against a standalone reproduction of the reported bug (InputParam.template("num_inference_steps", required=True) now raises when omitted, and still accepts an explicitly passed value)
  • CI / existing modular pipeline test suite

… is set

get_block_state() substituted input_param.default before checking
input_param.required, so a required input with a non-None default
(easy to hit via InputParam.template("x", required=True) since the
template's default carries over) never raised when omitted. Move the
required check ahead of the default substitution so it always fires
against the raw value passed by the caller.

Fixes huggingface#14388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

modular-pipelines size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modular: required=True is silently ignored when an InputParam carries a default

1 participant