Skip to content

Set scheduler begin index in remaining FlowMatch pipelines to avoid DtoH sync - #14576

Merged
sayakpaul merged 2 commits into
huggingface:mainfrom
shoemoney:fix/begin-index-siblings
Sep 8, 2026
Merged

sayakpaul merged 2 commits into
huggingface:mainfrom
shoemoney:fix/begin-index-siblings

Conversation

@shoemoney

@shoemoney shoemoney commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #14573.

#11696 added self.scheduler.set_begin_index(0) before the denoising loop in FluxPipeline to avoid the device-to-host sync from nonzero().item() in FlowMatchEulerDiscreteScheduler.index_for_timestep(). That fix was later propagated to Wan, QwenImage, and others, but five FlowMatchEulerDiscreteScheduler pipelines never received it: HunyuanVideo, Mochi, Lumina2, AuraFlow, and Chroma (text-to-image).

This PR applies the identical one-line pattern (with the same comment pointing at #11696) to those five. SD3 is intentionally excluded since open PR #14176 already covers it.

Verified on CPU with the repo's dummy-component fixtures: before, each pipeline enters index_for_timestep (the .item() sync path) once on the first step; after, zero entries, begin_index == 0, outputs unchanged. Fast test suites for all five pipelines show no new failures versus main; make style / check_copies clean. Like #11696, no new tests, since the eliminated sync is only observable in a profiler trace.

Before submitting

  • Did you read the contributor guideline?
  • Did you read our philosophy doc? (important for complex PRs)
  • Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Are you the author (or part of the team) of the model/pipeline (only applicable for model/pipeline related PRs)?

Who can review?

@yiyixuxu @dg845

…toH sync

Propagate the set_begin_index(0) fix from huggingface#11696 to HunyuanVideo, Mochi,
Lumina2, AuraFlow, and Chroma text-to-image/video pipelines. Without it,
the first scheduler.step() routes through _init_step_index() ->
index_for_timestep(), whose nonzero().item() forces a device-to-host
sync on the first denoising step. Fixes huggingface#14573.
@github-actions github-actions Bot added pipelines fixes-issue size/S PR with diff < 50 LOC labels Aug 24, 2026
@DN6
DN6 requested a review from sayakpaul September 7, 2026 12:14
@sayakpaul sayakpaul moved this to In Progress in Diffusers Roadmap Sep 8, 2026

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@sayakpaul
sayakpaul merged commit 040c7cd into huggingface:main Sep 8, 2026
13 of 15 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Diffusers Roadmap Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Several FlowMatch pipelines miss the set_begin_index(0) DtoH-sync fix from #11696

3 participants