Skip to content

fix(routing): explore idle providers without current first-content evidence - #1254

Merged
Gajesh2007 merged 2 commits into
Layr-Labs:masterfrom
brandon-eigenlabs:fix/first-content-idle-evidence-gap
Sep 29, 2026
Merged

Gajesh2007 merged 2 commits into
Layr-Labs:masterfrom
brandon-eigenlabs:fix/first-content-idle-evidence-gap

Conversation

@brandon-eigenlabs

@brandon-eigenlabs brandon-eigenlabs commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix the first-content router's evidence starvation loop: when any candidate is feasible, preferFirstContentCandidates currently drops every unknown candidate, including healthy idle providers that need work to refresh their measurements.

  • Let loaded, idle providers with missing or stale performance evidence compete beside feasible peers after the five-minute age threshold. Ordinary ranking still decides which provider wins.
  • Treat unretired service leases and reported service usage/reservations as busy, even when slot counters and the pending-request list are empty. Preserve legacy providers that omit the newer service fields.
  • Recheck exploration eligibility inside commitProviderReservation. If ownership changes after the scan, rescan rather than committing an obsolete idle choice.
  • Keep the candidate unknown: hedge and fresh-feasible requests still exclude it. Physical admission, trust, billing and the original deadline are unchanged.

Integrated current master without rewriting the original contribution. The PR remains a coordinator-only change with no wire fields, schema, configuration knobs or provider release requirement.

Before

flowchart TD
  R["Deadline-bearing request"] --> F["estimateFirstContent"]
  F --> P{"preferFirstContentCandidates:<br/>any feasible peer?"}
  P -->|"yes"| K["Keep feasible peers only"]
  P -->|"no"| U["Existing unknown fallback"]
  K --> D["Rank, reserve and dispatch"]
  U --> D
  K --> X["Idle provider with stale or missing evidence excluded"]
  X --> N["No work to refresh measurements"]
  N --> X
  classDef flow fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef guard fill:#fef3c7,stroke:#d97706,color:#451a03
  classDef problem fill:#fee2e2,stroke:#dc2626,color:#450a0a
  class R,F,K,U,D flow
  class P guard
  class X,N problem
Loading

After

flowchart TD
  R["Deadline-bearing request"] --> S["fillFirstContentSnapshot:<br/>include pending and unretired service"]
  S --> E{"firstContentEvidenceExplorable:<br/>loaded, idle, evidence gap,<br/>age at least five minutes?"}
  E -->|"yes"| P["Compete beside feasible peers;<br/>remain unknown"]
  E -->|"no"| F["Keep existing feasibility preference"]
  P --> K["selectFirstContentCandidate"]
  F --> K
  K --> C{"commitProviderReservation:<br/>eligibility still unchanged?"}
  C -->|"no"| S
  C -->|"yes"| D["Atomic admission and dispatch"]
  D --> O["Opportunity to refresh measurements;<br/>not a recovery guarantee"]
  classDef flow fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef guard fill:#fef3c7,stroke:#d97706,color:#451a03
  classDef outcome fill:#dcfce7,stroke:#16a34a,color:#14532d
  class R,S,K flow
  class E,C guard
  class P,F,D,O outcome
Loading

Blue: request/code flow. Amber: guards. Red: prior lockout. Green: new outcomes. Without feasible peers, the existing unknown fallback is unchanged.

Validation

  • make coordinator-test (33 packages passed; database and opt-in hardware/evidence tests skipped because their local prerequisites were not configured)
  • go test -race ./coordinator/registry -count=1
  • Exploration regression tests repeated 100 times with race detection and shuffled order.
  • go vet ./coordinator/registry
  • make coordinator-build
  • make docs-impact-check BASE=origin/master
  • make docs-check (324 documents; pinned MLX dependency initialized)
  • New regression coverage exercises reported service and terminal-retirement ownership through fresh scans, retained plans, and a scan/commit interleaving. It verifies that explicit retirement restores exploration and that no rejected exploration leaves a pending debit.
  • Mutation check: removing commit-time exploration revalidation makes both interleaving tests fail. The original ownership repro passes on master and fails with the unfixed exploration change.
  • Existing tests preserve the no-measurement and stale-measurement recovery opportunity, legacy service-field omission, pending-work exclusion, and hedge/fresh-feasible guards. Added exact threshold-boundary coverage.

The independent code review found no remaining actionable issues. Live-model performance and production behavior are not claimed by these tests; hosted CI is reported separately.

Evidence And Limits

