Skip to content

Moonshine streaming: incremental frontend (optional frontend_step.vmfb) - #516

Merged
michalharakal merged 2 commits into
developfrom
feature/moonshine-incremental-frontend
Oct 22, 2026
Merged

michalharakal merged 2 commits into
developfrom
feature/moonshine-incremental-frontend

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

What

The streaming Moonshine runtime reran the audio frontend over the whole 68-frame window at every hop, and once more over the tail at finish(). That tail is most of the end-of-utterance flush.

With an optional ninth model file, frontend_step.vmfb, next to frontend.vmfb, three things change:

  • Frontend: it runs in 0.32 s chunks (16 frames + 4 frames of causal left context) as the audio arrives, and its features are cached.
  • Windows: they run only the encoder and adapter on the cached features.
  • Padding: frames more than 4 frames past the audio can only see zero padding. They take the frontend's constant silence feature, captured at warm-up, instead of another graph call.

frontend_step.vmfb is the same frontend exported with MOONSHINE_FE_SAMPLES=6400. Without the file, behaviour is unchanged.

Also in this PR

  • moonshine_stream_check.c: drives the library on a device without an app (fake JNIEnv, like whisper_session_check.c).
  • stats(): gains feStepCalls / feStepMs.
  • IreeMoonshineStream.OPTIONAL_FILE_NAMES: names the optional file.
  • build-moonshine-stream.sh: always passes CMAKE_C_FLAGS. Before, a cached GEOMETRY from the previous build leaked into the next one.
  • Libraries: both ABIs rebuilt from this source.

Evidence

Measured on an arm32 Mali device (Vulkan, IREE 3.11) with 40 German commands fed like a microphone (40 ms chunks, real-time pace). The 0.62.2 library ran 3 times and this branch ran 2 times:

0.62.2 this branch
flush p50 / p95 319 / 324 ms 172 / 236 ms
finish p50 882 ms 737 ms
end of audio → final text p50 1.24 s 1.02–1.05 s
transcripts identical, 40/40
  • Speed: faster in 40/40 recordings, with a paired median of −147 ms on flush and −275 ms from end of audio to final text.
  • Features: a build with -DMOONSHINE_FE_VERIFY also runs the whole-window frontend and compares its output. It found maxdiff 0 in 141/141 windows, so the features are bit-identical, including the silence-feature shortcut.
  • Re-check: the committed armeabi-v7a library was re-checked on the device. Its transcripts match 0.62.2 in 40/40 recordings, with flush p50 172 ms.
  • Not changed: the exact final re-decode (~565 ms p50).

Follow-ups (not in this PR)

  • The blueprint asr-moonshine-v2-streaming-iree should export and compile frontend_step.vmfb.
  • Materializers should copy OPTIONAL_FILE_NAMES when present.

🤖 Generated with Claude Code

When frontend_step.vmfb (the same frontend exported for 16 + 4 frames) sits next to
frontend.vmfb, the frontend runs in 0.32 s chunks as the audio arrives and windows only run
the encoder and adapter on cached features. Frames that can only see zero padding take the
frontend's constant silence feature instead of another graph call. Without the file nothing
changes.

Measured with moonshine_stream_check on an arm32 Mali device, 40 German commands paced like a
microphone, against the released 0.62.2 library: features bit-identical (MOONSHINE_FE_VERIFY,
141/141 windows maxdiff 0), transcripts identical 40/40, flush p50 319 -> 172 ms, end of audio
-> final text p50 -275 ms, faster in 40/40.

moonshine_stream_check.c drives the library without an app (fake JNIEnv, like
whisper_session_check.c).
…docs; build script resets CFLAGS

Both ABIs rebuilt from this source (no verify code in them). stats() gains feStepCalls/feStepMs,
IreeMoonshineStream.OPTIONAL_FILE_NAMES names frontend_step.vmfb, and build-moonshine-stream.sh
always passes CMAKE_C_FLAGS so a cached GEOMETRY does not leak into the next build. The armeabi-v7a
library re-checked on the device: 40/40 transcripts identical to 0.62.2, flush p50 172 ms.
@michalharakal
michalharakal merged commit 0301c38 into develop Oct 22, 2026
2 checks passed
@michalharakal
michalharakal deleted the feature/moonshine-incremental-frontend branch October 22, 2026 20:35
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