Skip to content

fix(batch): keep compute admission within the worker deadline - #24211

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/gpucpu-deadline
Nov 1, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/gpucpu-deadline

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Compute admission currently evaluates a whole lease group serially and can answer after the worker's five-second HTTP timeout, discarding every completed decision. This change gives the server one four-second monotonic budget and returns the decisions completed so far. Unfinished and unreached leases get retry-after 30, with no allow and no fabricated policy hold.

Each blocking read, policy check, reservation and seal runs on the existing DB executor with the remaining request budget. The route awaits the coordinator directly, so executor queue time is included. Evaluation stays serial: current fresh funding/fair-use checks are check-then-act, with no in-flight usage reservation. Parallelizing them cannot be proven safe and would widen the documented overshoot risk. The existing privacy read, lease fence and scheduler attempt refund are retained. Worker code, retry ladder and levers are unchanged; the current ComputeClient parses partial receipts without a worker roll.

Already-running synchronous Firestore/Redis calls cannot be preempted by cancelling their executor future. Transaction retries and commit, privacy/intake reads, monthly allowance reads and reservations can therefore outlive the response. Firestore keeps its existing SDK/retry limits; the shared Redis client does not configure a socket timeout, so its executor occupancy is not bounded by this change. No later stage is scheduled and no late result enters the receipt. Queued calls and seal callbacks check expiry before starting/writing. A reservation or commit already issued may finish conservatively; the unfinished lease still has no allow in the response. Bounding those RPCs themselves requires passing remaining budgets through shared DB/policy helpers and a bounded Redis client, outside this change. This residual risk is tracked in card:gpucpu-20261101 for the rollout lead.

Admission exports omi_batch_compute_admission_stage_seconds for static substages (including executor wait and time until cancellation). Per-lease failures log only bounded_exception_class, without exception text or identifiers. No new reason label is introduced.

Validation:

  • Targeted backend unit shard through BACKEND_UNIT_TEST_FILE_LIST=/Volumes/Ephemeral/scratch/gpucpu/targeted-tests.txt backend/test.sh, under omi-heavy and nice -n 19: 229 passed across admission (44), current client (21), serving (51), provider (94) and reason-label (19) tests. Covers partial receipt, slow read/funding/restriction/reservation/seal, unreached leases, same-owner serial funding, exception sanitization, privacy/lease/refund regressions, unchanged worker decoder and real FastAPI HTTP route with the default four-second budget.
  • omi-heavy run -- nice -n 19 bash backend/testing/e2e/run.sh -k sync: 11 passed (174 deselected), hermetic local lifecycle layer.
  • omi-heavy run -- nice -n 19 env OMI_PR_BODY_FILE=<draft> make preflight: passed, including async, policy, serving-query, runtime-image source closure and documentation gates.
  • No cloud access, production account reads, merge or deploy. Lead-owned backend-sync deployment required; no worker image change.

Failure-Class: FC-per-hop-timeout

View guided diff Turn on auto-fix

Use one four-second request deadline across serial executor stages and return
completed decisions while deferring unfinished leases without an allow.
Keep privacy, lease and attempt-refund behavior; expose bounded diagnostics.

Failure-Class: FC-per-hop-timeout

@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.

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

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

@Git-on-my-level
Git-on-my-level merged commit e36545d into main Nov 1, 2026
65 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/gpucpu-deadline branch November 1, 2026 04:40
Git-on-my-level added a commit that referenced this pull request Nov 1, 2026
…ple cap (#24228)

## Summary

Train safety for the GMP sidecar's per-scrape `samples` cap (lead ruling
3d124a). Above the cap, GMP drops the instance's **whole** scrape, not
just the new series.

Backend Cloud Run max scrape, read-only GMP aggregates
(`scrape_samples_scraped`, job `omi-cloud-run-application-metrics`):

| Service | Max scrape | Note |
|---|---|---|
| backend | 9,339 now; 9,873 24h max | 3 instances, median 9,224 |
| backend-sync | 7,704 | |
| backend-sync-backfill | 6,769 | |
| backend-integration | 6,042 | |
| desktop-backend | 3,151 | |

The next train adds to backend, beyond the write probe:

- #24211 stage histogram: 96
- #24223: up to 18, behind a default-off flag
- #24214: 2
- #24212: up to 2

That is up to about 118 samples against roughly 127 of headroom.

Two changes:

1. **`OMI_FIRESTORE_WRITE_PROBE_ENABLED` kill switch** for the #24218
write probe. It is on unless the literal `false`. Off means
`database._client` never wraps the transport, so no labelled write
series exist in that process. That leaves 2 unlabelled counter samples.
It is registered in `config/feature-flags.yaml` as `ops_kill`, and the
registry doc is re-rendered.
2. **Shared Cloud Run sidecar cap 10,000 → 15,000**
(`backend/deploy/cloud_run_gmp_sidecar.yaml`: backend, desktop-backend,
notifications-job). Today backend is about 1% from losing all metrics on
any new series; this restores headroom. GMP bills per sample emitted, so
the cap itself costs nothing. The sync sidecar
(`cloud_run_gmp_sync.yaml`, max 7,704) is unchanged.

Series behaviour:

- **Write probe series are per instance.** They grow with code-path
diversity (distinct caller × collection × op an instance has executed,
capped), not with write volume.
- **At batch 100%**, instance count may grow and each instance sees more
batch callers. Per-instance cardinality rises toward the caps, not with
load.

Recommended for the train: merge this. If the cap raise is not wanted in
this train, set `OMI_FIRESTORE_WRITE_PROBE_ENABLED=false` on backend
Cloud Run only. Sync, listen and pusher keep the probe.

## Product invariants affected

none. Observability config only; no data path.

## Verification

All runs used `backend/test.sh` under `bin/omi-heavy` + `nice -n 19`, at
the unit layer:

- `test_firestore_write_probe.py`: 16 passed, including the kill switch
(literal `false` and ` FALSE ` leave `FirestoreClient.commit` unwrapped;
unset, empty, `true`, `0`, `off` stay on).
- The other tests that read the sidecar config:
`test_attach_cloud_run_gmp_sidecar` (117), `test_external_list_cache`,
`test_fleet_deployment`, `test_parakeet_request_metrics`,
`test_relevance_metric_is_scraped`, `test_sync_absorption_metrics`. All
pass.
- `scripts/check_feature_flag_registry.py`: OK.

## Rollback

Set the switch to `false` on any service, or revert. The cap can return
to 10,000 only if the max scrape is well below it.

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/24228?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/24228?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24228&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. -->
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