Skip to content

whisper.cpp backend: export a usable encoder bundle, and fix the stale fork docs - #275

Merged
sbryngelson merged 2 commits into
mainfrom
docs/whispercpp-upstream
Sep 18, 2026
Merged

sbryngelson merged 2 commits into
mainfrom
docs/whispercpp-upstream

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

What

ggml-org/whisper.cpp#3905 merged on 2026-09-18, so the encoder is an optional backend upstream. Two things on this side hadn't caught up: the benchmark README still said "in a fork" in two places, and export_bundle.py -- the only thing that produces what ANEFORGE_ENCODER loads -- emitted a bundle nobody could use.

The bundle was unusable

This is the part that isn't docs. export_bundle.py called make_encoder() (randomly-initialised weights) and build(attn="mha") -- the generic [seq,d] layout this README clocks at ~33 ms, not the channels-first query-tiled encoder the 5.7 ms and 2x-vs-CoreML numbers come from. It was whisper-tiny only.

So anyone told to point ANEFORGE_ENCODER at a bundle would have got one that transcribes noise and runs slower than Metal.

How

Default to the trained checkpoint (real_encoder) in the benchmarked layout (build_cf). --model takes any Whisper repo id tiny..medium; the dimensions come from its HF config through a new set_dims, since the graph builders read them as module globals. --compress int4 matches how medium is benchmarked, --layout seq keeps the old build for comparison, and --random keeps the old weights behind an explicit flag that says the bundle does not transcribe. The manifest records model, layout and dims.

Docs: both "in a fork" notes now point at the upstream PR, the README gains the export recipe and the two env vars, and the feature list gains the integration, which it was missing entirely.

Verification

  • whisper-tiny, trained weights, channels-first: cosine 0.999970 vs the torch reference
  • the C++ runner loads that bundle the way whisper.cpp does, at 5.569 ms/call -- matching the benchmarked 5.7 ms, so the exported bundle is now the fast encoder
  • whisper-base: cosine 0.999961, dims read from the config (d=512, layers=6, heads=8, ffn=2048)
  • ruff check . clean

No benchmark numbers changed. The existing caveats -- encoder only, energy measured against eager MPS, single-clip transcript rather than dataset WER -- stay as they were.

ggml-org/whisper.cpp#3905 merged 2026-09-18, so the two "in a fork" notes in
the encoder benchmark README are stale. Records how it is enabled (the
ANEFORGE_ENCODER / ANEFORGE_DYLIB env vars) and adds the integration to the
feature list, where it was missing entirely.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-18T04:39:07.117501Z 836b34a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…out, any size)

export_bundle.py produced a bundle that could not be used with the whisper.cpp
ANEForge backend: make_encoder() gives randomly-initialised weights, and
build(attn="mha") is the generic [seq,d] layout the README clocks at ~33 ms, not
the channels-first query-tiled encoder the 5.7 ms and 2x-vs-CoreML numbers come
from. It was also whisper-tiny only.

Defaults now to the trained checkpoint via real_encoder() and build_cf, adds
--model (dimensions read from the HF config through the new set_dims), --layout,
--compress, and keeps the old behaviour behind an explicitly-labelled --random.
The manifest records which model, layout and dims produced the bundle.

Verified: tiny exports at cosine 0.999970 and the C++ runner loads it the way
whisper.cpp does at 5.569 ms/call, matching the benchmarked 5.7 ms; base exports
at cosine 0.999961 with dims picked up from the config (d=512, layers=6, heads=8).
@sbryngelson sbryngelson changed the title docs: the whisper.cpp encoder backend is upstream, not a fork whisper.cpp backend: a usable encoder bundle export, and docs to match Sep 18, 2026
@sbryngelson sbryngelson changed the title whisper.cpp backend: a usable encoder bundle export, and docs to match whisper.cpp backend: export a usable encoder bundle, and fix the stale fork docs Sep 18, 2026
@sbryngelson
sbryngelson merged commit 6ea5ecb into main Sep 18, 2026
19 checks passed
@sbryngelson
sbryngelson deleted the docs/whispercpp-upstream branch September 18, 2026 04:45
sbryngelson added a commit that referenced this pull request Sep 18, 2026
#276)

#275 fixed the weights and the layout but not the file contract. whisper.cpp's
ANEForge backend reads ports.txt (three "name nelems" lines in mel, pos, output
order) and pos.f16 from the bundle root; export_bundle.py wrote neither, so the
bundle still could not be loaded upstream. The verification in #275 went through
our own whisper_ane_run.cpp, which reads manifest.json instead -- a different
contract, which is why it passed.

Ports are matched by shape rather than creation order: mel comes back as t1 and
pos as t0, so position would have swapped them.

Verified by compiling whisper.cpp's own src/aneforge/whisper-aneforge.cpp against
the bundle: whisper_aneforge_init() succeeds ("encoder ready (mel=t1 pos=t0
out=t1383)") and the encode output matches the torch reference at cosine 0.999970.
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