You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#11696 ("Avoid DtoH sync from access of nonzero() item in scheduler") added self.scheduler.set_begin_index(0) before the denoising loop in pipeline_flux.py. The same fix was
later propagated to pipeline_wan.py and pipeline_qwenimage.py. Several other pipelines that use FlowMatchEulerDiscreteScheduler never received it.
Opening this as one systematic issue rather than per-pipeline PRs, per the contributing guide.
Current state
I checked every FlowMatchEulerDiscreteScheduler pipeline on main for set_begin_index:
So five pipelines are unclaimed, and SD3 is already in flight — I'd leave that one to #14176 and
scope this to the other five.
Why it matters
Without a pre-set begin_index, the first step() call routes through FlowMatchEulerDiscreteScheduler._init_step_index() → index_for_timestep(), which does (schedule_timesteps == timestep).nonzero() followed by .item(). That .item() forces a
device-to-host sync on the first denoising step.
It's a latency cost rather than a correctness bug, and it's most noticeable exactly where these
pipelines are used — long video generations and torch.compile'd runs, where an avoidable sync
stalls the pipeline. pipeline_wan.py even carries a comment pointing back at #11696, so the intent
to propagate seems already established.
Proposed scope
Add the same single line before the denoising loop in each of the five unclaimed pipelines, matching #11696's placement and style exactly. No behavioral change beyond removing the sync.
Questions before I open anything
Do you want this as one PR across the five, or one PR per pipeline? The guide says fix
patterns rather than one-offs, so I'd default to a single PR — but five files touched by a new
contributor may not be what you want to review, so I'd rather ask.
Are any of these five deliberately excluded for a reason I can't see from the source?
Happy to take it from here once someone acknowledges the scope.
Disclosure per the contributing guide: I used AI assistance to survey the codebase for instances of
this pattern. The table above I verified by reading each file on main directly. If this moves to a
PR I'll run the self-review skill and post the notes with it, along with the test commands and
their output.
Summary
#11696 ("Avoid DtoH sync from access of nonzero() item in scheduler") added
self.scheduler.set_begin_index(0)before the denoising loop inpipeline_flux.py. The same fix waslater propagated to
pipeline_wan.pyandpipeline_qwenimage.py. Several other pipelines that useFlowMatchEulerDiscreteSchedulernever received it.Opening this as one systematic issue rather than per-pipeline PRs, per the contributing guide.
Current state
I checked every
FlowMatchEulerDiscreteSchedulerpipeline onmainforset_begin_index:set_begin_indexflux/pipeline_flux.pywan/pipeline_wan.pyqwenimage/pipeline_qwenimage.pystable_diffusion_3/pipeline_stable_diffusion_3.pyhunyuan_video/pipeline_hunyuan_video.pymochi/pipeline_mochi.pylumina2/pipeline_lumina2.pyaura_flow/pipeline_aura_flow.pychroma/pipeline_chroma.pySo five pipelines are unclaimed, and SD3 is already in flight — I'd leave that one to #14176 and
scope this to the other five.
Why it matters
Without a pre-set
begin_index, the firststep()call routes throughFlowMatchEulerDiscreteScheduler._init_step_index()→index_for_timestep(), which does(schedule_timesteps == timestep).nonzero()followed by.item(). That.item()forces adevice-to-host sync on the first denoising step.
It's a latency cost rather than a correctness bug, and it's most noticeable exactly where these
pipelines are used — long video generations and
torch.compile'd runs, where an avoidable syncstalls the pipeline.
pipeline_wan.pyeven carries a comment pointing back at #11696, so the intentto propagate seems already established.
Proposed scope
Add the same single line before the denoising loop in each of the five unclaimed pipelines, matching
#11696's placement and style exactly. No behavioral change beyond removing the sync.
Questions before I open anything
patterns rather than one-offs, so I'd default to a single PR — but five files touched by a new
contributor may not be what you want to review, so I'd rather ask.
Happy to take it from here once someone acknowledges the scope.
Disclosure per the contributing guide: I used AI assistance to survey the codebase for instances of
this pattern. The table above I verified by reading each file on
maindirectly. If this moves to aPR I'll run the
self-reviewskill and post the notes with it, along with the test commands andtheir output.