Skip to content

Comments

Share single model across channels and add 2-channel e2e tests#4142

Merged
yujonglee merged 5 commits intomainfrom
devin/1771724573-share-single-model-across-channels
Feb 22, 2026
Merged

Share single model across channels and add 2-channel e2e tests#4142
yujonglee merged 5 commits intomainfrom
devin/1771724573-share-single-model-across-channels

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Feb 22, 2026

Summary

Moves model creation (hypr_cactus::Model::builder().build()) out of the per-channel loop so that a single model is loaded once and shared (via Arc::clone()) across all channel streams. Previously, for 2-channel interleaved audio, two full model instances (weights + VAD) were loaded into memory.

This is safe because each cactus_stream_transcribe_process call runs a complete encode→decode cycle and then calls cactus_reset(), leaving no model state between calls. The per-channel state (audio buffer, confirmation logic) lives entirely in the separate CactusStreamTranscribeHandle instances. Concurrent access is serialized by the existing model_mutex on the C++ side.

Tradeoff: Channels now serialize on the model mutex instead of running in parallel. With ~50-150ms inference per 300ms chunk, this adds at most one inference duration of latency when both channels need the model simultaneously.

Updates since last revision

Added two new e2e tests and a CI workflow to exercise 2-channel inference:

  • e2e_streaming_dual_channel: Creates a single shared Model with two transcribe_stream handles, feeds english_1 to ch0 and english_2 to ch1, asserts both channels produce events.
  • e2e_websocket_dual_channel: Spins up the full TranscribeService, connects via WebSocket with channels=2, sends interleaved stereo PCM (english_1 + english_2), asserts Results messages arrive for both channel_index 0 and 1.
  • .github/workflows/local_stt_e2e.yaml: New workflow running the above tests (plus the existing e2e_streaming) on depot-ubuntu-24.04-arm-8 with the moonshine-base model. Triggers on changes to transcribe-cactus, cactus, or cactus-sys.

Review & Testing Checklist for Human

  • Dual-channel streaming test early-exit: The e2e_streaming_dual_channel test uses tokio::select! over two event streams — if one stream finishes before the other (e.g. shorter audio), the loop breaks and remaining events from the other stream are silently dropped. Verify this doesn't cause false passes or flaky failures.
  • CI passes on ARM: None of these tests could be built/run locally (cactus C++ targets ARM). Confirm the new local_stt_e2e workflow passes end-to-end on the first run.
  • No cross-channel state leakage: With the shared model, confirm that cactus_reset() fully clears all model state (KV-cache, encoder output, persistent nodes) between channel inferences — any missed state would cause one channel's audio context to bleed into the other.
  • Memory improvement: Confirm ~50% reduction in model memory for 2-channel sessions (one model load instead of two).

Suggested manual test plan: Run a real 2-channel transcription session on device and compare transcription quality/latency against the previous 2-model approach.

Notes

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@netlify
Copy link

netlify bot commented Feb 22, 2026

Deploy Preview for hyprnote-storybook canceled.

Name Link
🔨 Latest commit 683c5cd
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote-storybook/deploys/699a7949fb4c240008a9ea66

@netlify
Copy link

netlify bot commented Feb 22, 2026

Deploy Preview for hyprnote canceled.

Name Link
🔨 Latest commit 683c5cd
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/699a79492868d3000875ac2f

Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@devin-ai-integration devin-ai-integration bot changed the title Share single model across channels instead of creating one per channel Share single model across channels and add 2-channel e2e tests Feb 22, 2026
Copy link
Contributor Author

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

View 4 additional findings in Devin Review.

Open in Devin Review

devin-ai-integration bot and others added 3 commits February 22, 2026 01:57
Co-Authored-By: yujonglee <yujonglee.dev@gmail.com>
@yujonglee yujonglee merged commit f5a23ed into main Feb 22, 2026
14 of 17 checks passed
@yujonglee yujonglee deleted the devin/1771724573-share-single-model-across-channels branch February 22, 2026 03: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