Set scheduler begin index in remaining FlowMatch pipelines to avoid DtoH sync - #14576
Open
shoemoney wants to merge 1 commit into
Open
Set scheduler begin index in remaining FlowMatch pipelines to avoid DtoH sync#14576shoemoney wants to merge 1 commit into
shoemoney wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14573.
#11696 added
self.scheduler.set_begin_index(0)before the denoising loop inFluxPipelineto avoid the device-to-host sync fromnonzero().item()inFlowMatchEulerDiscreteScheduler.index_for_timestep(). That fix was later propagated to Wan, QwenImage, and others, but fiveFlowMatchEulerDiscreteSchedulerpipelines 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_copiesclean. Like #11696, no new tests, since the eliminated sync is only observable in a profiler trace.