Skip to content

Batch vendor overflow: one oldest-first rule with per-vendor in-flight slots; length-aware Modulate breaker - #26816

Merged
Git-on-my-level merged 6 commits into
mainfrom
lane/vendor-overflow-one-rule
Dec 1, 2026
Merged

Git-on-my-level merged 6 commits into
mainfrom
lane/vendor-overflow-one-rule

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Summary

One overflow rule for every recording, with a fleet-wide in-flight limit per vendor, and a Modulate latency breaker that allows for audio length (SCA-5986; David, 2026-11-30).

The 25→100 batch-vendor-routing ramp tripped at 20:01Z on 11-30 (SCA-5183):

  • Admission-time overflow started every new FRESH and RECENT English unit on Modulate while those GPU backlogs were older than 1200 s, with no bound on volume.
  • Modulate slowed under about 4x our usual concurrency, and our latency breaker opened.
  • Failover then reached Soniox, which returned 119 rate_limited and 71 error_5xx in 100 min.
  • vendor_held rose to about 470.

What changes

  • Admission always starts a GPU-capable unit on the GPU. Inside the vendor-routing cohort (legacy draining or dark, not the GPU floor share), when the table lists a primary vendor for the unit's language, admission stamps overflow_language and a writer-owned due clock, overflow_due_at = enqueued_at + ENTER_SECONDS. BATCH_VENDOR_OVERFLOW_PRIORITIES is retired, and the prod overlay drops it.
  • The overflow pump (utils/batch_pipeline/overflow_pump.py) moves stamped units that have waited at least BATCH_VENDOR_OVERFLOW_ENTER_SECONDS (1200 s) to a vendor, oldest first and whatever their priority, only into a free vendor slot.
    • Each move is one transaction. It re-checks that the unit is ready, admissible, unattempted (no GPU allowance reserved), past the threshold, and inside the cohort at the current percent.
    • It unlinks the unit from its owner's FIFO: a head the way a lease takes it, a later unit spliced out the way _prefer_merge_head does.
    • It writes the provider route admission-time vendor starts wrote, bumps the owner revision, and arms the provider-stt outbox row.
    • It finds units with one bounded query: state == ready, compute_decision.outcome == unattempted, overflow_due_at <= now, ordered by overflow_due_at, at most 100 rows. Only stamped units carry the field, so a backlog of units that can never move (legacy on, a GPU-only language, units admitted before this build) can't fill the scan and hide a movable unit behind it.
    • A move drops both stamps, so a moved unit is never scanned again.
    • A scanned row that can't move leaves the scan, so it never holds the bounded prefix. If its wait isn't over (a later deferral), it is re-dated to when the wait ends. Otherwise, for example outside the cohort after a ramp-down, not admissible, or no vendor for its language, it loses its stamp and stays on the GPU. That's one read and one write per such row, and the row then leaves the query.
    • The served builtin table (an unset or unusable table) never stamps a unit and never names an overflow vendor.
    • Units that don't fit stay in the GPU ring.
    • A pass runs at most once per 5 s fleet-wide (Redis token). It runs after each provider-stt delivery and from the enrichment-maintenance sweep, which acts as the bootstrap.
  • Vendor in-flight slots are a Redis sorted set per vendor with a 600 s lease, taken atomically in Lua.
    • The pump takes the slot for the unit it moves.
    • The provider stage takes or renews a slot for all vendor traffic, armed routing or not. It does this before it reads the audio, and before health and caps, so a slot wait costs no download or inspection and never spends the cap or the half-open probe. Only the chosen vendor keeps a slot. The stage gives it back at settle, hold or terminal, and when the row has already left the stage.
    • Defaults are Modulate 16 and Soniox 6, tunable per vendor with max_in_flight in BATCH_VENDOR_HEALTH_THRESHOLDS.
    • A unit that finds every vendor full waits in provider_pending and looks again after 5–10 s. It is never held or failed for lack of a slot.
    • Without shared state the slot fails closed, as the caps already do. That includes a serving process whose Redis client could not be created: it grants no slot.
  • Length-aware breaker: a call counts as slow against latency_degraded_s + latency_degraded_per_audio_min_s × audio minutes (defaults 30 s + 15 s per minute; open at 120 s + 60 s per minute).
  • New metrics:
    • omi_batch_pipeline_vendor_in_flight and _in_flight_limit{provider};
    • omi_batch_pipeline_vendor_overflow_diverted_total{provider,priority};
    • omi_batch_pipeline_vendor_slot_waits_total{provider}.

Firestore index