The original investigation in #1238 reports idle-provider stalls and a small provider-side experiment. The fleet figures come from SELECT-only production-replica queries, not the public stats feed. Source inspection and deterministic tests independently establish the exclusion mechanism; the experiment is not a measured fleet-wide performance gain.

  • Five minutes is a policy threshold, not a measured optimum. The clock is the older paired measurement's age, or connection age when either measurement is undated. It is not time continuously idle or time since evidence expired.
  • Selection and measurement recovery are not guaranteed. Cache-hit requests may leave isolated-prefill evidence unchanged; unchanged legacy EWMAs do not renew their timestamps.
  • fix(routing): expire dated idle decode estimates before ranking #1243 is complementary: this PR lets qualifying providers into the pool; that PR expires dated idle decode estimates used to rank them. Neither replaces the other.
  • Use verified prompt work and observed rates for first-content admission #1245's prompt-work identity checks, observed-rate calculations and calibrated-admission guards remain intact.
  • No deployment, provider publication, concurrency expansion or traffic change is performed by this PR.

Refs #1238.

…idence

preferFirstContentCandidates drops every unknown candidate whenever one is
feasible. Performance evidence is renewed only by serving, so a freshly
connected session (no measurement) and any provider idle past the 2-minute
freshness horizon (evidence ages out) can be excluded from deadline-bearing
requests indefinitely: they need a request to earn evidence and need evidence
to get a request.

After 5 minutes without usable evidence, an idle, loaded candidate whose
forecast is unknown only for performance_missing or
performance_age_unknown_or_stale now stays in the pool beside feasible peers
and competes on ordinary ranking. Its class stays unknown, so hedge and
fresh-feasible requests still exclude it, and qualified evidence still wins
within the bound (TestFirstContentFreshScanAndRetainedPlanPreferFeasibleBeforeVersion
is unchanged and passes). The gap age comes from existing data: the dated
measurement's age, else the connection's age. No new provider state.

Refs Layr-Labs#1238.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 29, 2026

Copy link
Copy Markdown

@brandon-eigenlabs is attempting to deploy a commit to the EigenLabs Team on Vercel.

A member of the Team first needs to authorize it.

@Gajesh2007
Gajesh2007 merged commit acda005 into Layr-Labs:master Sep 29, 2026
16 of 22 checks passed
davidtai added a commit that referenced this pull request Sep 30, 2026
The 5-minute no-starvation bound and the fleet-median cost of an
explored provider go beyond #1243 and #1254. #1254 admits an idle
provider without a selection promise, and #1243 keeps an old decode
rate for 30 minutes on purpose. Say so in the test comments and the
routing doc, and say that the maintainers own the policy.

Name the production constants that the test constants mirror, and say
that the package test must switch to them after the fixes merge.

Use the Swift provider's EWMA weight of 0.3 and blend every sample into
the EWMA, including the slow setup samples. Results on master and on the
local merge of both fixes are unchanged.

Restamp docs/architecture/routing.md with today's date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@brandon-eigenlabs

Copy link
Copy Markdown
Contributor Author

Verified in production, from the read replica's routing records:

  • Live at 2026-09-30T00:21:23Z. That is the first recorded deadline pool mixing feasible and unknown candidates. Before this PR there were 0 of 17,869 per hour; since, 727–3,430 per half hour.
  • Explorable providers win. From 04:00–05:00Z, 455 of 5,780 mixed-pool deadline requests (7.9%) went to an unknown / performance_age_unknown_or_stale provider while a feasible one was present.
  • Our provider's 0.9.12 restart (05:24:18Z, no evidence) got its first request at 05:29:38Z, in line with the 5-minute bound. Before, 5 of 6 comparable restarts stalled for 15+ min; this is n = 1.

