Repository navigation
test(routing): add closed-loop starvation simulation for idle evidence - #1262
Conversation
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>
|
Deployment failed for project d-inference with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
|
Repeat runs with
The first 20-run batch of
|
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>
|
Deployment failed for project eigen-homepages-darkbloom with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
|
Deployment failed for project d-inference-console-ui-dev with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
|
Deployment failed for project d-inference-landing with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
…anches 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>
Resolve the routing.md freshness stamp to master's date-only format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 355ff12237
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if p.MaxIdleWait > noStarvationBound { | ||
| t.Errorf("seed %d: %s waited %s idle and loaded while requests arrived; bound is %s (selections=%d)", | ||
| res.Seed, p.ID, p.MaxIdleWait, noStarvationBound, p.Selections) |
There was a problem hiding this comment.
Do not add red policy assertions to the required suite
This unconditional assertion encodes a proposed starvation bound that the accompanying routing documentation explicitly says the production code does not meet, so several new subtests fail by design. Because go test ./coordinator/... discovers this package, every required coordinator test run will remain red until a separate routing change lands; either implement the policy in this commit or keep the experiment opt-in/non-failing until the behavior exists.
AGENTS.md reference: AGENTS.md:L210-L216
Useful? React with 👍 / 👎.
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>
Summary
Add a closed-loop routing simulation to
coordinator/registry/routingsimand registry tests for the idle-evidence feedback loop in #1238. The change has tests and one documentation paragraph. No production code changes.This is a draft. Its starvation tests fail on
masterby design. It must merge after #1243 and #1254. Test failures here notify; they must not block other pull requests.Only the monotonicity tests are regression tests for #1243. The no-starvation bound and the fleet-median rows assert a proposed policy: from the exploration bound, an explored provider is costed at the fleet median for prefill and decode, and it is selected within the bound plus one request. This policy goes beyond both fix PRs. #1243 keeps an old decode rate for 30 minutes on purpose. #1254 admits an idle provider to the pool and does not promise that it is selected. The maintainers own this policy and its numbers.
Linked issue
Refs #1238, #1243, #1254
How the loop works
The simulation uses only the public
registryAPI, so it lives inroutingsimas package tests. No test seam was needed.testing/synctest. Two simulated hours take less than one second.TTFTDeadline). Each request takes 39.5 s, so 19 requests are in flight at each arrival. With 20 peers, exactly one peer is idle with current evidence at each arrival.ReserveProviderExselects sends a running heartbeat, serves, thenRemovePending+SetProviderIdle, then a heartbeat throughRegistry.Heartbeat(the path toreconcileFirstContentMeasurementsLocked). The new noisy sample is blended into the EWMA with the Swift weight 0.3 (provider-swift/Sources/ProviderCore/Inference/Engine/Bridge/EngineV2Bridge+Accounting.swift:161). A slow "last measurement" in setup is a run of slow samples blended in the same way until the EWMA is within 1 % of the slow rate.performance_measurementspath (Add provider work measurements and measured warm placement #1233).decode_tpsorprefill_tps, as the Swift provider does (CoordinatorClientCodec.encodeRegistration).Assertions:
noStarvationBound= 5 min + one request time (39.5 s), counted only while requests arrive.explorationPolicyBoundmirrorsfirstContentEvidenceExplorationAfterfrom fix(routing): explore idle providers without current first-content evidence #1254; this package cannot read that unexported constant.Results on four trees
Each cell covers both measurement paths (same result on both). "Wait" is the longest idle wait in the 2-hour run.
TestIdleDecodeMeasurementAgeNeverRanksBelowNoMeasurementTestIdleDecodeMeasurementAgeDoesNotLoseSelectionTestExploredIdleProviderIsCostedAtFleetMedian/no_measurement…/measured_just_past_exploration_bound(6 min, proposed policy)…/measured_past_stale_decode_age(31 min)The local merge had conflicts in
first_content_forecast.go(struct fields),first_content_snapshot.go(age initialization) and therouting.mdstamp. Both sides were kept. The merge was not pushed.Findings with both fixes applied
The rows in bold fail with both fixes. They fail against the proposed policy above, not against what #1243 and #1254 promise. The reason is one class: an explored provider is admitted to the pool, but it still ranks outside the 100 ms selection band against an idle peer with current evidence, so it never wins.
resolvePrefillTPS(coordinator/registry/scheduler.go, around line 2227) falls back toresolvedPrefillTPS= registration decode × 12 (around line 2467). The Swift provider sends no registration rates, so the registration decode issqrt(bandwidth)= 20 tok/s and the prefill fallback is 20 × 12 = 240 tok/s. For a 1000-token prompt the expected first content is about 4.3 s against 0.67 s for a measured peer. Even a 50-token prompt is outside the band (378 ms against 194 ms). The fix(routing): explore idle providers without current first-content evidence #1254 testTestFirstContentIdleProviderWithoutEvidenceIsExploredAfterBoundsetsPrefillTPS = 20000on the explored provider, so it does not see this.resolveEffectiveTPSkeeps the old rate until the fix(routing): expire dated idle decode estimates before ranking #1243 limit of 30 min. The provider waits 27 min after demand starts. At the first pick it is costed at 52.3 tok/s, the fleet median. So "an explored provider is costed at the fleet median" holds only after 30 min, not at the 5-minute exploration bound.resolvePrefillTPSprefersobservedPrefillTPSwith no age limit. fix(routing): expire dated idle decode estimates before ranking #1243 limits only decode. The provider is never selected in 2 h.Under the first-content ranking, decode enters the expected forecast as one token time (
1000/decode). A slow decode rate matters only when it is far below the median (below about 8.4 tok/s against 52). So at the issue rate, #1254 alone fixes scenario (a), and #1243 alone does not.Diagrams
Behavior:
flowchart LR subgraph Before A1[Trace arrival] --> B1[Preflight on a fixed fleet] B1 --> C1[Outcome; fleet state never changes] end subgraph After A2[Arrival with deadline] --> B2[ReserveProviderEx] B2 --> C2[Provider serves, releases] C2 --> D2[Heartbeat with new measurement] D2 --> E2[Fleet state for the next arrival] E2 --> B2 F2[Idle heartbeats every 5 s] --> E2 endCode:
flowchart LR subgraph Before T1[routingsim_test.go] --> Q1[QuickCapacityCheckWithTTFTForRequest] end subgraph After T2[closed_loop_starvation_test.go] --> S2[closed_loop_sim_test.go event loop in synctest] S2 --> R2[Registry.ReserveProviderEx] S2 --> P2[Provider.RemovePending + SetProviderIdle] S2 --> H2[Registry.Heartbeat to reconcileFirstContentMeasurementsLocked] T3[idle_evidence_ranking_test.go] --> E3[resolveEffectiveTPS + estimateFirstContent] T3 --> R2 endTest plan
go test ./registry/... ./registry/routingsim/...on four trees (table above)-race -count=20on this branch and on the local merge (results in a comment)go vet ./registry/...,gofmt -l coordinator/,golangci-lint run ./coordinator/registry/...with v2.1.6: cleanmake coordinator-test: fails only in the new tests, as expected onmastermake docs-impact-check BASE=origin/master,make docs-checkComponents touched
Protocol / interface changes
Documentation impact
docs/architecture/routing.md, routing simulation harness section.Notes for reviewers
master(acda005e) after this table was made. The "master" column ise351f359. This branch now has a conflict withmasterin the stamp line ofdocs/architecture/routing.mdonly; it needs a merge frommasterbefore it can land.math/rand. The fleet shape keeps a tie between at most a few candidates, and the slack is 20 arrivals, so the chance of a false failure is about one in a million per run.master.🤖 Generated with Claude Code
Refactor Pass
A dedicated refactor subagent reviewed the diff against the
AGENTS.mdstructure, clean-code and refactor rules. Outcome: one test-only cleanup commit, e26fcf9.idle_evidence_ranking_test.go:idleEvidenceFleet.decodeAgeis nowmeasurementAge, because the field dates both the prefill and the decode measurement.routingsim/closed_loop_sim_test.go,heartbeat: one branch now sets both the slot state and the heartbeat status. Before, the code checkedrunning > 0twice.Validation on the final tree:
gofmt -l,go vetandgolangci-lintv2.1.6 (0 issues) pass. The focusedgo testruns fail exactly as on the head.Needs a port before merge. The only text conflict with master c5552d3 is the
routing.mdstamp line, but the merged tree has two problems:TestCoordinatorTestsAreIsolatedrejects all three test files.idle_evidence_ranking_test.godoes not compile there.makeSchedulerProvider,firstContentMeasurement,testLoggerandtestRegisterMessagemoved or no longer exist, and the file uses unexported registry internals.The routingsim files compile in place on master, and there
issue_rate,IdleBeyondEvidenceWindowandHomogeneousControlpass.For the author:
forecast.EvidenceExplorationAfter, so the comments that say the symbol does not exist are out of date.routing.mdshould be checked. Each subtest took 2–10 s of wall time under load.Port to master, 12fe7dc plus 355ff12 (follow-up): the 3 test files moved to
coordinator/tests/registry/andtests/registry/routingsim/, and now use real APIs:Dependencies.Throughput,Dependencies.MeasurementswithHistory.Reconcile,ReserveProviderExdecisions,routingsim.DefaultHardwareSpecandTTFTDeadline. No production code changed. The same draft tests fail on purpose with identical numbers, for example 2h0m0s and 1h50m5s waits, and 'costed at 5.0 tok/s, want 52.0'. The comments now useforecast.EvidenceExplorationAfter. Build, vet, lint (0), the layout guard andtest-coordinator-tests.pypass.