Skip to content

Fix modular branch input defaults#14137

Open
pzarzycki wants to merge 1 commit into
huggingface:mainfrom
pzarzycki:fix/modular-branch-input-defaults
Open

Fix modular branch input defaults#14137
pzarzycki wants to merge 1 commit into
huggingface:mainfrom
pzarzycki:fix/modular-branch-input-defaults

Conversation

@pzarzycki

Copy link
Copy Markdown
Contributor

Summary

Fixes modular pipeline input default handling so branch-local defaults do not leak across conditional branches.

In ConditionalPipelineBlocks, pipeline-level defaults are now only exposed when every branch declares the same default for a shared input. If defaults differ across branches, or only some branches declare the input, the pipeline-level default stays unset and the selected branch applies its own local default.

This fixes cases where one branch could not distinguish:

  • user explicitly passed a value
  • a sibling branch's default was filled into PipelineState before branch selection

Fixes #14132.

Repro

Minimal shape of the bug:

  • one branch declares num_frames=189
  • sibling branch declares num_frames=None and requires that it stay unset when action is provided
  • before this change, the merged pipeline-level default filled num_frames=189 into state even on the action branch
  • after this change, the action branch receives num_frames=None unless the user explicitly passed it

Implementation

  • changed conditional input aggregation in src/diffusers/modular_pipelines/modular_pipeline.py
  • preserved pipeline-level defaults only when all branches agree on the same default
  • kept selected block local defaults working by not materializing missing None defaults into PipelineState
  • added focused regression tests for:
    • branch-local default leak repro
    • default-branch local default preservation
    • hidden branch-local defaults in default_call_parameters
    • preserved shared defaults
    • conflicting non-None defaults not being promoted

Tests

Ran:

./.venv/bin/python -m pytest tests/modular_pipelines/test_conditional_pipeline_blocks.py -q

Result:

26 passed

Additional broader validation surfaced unrelated modular test failures that are not addressed in this PR:

  • ErnieImage batch/single parity
  • LTX batch/single parity
  • Helios auto CPU offload device mismatch

Copilot AI review requested due to automatic review settings July 7, 2026 20:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes modular pipeline input default handling for ConditionalPipelineBlocks so branch-local defaults don’t get promoted to pipeline-level defaults (and therefore don’t leak into sibling branches before branch selection). This aligns behavior with the intent described in #14132: only defaults that are truly shared across all branches should appear as pipeline-level defaults.

Changes:

  • Updated conditional input aggregation to only promote a pipeline-level default when every branch declares the same default for a shared input.
  • Adjusted state/input resolution so missing inputs fall back to the selected block’s local default, and None defaults are not materialized into PipelineState before branch selection.
  • Added regression tests covering branch-local default leakage, shared default promotion, and conflicting-default non-promotion.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/diffusers/modular_pipelines/modular_pipeline.py Changes how conditional inputs are combined and how defaults are applied so branch-local defaults don’t leak across branches.
tests/modular_pipelines/test_conditional_pipeline_blocks.py Adds focused regression tests for branch-local defaults, shared defaults, and conflicting defaults behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[modular] ensure branch-specific input defaults

2 participants