The cost half (#1243) is still open. Details and era dating: #1238

brandon-eigenlabs added a commit to brandon-eigenlabs/d-inference that referenced this pull request Sep 30, 2026
…tions

Layr-Labs#1254 admits an idle provider without current performance evidence and
prices it at the fleet median. A provider whose engine keeps resetting
clears that evidence every few minutes, and a first-content timeout is a
429 the node-health breaker deliberately ignores. In production one such
provider (M3 Max decoding at ~11 tok/s against a ~79 fleet median) failed
most of the explorations it won for hours with no tracker reacting.

Two per-identity checks, scoped to exploration only:

- Outcome backoff. An attempt selected through exploration reports back:
  a first-content timeout, deadline refusal or genuine fault (the breaker's
  own fault test) doubles a per-model suppression interval (5 min to 2 h);
  a delivered request halves it. Reset-on-success would not stop a provider
  that still completes short requests.
- Remembered decode rate. Newly measured decode rates are kept per model
  across evidence resets and reconnects; a median of at least 5 below 0.25x
  the (model, chip family) fleet median makes the provider non-explorable.
  One slow observation never decides (the Layr-Labs#1238 lock-out); an observation
  at >= 0.5x clears the memory.

Both live on the stable-identity gate (merged on migration, swept after
6 h, cleared by a provider version change). Neither quarantines: a
suppressed provider still serves when nothing is feasible, and deadline
refusals and first-content timeouts stay neutral for every health breaker.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
davidtai added a commit that referenced this pull request Oct 5, 2026
…rdinator/tests

Port the idle-evidence ranking test and the closed-loop starvation
simulation onto the mirrored test tree, in the external packages:

- tests/registry/idle_evidence_ranking_test.go builds providers with the
  shared scheduler helpers, injects the fleet median through
  Dependencies.Throughput and the measurement history through
  Dependencies.Measurements, and reads each provider's effective decode
  rate and first-content forecast from its ReserveProviderEx decision.
- tests/registry/routingsim/closed_loop_*_test.go register providers
  through Registry.Register with a test-owned registration message
  instead of the package's unexported simRegisterMessage, simModelInfos
  and armSimProvider.
- The starvation bound now uses forecast.EvidenceExplorationAfter (#1254)
  instead of a copied 5-minute constant. The #1243 copy stays, because
  #1243 is not merged.

The tests keep every assertion. They still fail on purpose where the
routing code does not meet the proposed policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gajesh2007 pushed a commit that referenced this pull request Oct 6, 2026
#1262)

* Add closed-loop routing simulation and idle-evidence tests

Extend routingsim with closed-loop tests. The provider that
ReserveProviderEx selects serves the request, releases it, and reports a
changed measurement through Registry.Heartbeat. Idle providers send
unchanged heartbeats. The tests run under testing/synctest, so two
simulated hours take less than one second. Each scenario runs on the
legacy EWMA path and on the explicit measurement path.

Scenarios from #1238: a slow last measurement, a freshly connected
provider, a provider idle longer than the evidence window, and a healthy
control fleet. Every idle, loaded provider must be selected within
5 minutes plus one request time. The control also limits the share of
the busiest provider.

Add registry tests for measurement monotonicity (an old idle decode
measurement must not rank a provider below the same provider with none)
and for the fleet-median cost of an explored provider.

The starvation tests fail on master by design. They are the regression
tests for #1243 and #1254.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* State that the starvation bounds are a proposed policy

The 5-minute no-starvation bound and the fleet-median cost of an
explored provider go beyond #1243 and #1254. #1254 admits an idle
provider without a selection promise, and #1243 keeps an old decode
rate for 30 minutes on purpose. Say so in the test comments and the
routing doc, and say that the maintainers own the policy.

Name the production constants that the test constants mirror, and say
that the package test must switch to them after the fixes merge.

Use the Swift provider's EWMA weight of 0.3 and blend every sample into
the EWMA, including the slow setup samples. Results on master and on the
local merge of both fixes are unchanged.

Restamp docs/architecture/routing.md with today's date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: name the shared measurement age and fold heartbeat state branches

measurementAge dates both the prefill and decode measurements in the idle
evidence tests; the closed-loop heartbeat derives slot state and status once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(routing): move the closed-loop and idle-evidence tests under coordinator/tests

Port the idle-evidence ranking test and the closed-loop starvation
simulation onto the mirrored test tree, in the external packages:

- tests/registry/idle_evidence_ranking_test.go builds providers with the
  shared scheduler helpers, injects the fleet median through
  Dependencies.Throughput and the measurement history through
  Dependencies.Measurements, and reads each provider's effective decode
  rate and first-content forecast from its ReserveProviderEx decision.
- tests/registry/routingsim/closed_loop_*_test.go register providers
  through Registry.Register with a test-owned registration message
  instead of the package's unexported simRegisterMessage, simModelInfos
  and armSimProvider.
- The starvation bound now uses forecast.EvidenceExplorationAfter (#1254)
  instead of a copied 5-minute constant. The #1243 copy stays, because
  #1243 is not merged.

The tests keep every assertion. They still fail on purpose where the
routing code does not meet the proposed policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

No deployments
benchmarks — c0e6404f Deployed Sep 29, 2026 by Gajesh2007 via E2E Benchmarks #1924
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.

3 participants