Add experimental ZeroGPU STT, LLM, and TTS handlers #783
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.57) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #783"
general
weight: 0.35
jackboyla
Adds optional ZeroGPU STT, LLM, and TTS handlers that share a bounded GPU allocation. Existing handlers retain conversation state, history, streaming, and interruption semantics; model inference runs in the allocated worker.
Closes #782.
Scope
zerogpubackends and optional dependencies.This PR contains no demo changes, Space launcher, deployment scripts, readiness middleware, or browser protocol/UI changes. Those belong to the deployment. The existing private Spaces remain available for integration testing.
Usage boundary
A ZeroGPU application must import
spacesbefore CUDA libraries, callspeech_to_speech.zerogpu.runtime.initialize(...)before ZeroGPU startup, register the returned worker's decoratedlease_workerwith its hosting integration, and select the registeredzerogpubackends when constructing the pipeline. Selecting the CLI backend alone does not perform this startup sequence.runtime.prepare()waits for model warmup; the application decides when to call it and how to display readiness.runtime.prefetch()requests allocation without blocking. Models are selected once per process:STT currently uses Parakeet (default
nvidia/parakeet-tdt-0.6b-v3), and LLM uses the Transformers causal-model path (tested withQwen/Qwen3.5-4B). Adding another TTS architecture requires a loading/synthesis provider, not another conversation-side handler.Review order
1. STT/LLM/TTS
zerogpu_handler.pyfiles and backend registration.2.
zerogpu/runtime.pyand_tts_provider.py: initialization and model selection.3.
zerogpu/_worker.pyand_model_.py: GPU lifecycle, IPC, and model loading.4.
tests/test_zerogpu.py: lifecycle, cancellation, history, and provider coverage.Validation
Rebased onto main
5108a3ea, including PR #792 and the WebRTC audio-clearing fix. The main ZeroGPU Space is deployed at4874b621a067b2d44bba4b2fb89771ac0c766c59with library source atf1a01e12. Its live browser checks passed on desktop and mobile. An automated conversation test cancelled the first response by speech, then verified that the completed reply remembered Alex (1.23 s server E2E).251 targeted Python tests passed (ZeroGPU, backend registry, Realtime pipeline builder, latency tracking, and WebRTC). All 62 frontend adapter/WebSocket/WebRTC tests passed. Repository-wide Ruff and formatting checks passed; Mypy passed for 169 source files.
Real ZeroGPU integration tests used external private Spaces with all three models on CUDA. Qwen and Kokoro both passed automatic turns, interruption, and conversation memory. Individual warm server E2E measurements reached 1.15 s and 1.03 s respectively; these exclude browser playback and are not a controlled model benchmark.
The simplified cancellation path was also tested in the Qwen lab at
d9d5b4dc8c84ef5a00264da1701fe450f23b61df: speech cancelled the first response, the next response remembered Alex, and the second reply measured 1.14 s server E2E. Removing deployment files does not alter that inference implementation. The author also manually tested the deployed demo using a microphone and confirmed that it worked well. That testing covered an earlier deployed revision; the subsequent cancellation refactor was validated with the automated real-ZeroGPU tests described above.A regression test reproduces allocation-deadline truncation through the real worker generation function and native LLM handler. Expiry now produces an error terminal with incomplete history, while normal completion and caller abandonment retain their semantics. The independent reviewer rechecked the fix and ran 16 LLM/lease-broker tests successfully.
The 120-second allocation update passed all 59 ZeroGPU tests and was exercised in the live Space. The deployment uses the existing frontend startup-greeting hook: a browser test confirmed exactly one spoken greeting after model readiness, with generated audio received. Greeting UI/configuration remains outside this library PR.
Experimental limits
Multilingual follow-up: automatic transcription language metadata and session reset, shared model-language dropdown, 114 routing/pipeline tests passing, and real text language detection checked for all seven enabled languages. Live browser verification confirmed the seven enabled choices plus Auto, accepted a French session selection without protocol errors, and completed a French text-prompt response with generated audio. The startup greeting also passed.