Skip to content

fix(routing): expire dated idle decode estimates before ranking - #1243

Closed
jtrose24 wants to merge 2 commits into
Layr-Labs:masterfrom
jtrose24:fix/routing-stale-decode-tps
Closed

jtrose24 wants to merge 2 commits into
Layr-Labs:masterfrom
jtrose24:fix/routing-stale-decode-tps

Conversation

@jtrose24

@jtrose24 jtrose24 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Without a matching reviewed performance-profile point, a loaded idle provider can retain a dated, abnormally low decode EWMA indefinitely. resolveEffectiveTPS prefers that positive observation in its unqualified fallback, so it can continue losing to a busier peer even after its observation has become obsolete. This addresses the stale-score mechanism reported in #1238 on top of the first-content router (#1230) and provider-measurement/placement work (#1233), now integrated with current master at 8b8d1eedc through a signed merge that preserves the original contribution.

Expire independently dated decode observations older than 30 minutes, only for loaded models on idle machines with no local reservations. Use the existing model/chip-family fleet median, or the existing registration fallback if no median exists. Copy decode age separately from the combined prefill/decode age so a fresh prefill does not rejuvenate decode evidence. Matching reviewed profile points keep priority. Explicit producer sample counts can refresh an unchanged decode rate; replayed counts cannot.

The 30-minute threshold is an explicit policy proposal: it retains ordinary short idle intervals and outlives the existing 2-minute deadline-evidence horizon, while bounding multi-hour stale-score retention. It is not a measured optimum.

Before

flowchart TD
  A["No matching profile: idle, dated slow EWMA"] --> B["resolveEffectiveTPS fallback: use positive EWMA"]
  B --> C["estimateFirstContent: obsolete decode cost"]
  C --> D["Busier peer wins; idle score cannot recover"]
  classDef input fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef problem fill:#fee2e2,stroke:#dc2626,color:#450a0a
  class A input
  class B,C,D problem
Loading

After

flowchart TD
  A["fillFirstContentSnapshot: independent decode age"] --> P{"Matching reviewed profile point?"}
  P -->|"Yes"| Q["Keep qualified DecodeP10TPS"]
  P -->|"No"| B{"staleIdleDecodeMeasurement"}
  B -->|"Idle, loaded, dated over 30 min"| C["resolveEffectiveTPS: fleet or registration estimate"]
  B -->|"Fresh, busy, cold or undated"| D["Keep observed rate"]
  C --> E["Idle provider can compete for reservation"]
  E --> F["New decode observation restores measured ranking"]
  C --> G["Deadline confidence remains unknown"]
  classDef input fill:#dbeafe,stroke:#2563eb,color:#172554
  classDef check fill:#fef3c7,stroke:#d97706,color:#451a03
  classDef outcome fill:#dcfce7,stroke:#16a34a,color:#14532d
  class A input
  class B,P check
  class C,D,E,F,G,Q outcome
Loading

Validation of the integrated branch (repository-pinned Go 1.25.0):

  • A regression through ReserveProviderEx selects the busy peer on upstream and the idle provider with this fix; the recovered request retains unknown deadline evidence and its full physical token reservation.
  • Covers fresh/boundary/unknown ages, busy/pending/cold providers, missing fleet medians, repeated unchanged heartbeats, independent prefill age, recovery after a changed decode observation, exact qualified-profile precedence, unmatched-profile fallback, and explicit producer sample count/replay behavior.
  • GOTOOLCHAIN=go1.25.0 go test -race ./coordinator/registry -count=1 — passed, including current upstream routing tests.
  • GOTOOLCHAIN=go1.25.0 make coordinator-test — all 33 tested coordinator packages passed (existing prerequisite-gated skips remain); pinned coordinator build and registry vet also passed.
  • make docs-impact-check BASE=refs/remotes/review-1243/master — passed for the seven-file PR delta; make docs-check — 324 documents passed.

Limits: this does not guarantee traffic for every idle provider, change the feasible-before-unknown preference, refresh the fleet median, or invent age for undated samples. No physical admission, decode-quality cap, privacy gate, wire field, schema, release, or deployment changes. No production latency or hardware-performance improvement is claimed. Hosted CI and hardware-only checks are reported separately.

Conflict-resolution review

Resolved the forecast/snapshot/documentation conflicts without replacing either side's behavior: keep independently dated decode observations together with #1245's calibrated prompt-work checks and #1254's idle-evidence exploration, unretired-service guards and commit-time revalidation. No provider restart or new provider binary is required by this coordinator-only fix.

An independent ReserveProviderEx reproduction on current master selects the busy peer while the idle provider retains its dated low rate; the same probe selects idle with this patch, still reporting unknown deadline confidence. The merged full registry race suite and 100-repeat shuffled/race routing selections passed. This confirms the ranking mechanism, not every fleet-wide stall or the production incident statistics.

A separate test-environment discrepancy is retained transparently: Go 1.27.1 fails four existing JSON encoder tests on both this branch and unchanged master. The same four pass on repository-pinned Go 1.25.0; no JSON implementation, assertion or routing safeguard was weakened. Final qualification uses the pinned toolchain.

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

@jtrose24 is attempting to deploy a commit to the EigenLabs Team on Vercel.

A member of the Team first needs to authorize it.

