Skip to content

fix(kokoro): poll synthesis cancel between stages - #45

Merged
lalalune merged 1 commit into
eliza/develop-pin-ea8b3f2from
fix/android-elizainference-libm
Oct 14, 2026
Merged

lalalune merged 1 commit into
eliza/develop-pin-ea8b3f2from
fix/android-elizainference-libm

Conversation

@lalalune

@lalalune lalalune commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

This PR is rebased onto eliza/develop-pin-ea8b3f2 (after #59 ABI v17 and #60).

Dropped

  • Link libm (6993635). develop-pin does not need it: eliza_voice_classifiers already links m PUBLIC, and elizainference links eliza_voice_classifiers.

Ported: Kokoro cancels between stages

In #59, Kokoro checks kokoro_cancel only before and after the whole forward pass. A cancelled call still runs the predictor, the decoder front and the iSTFTNet generator to the end, then throws the audio away. This PR stops the call at the next stage boundary.

  • kokoro_synthesize and kokoro_synthesize_ipa take an optional kokoro_cancel_callback. It defaults to null, so existing callers do not change.
  • The callback is checked:
    • before the predictor
    • after the predictor
    • between the decoder front and the generator (inside kokoro_decoder_forward)
    • after the generator
  • A cancelled call returns the new KOKORO_E_CANCELLED with no samples.
  • eliza_kokoro_synthesize_audio passes a callback that reads the per-engine kokoro_cancel flag. It does not use the shared tts_cancel / ElizaScopedTtsForward, so an OmniVoice or Paradee call still cannot clear a Kokoro cancel. The flag is reset at the start of each call and cleared again when the call ends, as libelizainference ABI v17: Paradee + misaki TTS entries, ASR cancel/supported, TTS cancel and evict for Kokoro/Paradee #59 already does.
  • Changes from the original commit:
    • no per-64-row check in the transpose loop
    • no clearing of the shared flag on entry
  • No check inside a GGML graph. When a conv graph fails in kokoro-layers.h, the code falls back to the CPU loops, so a backend abort callback would not stop the work. Apple builds use Accelerate, not GGML, by default.

Tests

New test: test-kokoro-cancel.

  • Always runs: the status string, and a check that argument validation happens before the first cancel check.
  • Runs only when KOKORO_TEST_MODEL and KOKORO_TEST_VOICE are set: a real synthesis is cancelled at each stage boundary in turn. No weights were available locally, so this part has not been run yet.

Local run on macOS arm64 (Ninja, Release, LLAMA_BUILD_TESTS=ON, LLAMA_FATAL_WARNINGS=ON):

  • All kokoro and omnivoice targets built with no warnings in tools/.
  • ctest -R "kokoro|eliza-inference|omnivoice": 11/11 passed.

🤖 Generated with Claude Code

ABI v17 checks the Kokoro cancel flag only before and after the whole
forward pass, so a cancelled call still runs the predictor, decoder front
and iSTFTNet generator to completion. kokoro_synthesize and
kokoro_synthesize_ipa now take an optional cancel callback that is polled
before the predictor, between the predictor and the decoder, between the
decoder front and the generator, and after the generator. A cancelled call
returns KOKORO_E_CANCELLED with no samples.

libelizainference passes a callback that reads the per-engine
kokoro_cancel flag, so OmniVoice and Paradee calls still cannot clear it.
The existing entry reset and exit exchange in
eliza_kokoro_synthesize_audio stay as the flag's lifecycle.

No hook runs inside a GGML graph: a failed conv graph falls back to the
CPU loops in kokoro-layers.h, so a backend abort callback would not stop
the work.

Adds test-kokoro-cancel. Its weight-free checks always run; with
KOKORO_TEST_MODEL and KOKORO_TEST_VOICE set it cancels a real synthesis at
every stage boundary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lalalune
lalalune force-pushed the fix/android-elizainference-libm branch from 9abc710 to b843732 Compare October 14, 2026 03:03
@lalalune lalalune changed the title fix(omnivoice): link fused Android inference against libm fix(kokoro): poll synthesis cancel between stages Oct 14, 2026
@lalalune
lalalune changed the base branch from eliza/kokoro-g2p-plus-gemma4 to eliza/develop-pin-ea8b3f2 October 14, 2026 03:04
@lalalune
lalalune merged commit 53a0d25 into eliza/develop-pin-ea8b3f2 Oct 14, 2026
47 of 57 checks passed
lalalune pushed a commit that referenced this pull request Oct 14, 2026
Resolve kokoro-decoder against the stage-boundary cancel from #45: keep the
shared decoder_forward and pass the caller's cancel callback through
DecoderConfig. Keep both new kokoro tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lalalune pushed a commit that referenced this pull request Oct 14, 2026
Every change on this branch already reached develop-pin (and so main) in a
newer form through #64: Paradee hardening, Kokoro stage cancel from #45.
Keep main's tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant