Speed up CPU dictation and validate streaming across models #15

Merged
kleb merged 1 commit from perf/streaming-model-coverage into main 2026-10-29 02:32:36 +01:00
Owner

CPU dictation was spending time on a redundant warmup, and slow models could exhaust the short streaming backlog before producing output. Enable CPU Flash Attention, skip the CPU dummy decode, and allow the recorder's full 30-minute backlog within a hard 64 MiB audio budget.

Measured through the production Electron worker, three warmed trials per side:

Case Before median After median
Tiny, English 5 s 9,210 ms 8,013 ms
Tiny, English 11 s, auto language 18,009 ms 15,482 ms
Base, German 6.374 s 22,202 ms 19,423 ms

Process RSS at trial completion fell 18.4–19.7%. In a separate three-pair fresh-process comparison with Flash Attention on both sides, removing CPU warmup reduced Tiny's time from script start to first transcript from 16,767 to 8,685 ms. Text and language matched. GPU behavior is unchanged.

All 13 selectable model/detector profiles were exercised with verified model weights and native CPU inference. Nine streamed successfully, including Small with sustained input and all five Parakeet detector selections. Four Whisper models (Medium, Large v2, Large v3, full-precision Turbo) hit Electron's native aligned-allocation limit on Linux CPU. Those exact combinations now refuse safely, retain model files and selections, and leave startup recoverable. Ordinary Node loads the same Large v3 weights; bundling a separate inference runtime is deliberately outside this change. GPU and other OS compatibility were not runtime-tested.

See PERFORMANCE.md for methodology, input hashes, full coverage, limitations, and repeatable benchmark/native IPC commands.

Evidence: validation-evidence.tar.gz
Recovery from the refused Medium selection to Tiny: model-recovery.png

Proven with 144 passing tests (895 assertions), typecheck, oxlint, ESLint, format check, Knip, production build, the complete native catalog sweep, cancellation/reload/integrity checks, and a final independent Tiny/Parakeet native preload/IPC smoke.

CPU dictation was spending time on a redundant warmup, and slow models could exhaust the short streaming backlog before producing output. Enable CPU Flash Attention, skip the CPU dummy decode, and allow the recorder's full 30-minute backlog within a hard 64 MiB audio budget. Measured through the production Electron worker, three warmed trials per side: | Case | Before median | After median | | --- | ---: | ---: | | Tiny, English 5 s | 9,210 ms | 8,013 ms | | Tiny, English 11 s, auto language | 18,009 ms | 15,482 ms | | Base, German 6.374 s | 22,202 ms | 19,423 ms | Process RSS at trial completion fell 18.4–19.7%. In a separate three-pair fresh-process comparison with Flash Attention on both sides, removing CPU warmup reduced Tiny's time from script start to first transcript from 16,767 to 8,685 ms. Text and language matched. GPU behavior is unchanged. All 13 selectable model/detector profiles were exercised with verified model weights and native CPU inference. Nine streamed successfully, including Small with sustained input and all five Parakeet detector selections. Four Whisper models (Medium, Large v2, Large v3, full-precision Turbo) hit Electron's native aligned-allocation limit on Linux CPU. Those exact combinations now refuse safely, retain model files and selections, and leave startup recoverable. Ordinary Node loads the same Large v3 weights; bundling a separate inference runtime is deliberately outside this change. GPU and other OS compatibility were not runtime-tested. See [PERFORMANCE.md](PERFORMANCE.md) for methodology, input hashes, full coverage, limitations, and repeatable benchmark/native IPC commands. Evidence: [validation-evidence.tar.gz](https://git.kleb.sh/attachments/c19f5b83-cf5d-4501-8a04-cddbcec98f06) Recovery from the refused Medium selection to Tiny: ![model-recovery.png](https://git.kleb.sh/attachments/d5e54f02-d297-4d2c-bae2-d9045cb108a2) Proven with 144 passing tests (895 assertions), typecheck, oxlint, ESLint, format check, Knip, production build, the complete native catalog sweep, cancellation/reload/integrity checks, and a final independent Tiny/Parakeet native preload/IPC smoke.
Collaborator

kReview review

Verdict: no findings

No verified defects were found in the reviewed changes.

kReview checked only the PR diff, metadata, and supplied repository context at 2da1e6438a. It reports only issues supported by this material.

Estimated cost: ~$0.07 (198.0k in / 684 out / gpt-6.1-terra).

Run time: 0:26 total; this run 0:26.

<!-- codex-forgejo-review --> <!-- codex-forgejo-review-head:2da1e6438a258f7c6c971cce2659dc29d41a16a6 --> <!-- codex-forgejo-review-comparison:v1:331b45af05a7011feb828da14cff0a1d69cab4c5b27efc069897b0081a993a3b --> ## kReview review **Verdict:** no findings No verified defects were found in the reviewed changes. _kReview checked only the PR diff, metadata, and supplied repository context at `2da1e6438a`. It reports only issues supported by this material._ _Estimated cost: ~$0.07 (198.0k in / 684 out / gpt-6.1-terra)._ _Run time: 0:26 total; this run 0:26._ <!-- codex-forgejo-review-state:eyJoZWFkU2hhIjoiMmRhMWU2NDM4YTI1OGY3YzZjOTcxY2NlMjY1OWRjMjlkNDFhMTZhNiIsImNvbXBhcmlzb25LZXkiOiJ2MTozMzFiNDVhZjA1YTcwMTFmZWI4MjhkYTE0Y2ZmMGExZDY5Y2FiNGM1YjI3ZWZjMDY5ODk3YjAwODFhOTkzYTNiIiwic3VtbWFyeSI6Ik5vIHZlcmlmaWVkIGRlZmVjdHMgd2VyZSBmb3VuZCBpbiB0aGUgcmV2aWV3ZWQgY2hhbmdlcy4iLCJmaW5kaW5ncyI6W10sImN1bXVsYXRpdmVDb3N0Ijp7InVzZCI6MC4wNzQyMzI0LCJpbnB1dFRva2VucyI6MTk4MDA2LCJvdXRwdXRUb2tlbnMiOjY4NCwibW9kZWwiOiJncHQtNi4xLXRlcnJhIn0sImN1bXVsYXRpdmVEdXJhdGlvbk1zIjoyNjk0MX0= -->
kleb merged commit fb5430387a into main 2026-10-29 02:32:36 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kleb/VoiceTyper!15
No description provided.