Repository navigation
perf(batch): overlap worker artifact IO outside GPU ownership - #24213
Conversation
Keep attempt-local bounded first decode, settle persist before fenced publication, retain renewal and drain on cancellation/fatal CUDA, and expose content-free completion, admission, requeue and CPU strict-VAD shadow evidence.
Keep intentionally skipped results outside publication even if renewal recovers, and make pending IO receipt types explicit for the enforced type checker.
There was a problem hiding this comment.
7 issues found across 24 files
Confidence score: 3/5
backend/config/batch_pipeline.pyraises default artifact IO concurrency from 3 to 5 for workers without an env override, even though the L4 comparison and rollout are still pending. Keep the default at 3 until that validation is complete.backend/utils/batch_pipeline/pump.pyleaves the watcher active after dispatch, so a late stop can makeFirstDecode.take()fail and charge a retry. Stop and join the watcher before dispatch, then handle cancellation.backend/diarizer/batch_pipeline_runtime.pycan wait for encrypted writes inclose()while the pump still holds the GPU slot after a failed CUDA synchronize. Release the GPU slot before waiting on storage.backend/utils/batch_pipeline/compute_client.pyletsRecursionErrorfrom deeply nested JSON escape the receipt handler, so malformed receipts are counted as transport failures. Catch it and classify the receipt as invalid.
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_compute_client.py">
<violation number="1" location="backend/tests/unit/test_batch_pipeline_compute_client.py:85">
P3: Move `failure_outcome` and `InvalidReceipt` into the module-top import from `utils.batch_pipeline.compute_client` instead of importing them inside both test functions. AGENTS.md requires imports at module top level.</violation>
</file>
<file name="backend/config/batch_pipeline.py">
<violation number="1" location="backend/config/batch_pipeline.py:486">
P2: This raises the default artifact IO concurrency from 3 to 5 for every worker that does not set the env var. The PR says the L4 comparison and rollout are still pending with the lead, so this ship-on default goes live before that qualification. Either keep the default at 3 until qualification passes, or confirm the bump is approved. The docstring's 'conservative default' wording also no longer fits a value of 5.</violation>
</file>
<file name="backend/tests/unit/test_batch_pipeline_worker_bundle.py">
<violation number="1" location="backend/tests/unit/test_batch_pipeline_worker_bundle.py:189">
P2: This drain-time guard uses `1500` where the intended bound is almost certainly seconds. Change it to `1.5` so the test actually catches a slow drain.</violation>
<violation number="2" location="backend/tests/unit/test_batch_pipeline_worker_bundle.py:369">
P3: The test name promises coverage of clocks and model calls, but the body asserts only words and speaker output. Either assert the model/VAD call count is unchanged, or rename the test to match what it checks.</violation>
</file>
<file name="backend/diarizer/batch_pipeline_runtime.py">
<violation number="1" location="backend/diarizer/batch_pipeline_runtime.py:112">
P3: On a failed CUDA synchronize this `close()` waits for all pending encrypted writes while the pump still holds the GPU slot. Storage waits now run under GPU ownership on this path. Consider handing the close to the post-unlock settle path, or document that the wait is intentional.</violation>
</file>
<file name="backend/utils/batch_pipeline/pump.py">
<violation number="1" location="backend/utils/batch_pipeline/pump.py:402">
P2: `watching` remains active after dispatch, so a stop arriving after the one-time cancellation check can make `FirstDecode.take()` fail and charge a retry. Stop and join the watcher before dispatch, then handle any cancellation before submitting the flight.</violation>
</file>
<file name="backend/utils/batch_pipeline/compute_client.py">
<violation number="1" location="backend/utils/batch_pipeline/compute_client.py:69">
P3: A deeply nested JSON body below the 64 KiB cap can make `json.loads` raise `RecursionError`. It escapes this handler and is counted as `transport`; catch it here so malformed receipts retain the `invalid_receipt` outcome.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
|
||
|
|
||
| WORKER_IO_CONCURRENCY_DEFAULT = 3 | ||
| WORKER_IO_CONCURRENCY_DEFAULT = 5 |
There was a problem hiding this comment.
P2: This raises the default artifact IO concurrency from 3 to 5 for every worker that does not set the env var. The PR says the L4 comparison and rollout are still pending with the lead, so this ship-on default goes live before that qualification. Either keep the default at 3 until qualification passes, or confirm the bump is approved. The docstring's 'conservative default' wording also no longer fits a value of 5.
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/config/batch_pipeline.py, line 486:
<comment>This raises the default artifact IO concurrency from 3 to 5 for every worker that does not set the env var. The PR says the L4 comparison and rollout are still pending with the lead, so this ship-on default goes live before that qualification. Either keep the default at 3 until qualification passes, or confirm the bump is approved. The docstring's 'conservative default' wording also no longer fits a value of 5.</comment>
<file context>
@@ -483,7 +483,7 @@ def worker_pipeline_depth() -> int:
-WORKER_IO_CONCURRENCY_DEFAULT = 3
+WORKER_IO_CONCURRENCY_DEFAULT = 5
WORKER_IO_CONCURRENCY_MAX = 8
</file context>
| WORKER_IO_CONCURRENCY_DEFAULT = 5 | |
| WORKER_IO_CONCURRENCY_DEFAULT = 3 |
There was a problem hiding this comment.
The implementation brief explicitly authorizes IO concurrency 3 to 5 when preparation shares the existing pool. prepare_first, within-flight prefetch and persistence all use the same self._io pool. The default is intentionally ship-on per that brief; it does not update a running worker or authorize a roll. The lead owns the L4 qualification and Recreate deployment, and IO=1 remains the restart-time serial kill switch. The docstring now says bounded default rather than conservative default.
| finally: | ||
| release.set() | ||
| await asyncio.wait_for(running, 3) | ||
| assert time.monotonic() - started < 1500 |
There was a problem hiding this comment.
P2: This drain-time guard uses 1500 where the intended bound is almost certainly seconds. Change it to 1.5 so the test actually catches a slow drain.
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_worker_bundle.py, line 189:
<comment>This drain-time guard uses `1500` where the intended bound is almost certainly seconds. Change it to `1.5` so the test actually catches a slow drain.</comment>
<file context>
@@ -0,0 +1,489 @@
+ finally:
+ release.set()
+ await asyncio.wait_for(running, 3)
+ assert time.monotonic() - started < 1500
+ assert store.rows['jobs', 'a']['state'] == 'committed'
+ assert worker._decode_budget.seconds == 0
</file context>
| assert time.monotonic() - started < 1500 | |
| assert time.monotonic() - started < 1.5 |
There was a problem hiding this comment.
1500 is intentionally seconds: it matches terminationGracePeriodSeconds=1500 and the brief's shutdown contract. The synthetic test also awaits the running pump with asyncio.wait_for(..., 3), so a hung fake drain already fails after three seconds. A 1.5-second shared-host wall assertion would add flakiness without qualifying the actual 1500-second L4/network drain; that real-image qualification remains lead-owned.
| except Exception as error: | ||
| # Synchronization can fail after compute handed off writes. Fatal | ||
| # CUDA must not leave those writes running beyond the receipt. | ||
| close = getattr(pending, 'close', None) |
There was a problem hiding this comment.
P3: On a failed CUDA synchronize this close() waits for all pending encrypted writes while the pump still holds the GPU slot. Storage waits now run under GPU ownership on this path. Consider handing the close to the post-unlock settle path, or document that the wait is intentional.
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/diarizer/batch_pipeline_runtime.py, line 112:
<comment>On a failed CUDA synchronize this `close()` waits for all pending encrypted writes while the pump still holds the GPU slot. Storage waits now run under GPU ownership on this path. Consider handing the close to the post-unlock settle path, or document that the wait is intentional.</comment>
<file context>
@@ -93,6 +107,11 @@ def process_batch(self, items, **kwargs):
except Exception as error:
+ # Synchronization can fail after compute handed off writes. Fatal
+ # CUDA must not leave those writes running beyond the receipt.
+ close = getattr(pending, 'close', None)
+ if callable(close):
+ close()
</file context>
There was a problem hiding this comment.
The wait is intentional on a fatal synchronization failure, and the comment now makes this explicit. The slot is poisoned and must not be released for a sibling to start another chain before the pending writes drain and FatalGpuError stops the pump. Healthy flights settle their tail after unlock. The fatal-synchronize regression proves outstanding IO has finished before the exception escapes.
Keep the shared audio pipeline contract current and use module-level test imports.
Stop and join the waiting-lane watcher before dispatch so SIGTERM cannot cancel the active chain's queued first decode. Cover that boundary, all fenced completion outcomes, model-call parity and deeply nested invalid receipts.
Return prepared IO futures directly to their owner and shield renewal/cleanup handles explicitly before bounded cancellation-resistant draining. Keep the existing background-task ratchet unchanged.
Aggregate every group's persistence receipt without settling under the GPU lock, release decoded buffers, and drain earlier writes on later fatal errors. Drain discarded running preparations in final cleanup after unlock while renewal remains active. Count dispatch admission outcomes without changing permission. Add grouped-batch custody, fatal-drain, running-fetch and admission regressions. Failure-Class: none
Retain at most one pending write per admitted unit (32 per pull) instead of waiting on the first upload at the IO concurrency limit under the GPU locks. Add six/eight/32-unit short-flight coverage proving unlock, second-lane compute and persist-before-publication custody with a slow first upload.
|
Remaining Luna persistence block fixed in Removed the FIFO persist wait at five pending writes from the GPU loop. The existing 32-unit admission bound caps pending payloads/receipts per lane; the executor still limits simultaneous uploads. Decoded groups retain their 7200-audio-second bound, and normal settlement remains after CUDA quiescence and GPU unlock, before publication. No wait timeout was added. The other two fixes are unchanged. Regression coverage uses 6, 8 and 32 short units with the first upload blocked. All three cases timed out on the previous head; all pass now. They verify both GPU locks release, a second pump lane actually computes and commits, and the first lane publishes/commits nothing until its upload settles. Validation: 223 targeted worker/IO/bundle/runtime/pump tests pass via Exact-head CI: 37 SUCCESS, 22 conditional SKIPPED, zero pending or failed checks, with no reruns. Backend unit suite, Hygiene, hermetic stack gauntlets. Source/local custody evidence only. Exact-image L4 quality/memory/drain/gain qualification and the worker roll remain lead-owned; this lane did not merge or deploy. |
…#24248) Batch workers run a 10-hour-old image that lacks merged batch fixes, including #24223, and claims have run below normal since the freeze at 11:17Z. The worker needs a roll, but main's chart default of IO concurrency 5 (#24213) never ran in qualification: the staging verdict was NO-GO with no measured gain. This sets `worker.ioConcurrency: 3` in prod values only, which #24213 names as the previous default. The chart default stays 5, and qualification or a measured prod comparison can raise prod later. Rollback: remove the line (returns to 5), or set 1 for serial IO. No code path changes. Takes effect at the next worker roll, which the lead runs with the repair-flag re-apply. Failure-Class: none 🤖 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/24248?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/24248?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24248&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. -->
The batch worker currently holds exclusive GPU ownership while its first audio fetch and final encrypted writes wait on storage. This bundle prepares a lane's first decode before the lock and settles the final persist tail after CUDA quiescence and unlock, before fenced publication, with lease renewal still running.
Decision: use the smaller pump-side first-item preparation instead of rebasing draft #23490. It captures the first-fetch overlap without a cross-flight cache, new decode-concurrency knob or new queue custody state. All lanes share a 1,800-admitted-audio-second preparation budget and the existing IO pool (default 3 to 5; Helm worker.ioConcurrency). Authenticated language/stream context is bound to the actual attempt object. IO=1 is the existing serial kill switch; it takes effect at worker restart under the same Recreate/drain strategy.
Additional telemetry: retry-to-ready wakeups are requeued, genuine failure retries retain retry and get one content-free INFO record. Admission receipts distinguish timeout, transport and invalid receipt. Unique fenced completions count capture seconds by success/silence, including silence. CPU-only strict-VAD shadow never changes output or skips/adds a GPU call. The waiting-lane watcher is joined before GPU dispatch; once dispatched, the current bounded chain drains on stop. Completion seconds cover every canonical outcome, including no_recoverable_speech. The background-task ownership ratchet is unchanged; prepared futures return explicitly to their owner and cleanup/renewal handles are shielded and awaited. On this Mac, 60s synthetic silence/tone cost 0.278/0.280 thread CPU seconds; cold first 20ms inspection cost 0.094 CPU seconds. These are host measurements, not L4 qualification.
Validation: targeted backend/test.sh runs under omi-heavy, nice -n 19, BACKEND_PYTEST_WORKERS=4, with an explicit file list. Tests cover persist-before-publish, per-unit persist failure, fatal CUDA IO drain, renewal after unlock, lost leases, SIGTERM, repeated cancellation, cross-attempt context, global preparation bounds, privacy revocation during upload, and unchanged fake-model payloads (words/speakers/clocks). Final local result: 606 passed, 0 failed, 2 optional real-pyannote cases skipped across 23 files at 729934c. The final head passed the full enforced backend type check with 0 errors. The prescribed make preflight passed 39 checks before the final lease/type delta; canonical pre-push then passed all 39 shared checks, enforced type check, import/source closure, selected unit tests and formatting at this exact head, with no skips. Prior-head CI found the background-task ownership ratchet; it remains unchanged and is covered by the final local pass. GitHub CI is running on the final head. No dev GPU run or production access performed.
worker_flightnow ends with the model/CUDA phase; fetch/persist leaf spans can cross its boundary, andpersist_settlemeasures the separate tail, so overlapping durations must not be added.Rollback by piece:
Lead-only qualification plan (not run): after CPU admission is fed, pin source/image/model/corpus and flags; run a saturated L4 pair with matched synthetic/public inputs. The baseline is the pre-bundle image at IO=3; the treatment is this image at IO=5, with all model flags held identical. Use fixed warmup and 30-minute baseline/candidate/baseline plateaus, swapping treatments across GPUs. IO=1 is a serial rollback control, not the old production baseline. Compare unique fenced completed capture/speech seconds per GPU-hour, silence separately, complete/held/retry/expiry obligations and output hashes/words/clocks/normalized speakers. Measure GPU lock wait/hold and starvation, fetch/decode/persist/persist_settle/publication and projection tails, CPU/shadow cost/throttling, host/device peaks and restarts. Inject lease theft, privacy revoke, slow/failing uploads, fatal CUDA and SIGTERM. Do not claim a production gain from the host latency model or use pre-persist durations as the denominator. Filter all queue rates with job=batch-pipeline-worker-metrics. Require unchanged quality/custody and existing memory headroom before the lead schedules the single Recreate roll; rollout/repair-flag reapplication and all merge/deploy authority stay with the lead.
Product invariants affected
none
Failure-Class: none
This is a worker performance/observability bundle. It introduces no new workflow, admission allowance, provider route, model checkpoint/precision, data mutation tool or runtime dependency. admission.py, live.py and serving.py remain outside this PR.
The stockout/Recreate rollout takes all workers down together; this PR does not start it. The lead owns qualification, merge, roll and repair-flag reapplication.
Review corrections (gpufix)
Grouped batches now aggregate every deferred persistence receipt instead of settling earlier groups under GPU ownership. Their decoded buffers are released between groups, and a later fatal group drains all earlier writes. A cancelled preparation's running fetch drains in final cleanup after GPU unlock while reservation and renewal remain active. Dispatch admission rechecks now count the same closed outcomes as initial admission, without changing permission.
Nine new regressions fail against the original production files at 729934c and pass with these corrections. They cover four/eight 3,600-second units with a blocked first-group persist, no publication before settlement, both GPU lock boundaries, later-group fatal drain, a running slow fetch on lease loss, and five dispatch admission outcomes. The selected six-file backend shard passed 226 tests, including existing worker/IO/runtime/pump and background-task ownership coverage, through
backend/test.shwith an explicit file list,omi-heavy,nice -n 19, and four workers. No production access or deployment was performed.The follow-up also passed all 39 make preflight gates and the hermetic backend E2E harness (180 passed, 3 skipped, 2 xfailed), serially under
omi-heavyandnice -n 19. Correction head: 96210d9. Its canonical pre-push passed all 39 shared checks, the enforced full backend type check (0 errors, existing warnings remain), source closure, 263 selected unit tests, and formatting without a skip. GitHub's checks tab owns current exact-head CI status; local checks certify source/harness behavior, not real GPU quality or deployed behavior. Merge, L4 qualification, worker roll and release monitoring remain lead-owned.