This adds one composite per stage namespace: batch_pipeline_{prod,dev}_jobs on (state, compute_decision.outcome, overflow_due_at, name).

  • It is declared in database/batch_pipeline_indexes.py, and firestore.indexes.json is regenerated.
  • Only stamped units carry the field, so the index starts empty and stays small: one entry per stamped ready unit.
  • The prod index build must be READY before this ships. The deploy readiness gate enforces that.
  • overflow_due_at joins the census due-clock fields. Units with a due stamp leave the query when they move or leave ready.

Tuning

New knobs, so there are no before numbers:

  • In-flight limit per vendor: modulate new: 16, soniox new: 6 (DEFAULT_MAX_IN_FLIGHT). Prod readings before the ramp were about 10 Modulate calls in flight; failures began at about 35–45 for Modulate and about 7 for Soniox.
  • SLOT_LEASE_SECONDS new: 600.
  • SLOT_RETRY_SECONDS new: 5, with jitter up to 10.
  • PUMP_INTERVAL_SECONDS new: 5. That is at most 17,280 passes a day fleet-wide, and a pass reads nothing when no slot is free.
  • MAX_MOVES_PER_PASS new: 32.
  • AGED_READY_SCAN_LIMIT new: 100. Worst case is about 1.7M reads a day; the usual case is far lower.
  • Breaker per audio minute: latency_degraded_per_audio_min_s new: 15, latency_open_per_audio_min_s new: 60.

Product invariants affected

  • INV-MEM-4: matched only because backend/deploy/runtime_env.yaml is regenerated. The only change there drops BATCH_VENDOR_OVERFLOW_PRIORITIES. No memory intake, consolidation or promotion path changes.

Line-count exceptions

Line-Count-Exception: backend/database/batch_pipeline_store.py | 1486 -> 1511 | the pump's one store read sits beside its siblings oldest_admissible_ready and ready_for_capacity, which the parity census and query-driver registry key by module
Line-Count-Exception: backend/utils/batch_pipeline/provider_stt.py | 1460 -> 1528 | slot take, renew and release must sit at the provider stage's mint, settle and hold points
Line-Count-Exception: backend/utils/batch_pipeline/scheduler.py | 1492 -> 1529 | unlink_ready_in_transaction edits the owner FIFO and ring invariants this module owns, next to the lease path it mirrors

Evidence (ro-prod, read-only, 11-30)

  • Premise check for the breaker: Modulate's mean audio per ok attempt was 27.3 s in the 100 min before the ramp and 27.7 s during it (GMP), so long recordings did not cause the trip. On the sampled provider-stt handler logs, latency rose with concurrency: p50 went from 2.3 s to 7.5 s and p95 from 24 s to 41 s at 18:30–18:40Z. The length term is still needed because the pump now moves units of any length.
  • Limits, by Little's law on attempts × wall time:
    • Modulate ran at about 10 in flight before the ramp and about 35–45 at 18:45Z, just before its breaker opened.
    • Soniox ran at about 7 in flight when its 429s started.

DESIGN

SCA-5986 first comment covers:

  • what the change reads and writes;
  • cost per unit: at most 120 reads per pass, at most 2.1M per day in the worst case, about 6 reads and 5 writes per move;
  • implicit state;
  • the production numbers that prove it.

Rollout and rollback

  • Ship on. No production change by itself: vendor routing is at 25%, and the re-ramp is a separate Release step on SCA-5183.
  • Kill switch: BATCH_VENDOR_OVERFLOW_ENABLED=false keeps every capable unit on the GPU.
  • Tuning: set a vendor's limit with max_in_flight in BATCH_VENDOR_HEALTH_THRESHOLDS.
  • Full rollback: reverting restores admission-time overflow. fresh,recent would then need re-adding to the overlay.

Tests

  • tests/unit/test_batch_vendor_overflow_pump.py (new): moves, unlinking, slots on MemoryStore and fakeredis Lua, slot waits in the stage, and the length-aware breaker. It includes a starvation regression: 120 older unstamped units must not hide a stamped one.
  • tests/unit/test_batch_vendor_outage_drills.py: the GPU-outage drill now runs the real pump over the real store, GPU ring and provider stage. In 30 min with no GPU, 90 units moved, oldest first, each 600–609 s after admission, and Modulate never held more than its 4 drill slots. All 630 units committed.
  • Also updated: tests/unit/test_batch_vendor_overflow.py, tests/unit/test_batch_vendor_route_table_prod.py, tests/unit/test_jobstore_protocol_parity.py, and the census and Firestore query-shape registries (tests/unit/test_batch_census_registry.py, query drivers).
  • Focused set: 1368 passed.

