Skip to content

Profile batch worker stages and connect queue-age scaling input - #22324

Closed
Git-on-my-level wants to merge 4 commits into
mainfrom
lane/sol-worker-profile
Closed

Git-on-my-level wants to merge 4 commits into
mainfrom
lane/sol-worker-profile

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Production has one batch worker, a four-node dedicated L4 pool cap, and no working batch queue-age input to HPA. The adapter APIService is healthy, but its discovery lacks omi_batch_pipeline_ready_age_seconds; the exact external metric request returns NotFound. The worker's PodMonitoring feeds managed Prometheus while the adapter reads local Prometheus, where the worker series is absent.

Add the local worker scrape and scoped, freshness-filtered external adapter rule. Add content-free stage histograms across the real pump/model chain so pull, maintenance, worker flight, encrypted persistence, publication and ordered merge can be compared before selecting a concurrency change. Failed operations count; parent/child timings are documented. Replicas, HPA enablement, admission, model concurrency, ordering, privacy and lease behavior stay unchanged.

Validation: 142 focused tests passed in separate processes (stage timings 3, pump 14, worker 91, runtime 16, chart 18). The stage test drives the real Pump + PipelineWorker to committed state and tests failed timings and telemetry failure isolation. make preflight passed all 33 selected checks; runtime image source closure passed for all 14 images. Local /metrics health-server tests exercise the registry path. Existing PR #22201 mixed-fleet virtual-clock scenario passed at its own head; its modeled timings are not a production capacity benchmark. No GPU, multi-node, deployment or load-hold acceptance is claimed.

Live investigation used ro-prod only, aggregate metrics/log output, copied KUBECONFIG, explicit production context and cleared copied auth caches. The observed worker digest is sha256:fa484829a2a7e5c3f10d9f7013250f8e23dbebe893c8457bc067647d375a8a72, bound to build head 6fb2c6f7fad7145852fa0998f60a89ecb09c04ba by deployment run 39137005992. No production write was performed. After separate deployment approval, verify fresh external series for all priorities and qualify scaling before enabling HPA; the current pool cap and cold-start delay still apply.

Failure-Class: none

This change repairs an omitted metrics connection and adds the missing measurements; it does not change a domain mutation contract. No merge or deploy is requested.

View guided diff Turn on auto-fix

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T07:35:13.544052Z ba0d390 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20ab91afd3

ℹ️ 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".

Git-on-my-level and others added 3 commits October 19, 2026 14:02
…dapter rule

- Inventory batch-pipeline-worker-metrics in expected-targets.prod.yaml.
- Add the omi_batch_pipeline_ready_age_seconds external rule to the reviewed
  adapter upgrade expectation (diff_prod_adapter.py), rejecting any modified
  live copy.
- Contract fixture models the pre-upgrade live config and finds the listen
  rule by name instead of by list position; add exact/modified/live-drift
  tests for the new rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
run_process now constructs SynchronizedWorker(..., timings=timings); the
Sync Cloud Tasks gauntlet's CpuSynchronizedWorker override rejected that
keyword, so batch-worker-1 exited before readiness.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level force-pushed the lane/sol-worker-profile branch from fb6ee9b to 2382fc4 Compare October 19, 2026 07:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2382fc4c1b

ℹ️ 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".

Comment thread backend/diarizer/batch_pipeline.py Resolved
The fetch_decode timer previously wrapped prefetch.take(), so under the
production IO concurrency it measured only the later Future.result() wait;
a decode overlapping earlier GPU work appeared nearly free. Wrap the decode
callable submitted to the prefetch executor instead, keep the no-prefetch
fallback timing decode directly, and document the measurement point.
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor run summary (rebase + review-thread completion):

  • Confirmed the telemetry-inventory thread was already addressed in-tree (batch-pipeline-worker-metrics entry in expected-targets.prod.yaml); resolved that thread.
  • Rebased the branch onto current main (was 18 behind, DIRTY). Upstream's async worker IO overlap and leader-lease changes conflicted with the stage instrumentation; resolution keeps upstream's structure and re-applies the timing wraps at the new call sites, including executor-side timing for overlapped encrypted persistence.
  • Follow-up review finding fixed in ba0d390b15: prefetched fetch/decode is now timed where it executes (the callable submitted to the prefetch executor) instead of at the later Future.result() wait, so fetch_decode no longer underreports decodes that overlap earlier GPU work; the measurement point is documented in backend/docs/batch-pipeline-worker.md.
  • Verification: 224 focused backend tests passed across the seven touched suites (stage timings, pump, worker, runtime, chart, adapter HPA contract, telemetry contract), plus an ad-hoc run proving fetch_decode records exactly once per item under the production BATCH_PIPELINE_WORKER_IO_CONCURRENCY=3 prefetch path. Full CI at head: 33 success / 23 skipped / 0 failures. Both Codex threads resolved.

No merge or deploy action taken.

Git-on-my-level added a commit that referenced this pull request Oct 24, 2026
* feat(observability): profile dedicated batch pipeline stages behind a dev-default flag

Add metrics-only per-stage wall-clock histograms for the dedicated batch GPU
worker, adopting the instrumentation design of stalled PR #22324 (StageTimings
context manager, static stage labels, omi_batch_pipeline_stage_seconds) without
its HPA/scrape changes.

Pump stages: pump_cycle, maintenance, pull, admission, renew, publication,
ordered_merge, projection, worker_flight. Worker-chain leaves: fetch_decode,
vad, windows, asr, asr_recovery, flight_segment, flight_diarize, diarize,
persist, cuda_sync. Timings include executor wait and failed calls; prefetched
decode and submitted persist are observed on the background IO threads where
they run; optional or skipped stages emit no samples; telemetry failures are
swallowed and never invalidate compute or durable transitions.

BATCH_PIPELINE_STAGE_PROFILING_ENABLED gates histogram creation once at worker
startup: default on only for OMI_ENV_STAGE=dev, prod/unset off, explicit
true/false override (local/offline opt in). The histogram registers on the
dedicated worker's explicit CollectorRegistry (/metrics). No runtime behavior,
precision or concurrency change; cuda_sync times the pre-existing synchronize,
profiling adds no new GPU synchronization. Speaker embedding stays inside the
pyannote adapter seams (diarize / flight_diarize) and is documented as not
separately timed.

Failure-Class: none

* feat(observability): separate batch artifact and speaker embedding stage timings

Observe authenticated download, decrypt, decode, encryption and upload on the
worker's actual IO thread, plus serial and packed pyannote embedding forwards.
Keep labels static and telemetry failures isolated from compute and custody.

Failure-Class: none

* docs(observability): clarify batch timing scope and submillisecond buckets

Failure-Class: none

* feat(observability): profile retained batch source audio leaves

Include generation-pinned retained downloads, framed decryption and codec
decoding in the dedicated worker's scoped leaf timers. Non-worker callers
remain unprofiled; ownership, validation and source bytes are unchanged.

Failure-Class: none
@Git-on-my-level
Git-on-my-level marked this pull request as draft November 4, 2026 07:01
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review November 4, 2026 07:27

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 issues found across 14 files

Confidence score: 4/5

  • test_batch_pipeline_stage_timings.py can skip diarize for the 2-second fixture when short-speech skipping is enabled, so the test may fail before checking telemetry. Pin the relevant stage flag.
  • batch-pipeline-worker.md names stage labels that differ from the runtime values, which could lead to dashboards querying the wrong labels. Document the exact emitted values.
  • batch-pipeline-worker.md overstates what fetch_decode timings cover: executor queueing and the later future.result() wait are excluded. Clarify that scope.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/tests/unit/test_batch_pipeline_stage_timings.py">

<violation number="1" location="backend/tests/unit/test_batch_pipeline_stage_timings.py:36">
P2: This integration-style assertion is environment-dependent: enabling the short-speech skip causes the 2-second fixture item to bypass `diarize`, so the test fails before validating telemetry. Pin the relevant stage flags in this test, as the worker fixture does.</violation>
</file>

<file name="backend/docs/batch-pipeline-worker.md">

<violation number="1" location="backend/docs/batch-pipeline-worker.md:216">
P3: The stage label values are not documented for most leaves. The runtime emits `windows`, `asr_recovery`, `diarize`, `persist`, and `cuda_sync`, not the prose names here; list the exact values so dashboards do not query nonexistent series.</violation>

<violation number="2" location="backend/docs/batch-pipeline-worker.md:219">
P3: `fetch_decode` timings do not include all executor wait for prefetched work. The timer starts only after the executor begins the callable, while executor queueing and the later `future.result()` wait are outside the observation; qualify this as execution time or measure submit-to-consumption time.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

async def test_real_pump_and_worker_export_one_cycle_with_nested_leaf_stages():
registry = CollectorRegistry()
timings = StageTimings(registry)
worker, _, _, _, _, _ = setup_worker(timings=timings)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This integration-style assertion is environment-dependent: enabling the short-speech skip causes the 2-second fixture item to bypass diarize, so the test fails before validating telemetry. Pin the relevant stage flags in this test, as the worker fixture does.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/unit/test_batch_pipeline_stage_timings.py, line 36:

<comment>This integration-style assertion is environment-dependent: enabling the short-speech skip causes the 2-second fixture item to bypass `diarize`, so the test fails before validating telemetry. Pin the relevant stage flags in this test, as the worker fixture does.</comment>

<file context>
@@ -0,0 +1,66 @@
+async def test_real_pump_and_worker_export_one_cycle_with_nested_leaf_stages():
+    registry = CollectorRegistry()
+    timings = StageTimings(registry)
+    worker, _, _, _, _, _ = setup_worker(timings=timings)
+    store, _, pump = setup(worker, timings=timings)
+    assert await pump.run_once() == 1
</file context>
Suggested change
worker, _, _, _, _, _ = setup_worker(timings=timings)
monkeypatch.setenv('BATCH_PIPELINE_DIARIZE_SPEECH_ONLY_ENABLED', 'false')
monkeypatch.setenv('BATCH_PIPELINE_SHORT_SPEECH_SINGLE_ENABLED', 'false')
worker, _, _, _, _, _ = setup_worker(timings=timings)

Comment on lines +216 to +218
for pull, maintenance, admission, full worker flight, publication, ordered merge,
and projection, plus fetch/decode, VAD, window assembly, ASR, padded retry,
diarization, encrypted result persistence, and final CUDA synchronization.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The stage label values are not documented for most leaves. The runtime emits windows, asr_recovery, diarize, persist, and cuda_sync, not the prose names here; list the exact values so dashboards do not query nonexistent series.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/docs/batch-pipeline-worker.md, line 216:

<comment>The stage label values are not documented for most leaves. The runtime emits `windows`, `asr_recovery`, `diarize`, `persist`, and `cuda_sync`, not the prose names here; list the exact values so dashboards do not query nonexistent series.</comment>

<file context>
@@ -212,6 +212,28 @@ Completion-only retention never expires pending work.
 ## Capacity and autoscaling
 
+The dedicated runtime exports `omi_batch_pipeline_stage_seconds{stage=...}`
+for pull, maintenance, admission, full worker flight, publication, ordered merge,
+and projection, plus fetch/decode, VAD, window assembly, ASR, padded retry,
+diarization, encrypted result persistence, and final CUDA synchronization.
</file context>
Suggested change
for pull, maintenance, admission, full worker flight, publication, ordered merge,
and projection, plus fetch/decode, VAD, window assembly, ASR, padded retry,
diarization, encrypted result persistence, and final CUDA synchronization.
for stages `pull`, `maintenance`, `admission`, `worker_flight`, `publication`, `ordered_merge`,
`projection`, `fetch_decode`, `vad`, `windows`, `asr`, `asr_recovery`, `diarize`, `persist`,
and `cuda_sync`.

Comment on lines +219 to +220
Timings include failed operations and executor wait; a prefetched fetch/decode
is measured where it executes, not at the later consuming wait. `pump_cycle` contains the

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: fetch_decode timings do not include all executor wait for prefetched work. The timer starts only after the executor begins the callable, while executor queueing and the later future.result() wait are outside the observation; qualify this as execution time or measure submit-to-consumption time.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/docs/batch-pipeline-worker.md, line 219:

<comment>`fetch_decode` timings do not include all executor wait for prefetched work. The timer starts only after the executor begins the callable, while executor queueing and the later `future.result()` wait are outside the observation; qualify this as execution time or measure submit-to-consumption time.</comment>

<file context>
@@ -212,6 +212,28 @@ Completion-only retention never expires pending work.
+for pull, maintenance, admission, full worker flight, publication, ordered merge,
+and projection, plus fetch/decode, VAD, window assembly, ASR, padded retry,
+diarization, encrypted result persistence, and final CUDA synchronization.
+Timings include failed operations and executor wait; a prefetched fetch/decode
+is measured where it executes, not at the later consuming wait. `pump_cycle` contains the
+whole pass; `worker_flight` contains worker leaves and CUDA synchronization.
</file context>
Suggested change
Timings include failed operations and executor wait; a prefetched fetch/decode
is measured where it executes, not at the later consuming wait. `pump_cycle` contains the
Timings include failed operations and executor wait for pump/model calls. Prefetched fetch/decode is timed inside its executor callable, excluding queueing and the later consuming wait.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Folding batch (2026-11-04): this branch's tip was merged into the survivor PR #24477 (feat/cv1-release-safety), which now carries origin/main plus all sixteen folded branches; pushed as 88c7ec5. Both sides' conflict intents were preserved (main's evolved implementations win where a successor of the same intent had already landed). Closing here so the batch lives on one PR. Reopen if something you need is missing from the survivor.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Hey @Git-on-my-level 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

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