Skip to content

core: widen the cancel callback into an AceProgress report+cancel callback - #111

Open
erichchampion wants to merge 1 commit into
ServeurpersoCom:masterfrom
erichchampion:offer/patch-3-progress
Open

core: widen the cancel callback into an AceProgress report+cancel callback#111
erichchampion wants to merge 1 commit into
ServeurpersoCom:masterfrom
erichchampion:offer/patch-3-progress

Conversation

@erichchampion

Copy link
Copy Markdown

Third of four small embedder patches from Cadenza (independent of the others; ported onto current master's heterogeneous LM batching from #9761469 and the dropped DiT padding-mask plumbing from #da5bc90).

What it does

The pipelines took bool (*cancel)(void *) + void * cancel_data. The same callback now also reports where the run is:

struct AceProgress {
    bool (*fn)(void * data, AceStage stage, int step, int total) = nullptr;
    void * data                                                  = nullptr;
};

Every pipeline poll calls fn with the current stage and loop position, and returning true still cancels -- so a UI gets a real progress bar over the exact hook it already had to implement anyway. The HTTP server's /progress poll-with-cancel is the visible beneficiary: today a client can cancel but cannot know whether the run is in LM, DiT or VAE, or how far along.

  • Passed by value, defaulted to {} (no callback = no progress and never cancel), so every existing caller that passed nothing is unchanged, and callers that passed a cancel pair keep identical cancellation semantics.
  • Stages: LM, DiT, VAE encode, VAE decode, MP3. step is 0-based, and a step-0 report fires before a loop's first unit of work, so a segmented bar can be sized even for empty loops.
  • Thread-safety is documented: fn is called sequentially for LM, DiT and VAE, but MP3 encode is fork-join, so fn may be called concurrently there -- safe for the flag-reading implementations that are the common case.

Testing

tests/test-progress.cpp exercises the report/cancel contract: report sequence, cancel mid-loop, and the step-0-before-first-work guarantee. Built and run on macOS/arm64/Metal.

…lback

The pipelines took `bool (*cancel)(void *)` + `void * cancel_data`. The same
callback now also reports where the run is: AceProgress carries a
fn(data, stage, step, total) that every pipeline poll calls with the current
stage and loop position, and returning true still cancels -- so a UI gets a
real progress bar over the exact hook it already had to implement anyway (the
HTTP server's poll-with-cancel is the visible case).

AceProgress is passed by value, defaulted to {} (no callback = no progress and
never cancel), so every existing caller that passed nothing is unchanged, and
callers that passed a cancel pair keep identical cancellation semantics with
one extra argument they can ignore. Stage enum covers LM, DiT, VAE encode and
decode, and MP3; step is 0-based with a step-0 report before a loop's first
unit of work, so a segmented bar can be sized even for empty loops. MP3 encode
is fork-join, so fn may be called concurrently there -- documented, and safe
for the flag-reading implementations that are the common case.

Ported onto current master's heterogeneous LM batching (9761469) and the
dropped DiT padding-mask plumbing (da5bc90). test-progress.cpp exercises the
report/cancel contract.
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 14cc8ce6-474f-4b13-86ea-8b291c69cce2

📥 Commits

Reviewing files that changed from the base of the PR and between c9045e2 and 2378347.

📒 Files selected for processing (19)
  • src/audio-io.h
  • src/dit-sampler.h
  • src/pipeline-lm.cpp
  • src/pipeline-lm.h
  • src/pipeline-synth-ops.cpp
  • src/pipeline-synth-ops.h
  • src/pipeline-synth.cpp
  • src/pipeline-synth.h
  • src/pipeline-understand.cpp
  • src/pipeline-understand.h
  • src/progress.h
  • src/vae-enc.h
  • src/vae.h
  • tests/CMakeLists.txt
  • tests/test-progress.cpp
  • tools/ace-lm.cpp
  • tools/ace-server.cpp
  • tools/ace-understand.cpp
  • tools/synth-batch-runner.h

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant