Repository navigation
feat(stt): Parakeet request seconds by caller (omi_parakeet_request_seconds) - #22902
Conversation
…econds) Client-side histogram in every backend Parakeet caller (app proxy, sync fresh/backfill, batch recovery, shadow, voice message) so pool time per caller is measurable before shrinking the GPU pool to a live-only floor. Metrics only; sync GMP keep rule extended and pinned by tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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: c18f0390ed
ℹ️ 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".
| # Preserve the existing deferred STT boundary: its transitive encryption | ||
| # module requires runtime secrets and cannot join credential-free imports. | ||
| from utils.stt.pre_recorded import prerecorded_from_bytes, modulate_prerecorded_from_bytes | ||
| from utils.stt.parakeet_request_metrics import parakeet_caller |
There was a problem hiding this comment.
Move the metrics import to module scope
Move parakeet_caller to the module-level imports rather than extending the legacy deferred-import block. Unlike the secret-dependent STT import immediately above it, this metrics helper is import-safe, and leaving it inside transcribe violates the backend's explicit module-scope import convention and obscures the dependency during normal module loading.
AGENTS.md reference: backend/AGENTS.md:L161-L169
Useful? React with 👍 / 👎.
| def test_prerecorded_v2_request_is_labelled_with_the_context_caller(): | ||
| client = _patched_client(_response()) | ||
| before = _count('shadow', 'v2') | ||
| with patch('httpx.Client', return_value=client), parakeet_caller('shadow'): |
There was a problem hiding this comment.
Patch the imported client reference directly
Replace this string-based patch('httpx.Client', ...) usage, including the two repetitions below, with patch.object on the reference used by pr. The repository specifically prohibits string-based patch targets because they can silently patch a different reference after import structure changes, allowing these attribution tests to pass without intercepting the production call.
AGENTS.md reference: backend/AGENTS.md:L227-L227
Useful? React with 👍 / 👎.
Router test harnesses stub the utils.observability package without its sync_phases submodule; utils.chat now imports the metrics module, so the module-level import broke those suites. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… counts (#22920) ## Summary `batch-two-workers` in the Sync Cloud Tasks Stack Gauntlet still fails now and then with "a segment was computed more often than it was leased across replicas", even after #22866. PR #22902 hit it twice at `3508c7ca`, and that diff can't reach batch compute. The check compared compute evidence with the job's `attempt` field. That field is a retry budget, not a count of lease grants: a refund before compute lowers it. The check also printed no counts, so the CI failures couldn't be diagnosed. Changes (test harness only): - **Lease evidence.** `testing/sync_cloud_tasks_stack/batch_worker.py` wraps `Scheduler.pull` and `Scheduler.defer` in the stack worker. They emit `lease_granted` and `lease_refunded` evidence with the segment id, attempt and worker name. No production code changes. - **New bound.** `batch.py` checks `computes <= grants` and `results <= grants` for each segment. - **Counts on failure.** The failure message now includes grants, refunds, attempt, computes, results, state and failure. - **Drift is visible, not fatal.** A mismatch between `attempt` and `grants - refunds` prints and is counted as `attempt_drift` in `batch_two_workers_verified`. - **Unchanged assertions.** These still apply: one paid recovery call, one committed result log entry per segment, an intact predecessor chain, and capture order. ## Why this doesn't hide a paid-twice bug - **The counter isn't paid STT.** It counts Parakeet `transcribe_batch` calls, which run on our own GPUs in prod. Paid STT is quarantine recovery only, and `paid_calls == 1` is still asserted. - **Only one path lowers `attempt`.** `pull` is the only lease grant. `defer` is the only call that lowers `attempt`, and in this lane it runs only before compute. The `HeldWork` path is fenced off because `_BATCH_LANE_READY = False`. The `FatalGpuError` path is CUDA-only. - **Publication stays fenced.** It is checked by `owns_lease` plus `compute_admission_token`. - **Local stress agrees.** About 25 local two-worker runs, including some with a 3s/1s lease/heartbeat, never had computes exceed `attempt`. Investigation notes: `data/run-2026-10-13-two-lane-nemotron/gauntlet-double-compute-2026-10-20.md` in the omi-workspace repo. ## Test plan - [x] `backend/testing/sync_cloud_tasks_stack/run.sh --only batch` passed locally (`attempt_drift=0`, `paid_calls=1`, 5 segments, 2 replicas). - [ ] CI: Sync Cloud Tasks Stack Gauntlet. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/22920?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/22920?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F22920&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
… counts
batch-two-workers still failed occasionally ("a segment was computed more
often than it was leased") after BasedHardware#22866, e.g. PR BasedHardware#22902 at 3508c7c, whose
diff cannot reach batch compute. The check compared compute evidence with
the job's attempt field, which is a retry budget (a pre-compute refund
lowers it) rather than a grant count, and printed no counts, so CI failures
were undiagnosable.
The stack worker now records lease_granted / lease_refunded evidence by
wrapping Scheduler.pull/defer (test harness only). The scenario asserts
computes <= grants and results <= grants per segment, includes grants,
refunds, attempt, computes, results, state and failure in the failure
message, and reports attempt drift (attempt != grants - refunds) as a
visible, non-fatal attempt_drift count. The paid-once and committed-once
assertions are unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The Parakeet GPU pool's
/v2/transcribetraffic (83–86% of its request time) is not split by caller, so we cannot tell how far the pool can shrink once sync/backfill go dark. This adds a client-side histogram in every backend caller so request time per caller is measurable. Metrics only. No request, response, retry or routing behaviour changes, and no Parakeet image rebuild is needed.New metric:
omi_parakeet_request_seconds{caller,route}(Histogram). It records the wall time of each backend HTTP request to Parakeet transcribe, failures included.sum by (caller) (rate(..._sum[1h]))is the pool-seconds each caller holds.app_proxyrouters/stt.pyPOST /v1/stt/transcribe(mobile "Omi Parakeet" upload proxy)sync_fresh/sync_backfill/sync_unknownpre_recorded.parakeet_prerecorded_from_bytesinside a sync attempt; derived from the existing sync-phase attempt lanebatch_recoverybatch_pipeline/quarantine_recovery.transcribeshadowconversations/transcription_shadowfinal-pass shadowvoice_messageutils/chat.pyvoice-message STT (diarize=False)otherparakeet_prerecorded*callThe live
/v3/streamand window/v1/transcribepaths on backend-listen are not touched; they already haveomi_stt_window_post_seconds.Scrape:
backendkeepsomi_.*already.cloud_run_gmp_sync.yaml(backend-sync, backend-sync-backfill, backend-integration) getsparakeet_request_seconds(_.*)?added to its keep rule, pinned by tests (FC-metric-dropped-by-scrape-allowlist). Sync series are queryable in GMP directly. They are not added to the in-cluster stackdriver exporter.Failure-Class: none
The
fix:commit repairs a test-stub import broken earlier in this same PR; no shipped failure.Deploy
The backend and sync Cloud Run services need a normal backend-stack deploy for the metric to appear. No chart, listen, pusher or Parakeet rollout is needed.
Tests
tests/unit/test_parakeet_request_metrics.py: caller resolution (explicit, then sync lane, then other), failures are observed, v2 labelling, the 404 to v1 fallback counts both routes, sync-attempt lane attribution, and both GMP keep rules keep the metric.test_stt_router.py: app proxy attribution.test_attach_cloud_run_gmp_sidecar.py: the sync keep rule retains the family.BACKEND_UNIT_TEST_FILE_LIST=... nice -n 19 bash backend/test.shon the four files above (all pass) plus the quarantine-recovery, transcription-shadow, sync-phase and voice-message suites. All assertions pass. Two files tripped the local fast-unit CPU-time guard on unchanged tests while the host was under load average 11.🤖 Generated with Claude Code