Skip to content

Reuse shared host CTC decoding across ASR models - #1214

Merged
0xShug0 merged 1 commit into
mainfrom
refactor/shared-ctc-callers
Nov 5, 2026
Merged

0xShug0 merged 1 commit into
mainfrom
refactor/shared-ctc-callers

Conversation

@0xShug0

@0xShug0 0xShug0 commented Nov 5, 2026

Copy link
Copy Markdown
Owner

OWSM-CTC, GigaAM CTC, SenseVoice and Granite5-ASR duplicate CTC best-path decoding. Reuse the existing CtcHostDecoder for blank/repeat collapse and frame spans, and for SenseVoice's host argmax. Production code is reduced by 29 lines.

  • Keep OWSM device argmax, overlapping-window merging and partial-text publication unchanged.
  • Preserve GigaAM's first-frame indices and leave its RNNT branch unchanged.
  • Keep SenseVoice vocabulary decoding, language/event tags and ITN handling local.
  • Keep Granite confidence scoring, word construction and timestamp conversion local.
  • Cache the winning float in the shared argmax loop, preserving strict-greater comparisons and first-winner ties while avoiding repeated indexed loads.

No neural graph, backend kernel, weight, spec, public option or loading changes.

Validation

Debug builds with eight host threads; model runs performed sequentially on CPU, CUDA and Vulkan against main 28783225.

  • 213 paired requests matched exactly: 153 CLI request pairs and 60 real-server request pairs. Compared transcripts, partial-text events, word timestamps, confidence values, speech segments and all non-timing server response fields.
  • Covered short and 167-second long-form inputs, stereo/native-rate audio, fixed and unchunked execution, requests after long inputs, streaming where supported, translation, language selection, tags and ITN.
  • GigaAM coverage includes multilingual CTC, multilingual large CTC, v3 CTC, v3 e2e CTC, v3 RNNT and v3 e2e RNNT.
  • Server checks include lazy loading, model switching with a one-model resident limit, explicit unload/reload and identical output after reload.
  • Shared CTC tests pass, including 8,192 exhaustive short label sequences, blank-separated repeats, frame boundaries, empty/all-blank input, argmax ties/nonfinite inputs and existing alignment checks. All 14 Granite timestamp/confidence tests pass.

SenseVoice automatic VAD was tested with native 16 kHz input; 24 kHz recordings used explicit fixed chunking, matching the existing VAD input-rate requirement.

Performance

Counterbalanced A-B-B-A sessions: short warmup, two different long recordings (167 and 328 seconds), then a short request. RTF excludes warmup. All outputs match across all four legs.

Model Backend Main RTF Refactor RTF Generation-time change
OWSM-CTC CUDA 0.001900 0.001863 −1.95%
GigaAM CTC Vulkan 0.000680 0.000662 −2.58%
SenseVoice CPU 0.019032 0.019082 +0.26%
Granite5-ASR CPU 0.020787 0.020483 −1.46%

These small differences do not establish speedups. No sustained performance regression was observed in the counterbalanced checks; all other backend combinations passed the full correctness matrix.

@0xShug0
0xShug0 merged commit 3392e1c into main Nov 5, 2026
7 checks passed
@0xShug0
0xShug0 deleted the refactor/shared-ctc-callers branch November 5, 2026 23:28
0xShug0 pushed a commit that referenced this pull request Nov 8, 2026
* sense_asr: return word timestamps from CTC emission frames

SenseVoice decodes with greedy CTC, and since #1214 its decoding goes
through CtcHostDecoder, which already reports each token's frame span.
Those spans were dropped after text decoding. Keep them and, when the
request sets return_timestamps (or the CLI gets --words-out), return them
as word timestamps.

- Encoder output frames start with the query-token prefix (language,
  event, emotion, ITN); drop it, then convert at one LFR frame
  (frame_shift_ms * lfr_n = 60 ms) to the input's sample rate.
- Chinese, Japanese kana and Thai give one entry per character; other
  scripts join SentencePiece pieces into words at the boundary marker.
  Punctuation joins the preceding word without extending its time;
  language/event/emotion tags are skipped.
- Chunked offline runs and streaming windows shift times to the whole
  input.
- Times are token emission frames, as for GigaAM and Granite, not a
  forced alignment: starts track onsets, ends fall at the last emission.

The default path is unchanged: without return_timestamps no words are
built and transcripts are identical. The spec gains the word_timestamps
capability and the return_timestamps request option, so the C API's
audiocpp_model_supports_timestamps() now reports 1 for sense_asr; no C
ABI declarations change.

Grouping and frame conversion live in sense_asr/word_timestamps.h,
covered by the new sense_asr_word_timestamps_test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* sense_asr: append only new words per streaming window

Streaming windows are final once decoded, but each window republished
the whole word list through publish_transcript(), so every stream event
carried all words so far. On a 167 s clip with 2 s windows the events
held 19,857 words for a 479-word transcript, growing quadratically with
stream length, and a caller appending event words got duplicates.

Use append_transcript() with only the window's text delta and words, as
other finalized-segment streams do. The transcript is joined exactly as
before, and the session no longer keeps its own copy of the words. Also
make the word-boundary marker a constexpr string_view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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