Repository navigation
Add step-end callbacks and interrupt to modular pipelines - #14942
Closed
fusheng-ji wants to merge 2 commits into
Closed
fusheng-ji wants to merge 2 commits into
fusheng-ji wants to merge 2 commits into
Conversation
ModularPipeline now accepts callback_on_step_end and callback_on_step_end_tensor_inputs, and pipe.interrupt stops denoising. Denoising loops use LoopSequentialPipelineBlocks.loop_over_timesteps and declare their callback fields. set_progress_bar_config now reaches nested loops. Addresses huggingface#12386.
fusheng-ji
force-pushed
the
feat-12386-modular-step-callbacks
branch
from
October 6, 2026 16:44
6331063 to
234f3de
Compare
Collaborator
|
hi @fusheng-ji we'd really welcome it if you are able to do a review that PR and let us know if there is any features are missing or anything can be improved - happy to collaborate more there |
Author
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.
What does this PR do?
Fixes #12386.
Modular pipelines had no step callbacks, and
set_progress_bar_configdidn't reach denoising loops nested inside other blocks (e.g. SDXL). This PR:callback_on_step_endandcallback_on_step_end_tensor_inputstoModularPipeline.__call__, with the same signature as the standard pipelines;pipe.interrupt = True, while still decoding the partial result;LoopSequentialPipelineBlocks.loop_over_timesteps, which runs the step, the callback and the interrupt check. The 15 timestep loops use it; the chunked loops (Cosmos3, Helios, MiniMax Music 3, Wan Animate 2) call the same pieces directly;pipe.callback_tensor_inputs).step_indexcounts across chunks and stages;set_progress_bar_configwalk all nested blocks.The issue's first point (listing call inputs) is already covered by
input_namesandrequired_inputs, as noted on the issue.Coordination: #12386 (@yiyixuxu: "we will add support for callback etc")
Results
Real checkpoints, same seed,
mainvs this branch:mainset_progress_bar_config(disable=True)latentsfrom the callback changes the result, and the call after an interrupt matches a normal run bitwise.Tests
The new SDXL test
test_set_progress_bar_config_reaches_nested_loopfails onmainand passes here.Design question for reviewers
loop_over_timestepsputs the step, callback and interrupt logic in a base-class helper instead of repeating it in each loop. The chunked loops can't use it and call the same pieces directly, so there are two patterns. Happy to inline it into each loop instead if you prefer.Known limitations
tqdm, soset_progress_bar_configstill doesn't reach them.latentsto callbacks, because their loops build the conditioning once per chunk.guidercomponent.Self-review notes
Final self-review round (verdict: READY)
Blocking: none. Checked request validation, cleanup in
finally, that conditioning edits reach the next step, and that the chunked loops handle interrupt and callbacks.Non-blocking, left for review:
set_progress_bar_configdoesn't reach the plaintqdmbars inhelios/denoise.pyandwan_animate_2/denoise.py(existing; noted above)._call_callback_on_step_endwrites a returned field into any dict inblock_statewith that key, not onlykwargs_typecollections. No current loop is affected, but it could be narrowed.nearestso it can still be decoded.latent_hop_lengthto get two chunks from the tiny config.test_step_callback_and_interruptis in the shared modular tester mixin, so a future loop without callback support will fail it.Dead code: none.
Suggestion for maintainers: a note in
.ai/references/modular.mdthat loops should useloop_over_timestepsand declare_callback_tensor_inputs.Before submitting
self-reviewskill on the diff?Who can review?
@yiyixuxu @DN6