Failure class (fixes)

Failure-Class: new

🤖 Generated with Claude Code

Git-on-my-level and others added 6 commits November 30, 2026 16:33
…t slots; length-aware breaker

Admission always starts a GPU-capable unit on the GPU and stamps it
overflow-eligible inside the vendor-routing cohort. A fleet-paced pump moves
stamped units that have waited past BATCH_VENDOR_OVERFLOW_ENTER_SECONDS to a
vendor, oldest first whatever their priority, only into a free fleet-wide
in-flight slot (Redis ZSET with a lease; Modulate 16, Soniox 6). A unit that
finds every vendor full waits in provider_pending with no hold, and none fails.
BATCH_VENDOR_OVERFLOW_PRIORITIES is retired.

The Modulate latency breaker now allows per-audio-minute latency on top of its
flat bounds.

Refs SCA-5986, SCA-5183.

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Take the vendor slot before reading audio, on armed and unarmed paths, so a
  slot wait costs no download or inspection; only the chosen vendor keeps one.
- A serving health service without its shared store grants no slot and no
  pump token (no per-pod fallback for a fleet-wide bound).
- The builtin table never stamps a unit or names an overflow vendor.
- The move re-checks the cohort on its own transactional read.
- Rows the pump scans but cannot move leave the scan (re-dated or unstamped),
  so a ramp-down or a refused move cannot starve the bounded prefix.
- Release a unit's slots once its row has left the provider stage.

Panel review-20261130t213739-0ba9 F1-F5, F7 (part); SCA-5986 design review.

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An overlapping pump pass (one that ran past the 5 s token) could renew a slot
the winning pass had handed to a running provider call, then release it when
its own move lost the CAS, freeing capacity under a live call. The pump now
takes a slot only when the unit holds none yet, so it releases only the
reservations it created. The provider stage still adopts the pump's slot.

SCA-5986 design review (DESIGN: BLOCKED, slot release not fenced).

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_sync_future_early_parity executes a pinned older intake.py against the
current helpers; that intake still passes gpu_saturated, so routing raised
TypeError and sync answered 503. Overflow is the pump's now; the argument is
accepted and ignored.

Refs SCA-5986.

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ease

reserve_slot returns the lease it wrote; the pump's rollback removes the slot
only while its score is still that lease. A pass that stalled past the 600 s
lease can no longer delete a successor's reservation (or one the adopting
provider renewed) when its own move CAS fails.

SCA-5986 design review (stale rollback after lease expiry).

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The provider stage now passes the unit's audio length to record_attempt (the
length-aware breaker); the failover test's MeteredHealth fake rejected the new
keyword, so its records were empty.

Refs SCA-5986.

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit ec27125 into main Dec 1, 2026
78 of 79 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/vendor-overflow-one-rule branch December 1, 2026 00:08
Git-on-my-level added a commit that referenced this pull request Dec 1, 2026
…SCA-5315) (#26866)

## What changed and why

Restore the serving predecessor's admission-time GPU overflow at the
`backend-sync` upload call for SCA-5315. The original parser includes
FRESH and reads the predecessor's `fresh,recent` production setting on
Sync. Outside the GPU floor, a configured-priority unit that would
choose GPU can select a healthy primary vendor when that priority's
backlog is saturated. Sync uploads leave admission without the deferred
overflow stamp. The #26816 slot and pump path continues for all other
callers, including backfill and integration.

The Sync guard failures remain unattributed. Immediate predecessor
routing can send newly admitted work to a vendor during saturation.
Release owns the separate canary, guard and pause decisions. Rollback is
a revert of this patch.

## Product invariants affected

- INV-MEM-4. Intake routing stays upstream of memory-promotion
authority.

## How it was verified

The focused M1 tests exercise the recreated predecessor priority parser,
route matrix (saturation, health, cohort, floor and kill switch) and the
real admission transaction with a synthetic store. The latter checks the
GPU ring, provider outbox and deferred eligibility fields. Existing pump
and worker controls are outside this patch.

## UI evidence

UI-Evidence: none -- backend mitigation

## Failure class (fixes)

Failure-Class: none

Line-Count-Exception: backend/routers/sync.py | 4462 -> 4463 | Select
the predecessor route only at the backend-sync upload authority.
Line-Count-Exception: backend/utils/batch_pipeline/intake.py | 1617 ->
1649 | Keep route selection and deferred-stamp policy together in a
small helper outside the existing admission transaction.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/26866?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/26866?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26866&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