@jtrose24
jtrose24 marked this pull request as ready for review September 29, 2026 00:01
@jtrose24
jtrose24 force-pushed the fix/routing-stale-decode-tps branch from e2c12ee to a455360 Compare September 29, 2026 12:13
davidtai added a commit that referenced this pull request Sep 30, 2026
After #1243 merges, the decode fallback table needs a row for an idle
provider whose decode measurement is older than 30 minutes. The row
cannot be added yet because the age field does not exist on master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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 5, 2026
* Add routing evidence boundary and invariant tests

Add package tests for the first-content evidence predicates and for
invariants that routing holds by design.

Boundary tables cover the capacity and performance freshness limits,
the budget edge between feasible and predicted late, the candidate gate,
the explicit measurement dating rules, and the decode and prefill rate
fallback chains.

Seeded property tests check the forecast invariants, that a faster rate
never makes a forecast later, that the first-content preference never
empties or reorders the pool, and that heartbeats on a virtual clock
never make an unchanged measurement younger. Each failure prints its
seed and case.

All new tests pass on master. The tests that expose the idle-evidence
feedback loop in #1238 are in a separate draft pull request.

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

* Note the stale-idle row the decode fallback table needs after #1243

After #1243 merges, the decode fallback table needs a row for an idle
provider whose decode measurement is older than 30 minutes. The row
cannot be added yet because the age field does not exist on master.

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

* refactor: name routing invariant helpers for their domain

Rename the random candidate generator and pool helpers to say what they
return, and merge the two identical new-sample flags in the dating check.

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

* test(routing): move evidence boundary and invariant tests to coordinator/tests

Master keeps every coordinator test under coordinator/tests in the
external package, and the first-content predicates now live in internal
packages. Move both files to coordinator/tests/registry and test each
predicate at the package that owns it:

- forecast.UnknownReason, forecast.Evaluate and forecast.Allows for the
  freshness, budget and candidate gate tables and the seeded forecast
  invariants.
- measurements.History.Reconcile for the explicit measurement dating
  table.
- performance.Rates for the decode and prefill rate chains.
- selection.Prefer for the seeded pool narrowing invariant.
- Registry.Heartbeat and ReserveProviderEx for the synctest dating
  invariant. The routing age now comes from the routing decision.

The scheduler folds busy and pending work into one occupied input, so
the two hedge rows become one table row plus a scheduler test where a
pending reservation keeps a hedge off the provider. All rows, seeds and
synctest schedules are kept.

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

---------

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

Copy link
Copy Markdown
Member

Superseded by #1371: #1371 . The replacement consolidates #1243, #1270 and #1276 on current master, preserves the stale-decode fix and regression coverage, and credits @jtrose24 as its original author plus @jonathan308 for the earlier integration in both the PR description and signed commit co-author trailers. Combined local normal/race suites, schema checks, builds, lint and docs checks pass; hosted review/CI are now running on the replacement. Closing only to keep one review/merge target; thank you for the original contribution.

@Gajesh2007 Gajesh2007 closed this Oct 7, 2026
davidtai added a commit that referenced this pull request Oct 7, 2026
Port the rule of #1243 into the performance.Rates layout. An idle,
loaded provider with no local reservations no longer ranks by an observed
decode EWMA whose dated observation is older than
performance.IdleDecodeMaxAge (30 minutes). EffectiveDecode then uses the
fleet median, or the load-scaled registration rate. A reviewed profile
point and the explored fleet median still come first; ProjectedDecode is
unchanged.

The snapshot copies the decode age (decodePerformanceAgeMs) separately
from prefill age, so heartbeats and prefill samples cannot renew it.
fillExplorationRates reads the same field. The ported #1243 tests live in
coordinator/tests/registry/decode_measurement_freshness_test.go, and the
#1262 idle evidence tests now use the production constant.

Co-authored-by: jtrose24 <rosejt24@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gajesh2007 added a commit that referenced this pull request Oct 7, 2026
…off (#1371)

* fix(routing): consolidate idle provider recovery and exploration backoff

Port the complementary fixes from #1243, #1270 and #1276 onto the
current domain-owned coordinator. Preserve independent decode aging,
per-rate exploration pricing, stable-identity suppression, and existing
physical admission and provider-health policy.

Close the integration gaps for median-priced deadline-exempt attempts,
duplicate timeout/fault feedback, reviewed-profile attribution, and
invalid explicit metadata replay. Retain the closed-loop starvation
regressions and add live-registry, outcome, identity and race coverage.

Original contributions: #1243 by JT Rose, #1270 by Brandon Curtis,
and #1276 by David Tai; earlier #1243 integration by jonathan308.

Co-authored-by: JT Rose <rosejt24@gmail.com>
Co-authored-by: Brandon Curtis <brandon@eigenlabs.org>
Co-authored-by: David Tai <dtaipublic@gmail.com>
Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(routing): preserve evidence identity across reconnects

Address the three Codex review findings on #1371: preserve newer healthy clears independently of outcome timestamps, distinguish explicitly missing rate evidence from legacy EWMAs, and deduplicate corroborating observations across reconnects and identity merges.

Bound producer watermarks and expiry fences, preserve healthy-only routing read fast paths, and add regression coverage for provenance replay, chronology, saturation, recovery and real reservation behavior. Original contribution attribution remains in the consolidation commit.

---------

Co-authored-by: JT Rose <rosejt24@gmail.com>
Co-authored-by: Brandon Curtis <brandon@eigenlabs.org>
Co-authored-by: David Tai <dtaipublic@gmail.com>
Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

4 participants