Repository navigation
fix(parakeet): bound backfill work and add demand-based packing - #21910
Conversation
Failure-Class: new
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f9e495583b
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| service._packing_enabled = packing | ||
| service.batch_engine._packing = packing |
There was a problem hiding this comment.
Recreate the engine when enabling packing
When this script runs with the documented dev defaults, BatchEngine was constructed with PARAKEET_MAX_INFLIGHT=2, because the dev values do not override that default. Mutating _packing directly bypasses the constructor guard requiring one in-flight batch and leaves both the semaphore and VRAM budget configured for two, so the packing-on rows do not qualify the production singleton scheduler. Start a fresh service with PARAKEET_MAX_INFLIGHT=1 for packing runs, or fail unless the existing engine already has that configuration.
Useful? React with 👍 / 👎.
| for _ in range(100): | ||
| if service.ACTIVE_BATCH._value.get() > 0: | ||
| break |
There was a problem hiding this comment.
Wait for backfill GPU dispatch before probing live work
ACTIVE_BATCH increments at the beginning of the HTTP handler, before the upload is written, split, enqueued, or dispatched to the GPU. This loop can therefore finish while the 360-second request has not started any backfill quantum, allowing the first live probes to run ahead of it and making the reported live latency nondeterministically fail to exercise the intended residual wait behind a running 120-second quantum. Synchronize on an observed in-flight backfill batch instead of the HTTP activity gauge.
Useful? React with 👍 / 👎.
| resp = await client.post( | ||
| self._url, | ||
| files={'file': ('audio.wav', wav, 'audio/wav')}, | ||
| headers={'X-Omi-STT-Surface': 'live-stream'}, |
There was a problem hiding this comment.
Handle queue expiry before marking legacy windows live
When packing is enabled, this marker promotes every ParakeetStreamingSocket POST to the live lane, where Parakeet applies the default eight-second queue deadline and can return a signaled 503. Unlike the modern windowed caller, _transcribe_chunk catches that response and returns an empty list after _flush has already removed the PCM from its buffer, while leaving the socket healthy, so an overloaded legacy session silently loses the entire window without retry or provider failover. Either retain backfill treatment for this caller or handle the queue-timeout signal through its replay/failover path before rollout.
Useful? React with 👍 / 👎.
| - type: Pods | ||
| pods: | ||
| metric: | ||
| name: parakeet_{{ $lane }}_queue_age_seconds | ||
| target: | ||
| type: AverageValue | ||
| averageValue: "{{ $target }}" |
There was a problem hiding this comment.
Preserve live queue peaks between Prometheus scrapes
The new HPA consumes an instantaneous queue-age gauge, but both environment values scrape Parakeet only every 15 seconds while live requests expire after at most eight seconds and the gauge returns to zero once they dispatch or expire. A complete burst-induced queue episode can therefore occur between scrapes and never reach this metric; with demand mode also removing the persistent p99 and GPU scaling inputs, such bursts can produce live queue timeouts without a queue-age scale-out recommendation. Scrape faster than the live deadline or export a signal that preserves queue peaks across the scrape interval.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1d76e2887b
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| type: AverageValue | ||
| averageValue: "{{ $target }}" |
There was a problem hiding this comment.
Scale on the maximum per-pod queue age
When demand mode is enabled and queued work is concentrated on one pod while other pods report zero, AverageValue dilutes that pod's queue age across the entire replica count. At the production floor of three replicas, a live queue must therefore age past 2.25 seconds before satisfying the configured 0.75-second target; with eleven replicas, the effective threshold exceeds the eight-second live deadline, so requests can expire without this metric recommending the final scale-out. Export the fleet maximum as an external metric, or otherwise preserve the maximum pod recommendation instead of averaging this non-additive age signal.
Useful? React with 👍 / 👎.
…rt unchanged The #21910 helm guard requires the Parakeet pod template to match main apart from the reviewed dark flags, so a chart env for PARAKEET_LID_MODEL fails it. The model now defaults to whisper-base when unset; "off" (or any unknown value) is the kill switch. GPU worker tests pin it off so they never load the real model. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…P58) (#23264) ## Summary **Stacked on PR A (#23263, `p58/phase0-vendor-fail-fast`, merged in with a merge commit): merge PR A first; this PR's own change is everything after it.** Self-hosted spoken-language gate for prerecorded STT routing (P58, approved by David 2026-10-22). Today a vendor (Modulate) LID probe decides whether `multi`-language audio may go to Parakeet, which transcribes only 25 European languages. That probe costs ≈$34/day, blocked English entirely when Modulate ran out of credits (10-22 02:00–04:00Z), and misroutes: staging canary 10-22 05:29Z sent 6 s Arabic to Parakeet as `en` 0.926, and soak003 sent 6 s Chinese as `en` 0.80–0.84. - **Parakeet** `POST /v2/language`: Whisper-base language-token head (fp16, Apache-2.0) through the GPU worker queue, loaded before the VRAM baseline; returns `p_supported` (summed probability of the 25 TDT languages), the top language and a route. Parakeet only if `p_supported ≥ 0.95` (≥6 s) or `≥ 0.985` (1–6 s); never under 1 s. `PARAKEET_LID_MODEL` defaults to `whisper-base` in code (the chart is unchanged, per the #21910 pod-template guard); `off` is the kill switch. A load failure leaves transcription serving. `/v2/transcribe` also counts transcript text language (`parakeet_output_language_total`) as the wrong-language alarm. - **Backend shadow** (default on, `STT_PRERECORDED_LANGUAGE_GATE_SHADOW=false` kills it): every unknown-language probe also asks the gate; `omi_stt_language_gate_shadow_total` records self vs vendor; the dangerous direction logs `event=language_gate_shadow_disagreement` with bounded codes and scores only. Routing unchanged. - **Enforcement** `STT_PRERECORDED_LANGUAGE_GATE_PERCENT` (default 0; uid cohort on legacy sync, audio-hash cohort for voice): the gate replaces the vendor probe. The backend re-derives the threshold rather than trusting the service `route`, and requires the top language to be supported. Any gate failure falls back to today's vendor probe path. Batch intake stays shadow-only until its GPU worker accepts `self_lid` evidence (Phase 4). MMS-LID-126 scored better offline but is CC-BY-NC-4.0, so it is not used. ## Evidence (offline, through this serving code; not prod audio) FLEURS 15 languages × 60 clips (full, 6 s, 3 s, 8 kHz copies) + owned synthetic corpus, 4,191 clips, 2,349 unsupported (`/Volumes/Ephemeral/scratch/p58-language-routing/eval/out/gate-whisper-base.final.jsonl`): | | Result | |---|---| | Unsupported → Parakeet at 0.95/0.985 | **0 / 2,349** (2 at 0.90/0.97: hi→ro 0.922, id 3 s→it 0.978) | | Non-speech → Parakeet | 0 / 27 | | Arabic canary (Modulate `en` 0.926) | `ar`, p_supported 0.0072 → multilingual | | soak003 zh 6 s (all 9 codec/noise variants) | `zh`, p_supported ≤ 0.011 → multilingual | | Supported leak to paid | full 6/420 · 6 s 21/420 · 3 s 189/420 · 8 kHz 100/420 | | Latency | p50 0.08 s per clip on Apple MPS (L4 fp16 to be measured on the canary pod) | Production enforcement is gated on the shadow readout (dangerous-direction disagreement ≤0.1% of self-Parakeet segments, output alarm no worse than baseline) and a serving-SHA staging multilingual mini-soak. ## Ramp plan (`STT_PRERECORDED_LANGUAGE_GATE_PERCENT`) - Cohorts: 5% → 25% → 100%, ~30 min holds (David: fully rolled out or ruled not worth doing by 2026-10-22 11:50Z). - Clean metrics: shadow dangerous-direction ≤0.1%; `parakeet_output_language_total` non-P25 share ≤ baseline; sync `upstream_error` and empty-ASR rates flat; multilingual share within ±2 pp of shadow; Parakeet p99/GPU in bounds. - Expander: two-lane lead; p58 owns the evidence. Rollback: percent 0 (vendor probe path unchanged); gate off: `PARAKEET_LID_MODEL=off` or `STT_PRERECORDED_LANGUAGE_GATE_SHADOW=false`. ## Deploy Parakeet GPU image (prod-omi-backend; no chart change): 1 pod first, check VRAM after load (Whisper-base fp16 ≈150 MB) and `/v2/transcribe` p99, then fleet. Cloud Run backend services (config train) for the backend half. No new env needed for shadow; enforcement percent is a later env flip. Failure-Class: FC-deterministic-provider-rejection-burns-connect-retries Line-Count-Exception: backend/utils/sync/pipeline.py | 3659 -> 3660 | passes the uid as the language-gate cohort key at the existing resolve_file call ## Test plan - `BACKEND_UNIT_TEST_FILE_LIST` via `backend/test.sh`: `test_prerecorded_language_gate.py` (38), `test_batch_audio_language.py` (62), `test_parakeet_endpoints.py` (62), `test_parakeet_gpu_worker.py` (72), `test_parakeet_language_gate.py` (19), all pass. - `make preflight` (local lane) passed; feature-flag registry OK. - Real model: `language_gate.load('mps')` over the 4,191-clip eval (table above). - Independent GLM review (SHIP-WITH-FIXES, no below-threshold Parakeet path found); its fixes are in the last commit: GPU priority lane for language ID, `/v1` prerecorded wrong-language alarm, 16 MiB probe cap. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Callers reach Parakeet at parakeet.omi.me, whose Ingress lists only the transcribe, stream and health prefixes, so every language-gate call 404ed at the load balancer (prod 10:47Z: new cfbcf20 pods served /v2/transcribe and received zero /v2/language requests). Add the path in prod and dev. The #21910 pod-template guard admits exactly that one path, on the transcribe backend; any other Ingress change still fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sync, move ramp to 10-23 (#23282) ## Summary Three P58 language-gate follow-ups (lead rulings 2de1ea, ca3cc3): 1. **Sync metrics were dropped (fix).** `backend/deploy/cloud_run_gmp_sync.yaml` keeps only allowlisted `omi_*` names on backend-sync and backend-sync-backfill. `omi_stt_language_gate_*` (#23264) and `omi_prerecorded_vendor_*` (#23263) were not on the list. Legacy sync makes almost all prerecorded probes. Prod 10:05–10:35Z after train T: 23,015 vendor probes on sync with 0 shadow series, against 43/43 on backend. So the shadow readout that gates enforcement, and the Phase 0 vendor burn and breaker metrics, were invisible there. The PR adds both prefixes, plus a test that reads the real keep regex and asserts every such collector matches it. 2. **`/v2/language` was never routed (fix).** The `parakeet.omi.me` Ingress lists only `/v1/transcribe`, `/v2/transcribe`, `/v3/stream` and `/health`. Every gate call 404ed at the internal load balancer: on 10:47Z, the new cfbcf20 pods served `/v2/transcribe` and received zero `/v2/language` requests. This PR adds the path in prod and dev values. The #21910 pod-template guard now admits exactly that one Ingress path, on the same backend as `/v2/transcribe`; new mutation cases reject a different backend or any other path. It ships with a `gcp_parakeet` helm apply (an Ingress URL-map change, no pod restart from it). Rollback: `helm rollback prod-omi-parakeet`. Callers fall back to the vendor probe either way. 3. **Registry (chore).** The `STT_PRERECORDED_LANGUAGE_GATE_PERCENT` ramp `done_by` moves 2026-10-22 → 2026-10-23, with the ruling in the notes. On 10-22, the lead (ruling ca3cc3, under David's 6 h rule) ruled the same-day rollout not worth finishing: shadow accrues and enforcement ramps 5/25/100 off-peak on 10-23. The rendered doc was regenerated, and `check_feature_flag_registry.py` reports OK. No behaviour change. The sync allowlist takes effect on the next Cloud Run deploy of backend-sync and backfill, which must land before the 10-23 ramp readout. Failure-Class: FC-metric-dropped-by-scrape-allowlist ## Verification - `test_batch_audio_language.py` (new allowlist test), `test_attach_cloud_run_gmp_sidecar.py`, `test_fleet_deployment.py`, `test_parakeet_request_metrics.py`, `test_monitoring_gmp_shadow.py`: pass via `test.sh`. - `test_audio_fleet_helm.py` and the other 11 files that render Parakeet/Ingress charts: pass (dev and prod against current main). - Prod (ro-prod GMP): `omi_stt_language_gate_*` series exist only for service_name=backend. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Parakeet averaged 6.04% GPU while desired replicas averaged 11.19 over the measured 24h. All 43 scale-ups were attributed to p99 (24) or active requests (19); the raw p99 includes queueing and v2 speaker post-processing. This PR makes packing and demand scaling independently opt-in.
The dated dev qualification receipt is committed for review. Adapter scoping builds on #21673; its production Helm release is still a separate operator step.
Validation: normal pre-push passed at
1d76e2887b3c6100547c889d385ba23a7cd37db5(37-check manifest, zero type errors, source closure, 257 selected unit tests across 8 files, format checks; one selected suite at a time under nice19). Remote isolated dev L4, public LibriSpeech fixture, 40 synchronized mixed 24s-live/120s-backfill waves per step: packing off/2 p95 2.059s, on/2 2.059s, on/3 2.453s; no refused or empty responses; final loaded 1Hz DCGM nonzero; actual decoder graphs disabled. A separate final-source 360s-backfill probe yielded live p95 2.139s and v2 timestamps through 359.84s. Qualification used the resident dev image plus source overlay, not a newly built immutable production image; deployment/canary and long-input language/boundary quality remain promotion gates. Production was read-only; no Firestore writes or production API calls.Ramp and rollback: packing runbook. Dark merge -> immutable image/adapter discovery and streaming-marker producer rollout -> <=5% packing for >=3h -> demand scaler with max unchanged -> later reversible downscale. Higher density has a separate opt-in values file and dated dev receipts; no pool consolidation or floor cut is proposed. $0 savings booked: only removed billed node-hours count; do not price desired-replica reductions as savings.
Verification commands: the focused file-list runner used
BACKEND_UNIT_TEST_FILE_LIST=/tmp/pk.txt BACKEND_PYTEST_WORKERS=1 BACKEND_PYTEST_XDIST=0 nice -n 19 bash test.shfrombackend/; repository checks usedOMI_PR_BODY_FILE=/tmp/parakeet-packing/pr-body.md nice -n 19 make preflight. The shared submit/scheduler primitive owns prevention; regression coverage uses the existing unit gate rather than a new standalone CI checker.Grok FIX-FIRST follow-up: the fleet gate now permits exactly the two
falseenv additions in dev and prod, while comparing every other pod-template field and non-HPA object with main; mutation tests reject enabled/duplicate flags and unrelated env/image/affinity changes. Short backfill files (including v2 caller-owned PCM16) retain their original path/subtype. Real-file tests traversesubmit_audioand the realBatchEngine; split FLOAT quanta exercise its duration reader. The 40-wave receipt is delivery/DCGM evidence only; the separate 360s probe supplies split/yield/time-coverage evidence, with no boundary-word or speaker-parity claim. The remote GPU receipt predates this short-file fix; repeat qualification on the immutable rollout image before promotion.Merged main through
1dd3b3541098097ace200bbf50ca63b2417ba8b0with merge commits. Follow-up targeted run: 127 packing/fleet tests passed; schema inventory had 12 passes and the same unrelated failure atgetDailySummaries(app/lib/backend/http/api/users.dart:764). Its test/scanner and every scanned input are identical to main; no schema changes are included here. Terminal CI and Grok/lead approval remain required.Product invariants affected
none — no locked-invariant paths are selected. Preserve complete capture/tail coverage, timestamps, speaker identity, live delivery and warm processing deadlines.
Failure-Class: new
Line-Count-Exception: backend/utils/stt/streaming.py | 2369 -> 2373 | Add the live-origin header at the existing HTTP call site; extracting four call arguments would obscure the wire contract.