Skip to content

serving: spread gateway traffic instead of sending it all to the top-scored miner - #1733

Merged
anderdc merged 2 commits into
testfrom
serving/routing-tie-break
Aug 29, 2026
Merged

serving: spread gateway traffic instead of sending it all to the top-scored miner#1733
anderdc merged 2 commits into
testfrom
serving/routing-tie-break

Conversation

@anderdc

@anderdc anderdc commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Measured in soak 7, on two healthy 5090s.

ServingState.acquire picked min(inflight, -score). At the soak's rate — one request per 20 s against sub-second completions — requests never overlap, so in-flight is always 0 and the tie-break decides every single request. All of it went to one miner:

served TTFT credit
UID 16 12 1029 ms 0.681
UID 27 3 461 ms 0.945

Both cards are healthy and identical. The concentration is what raised UID 16's TTFT, and the TTFT band is what cut its pay — the miner doing the work was paid less for doing it, while the idle miner was barely measured at all. Left alone it oscillates: the loaded miner's score decays until it drops below the other, and then all the traffic swaps over.

Among the miners with the fewest in flight, the choice is now random weighted by score — a better miner is still sent more, neither is starved, and load no longer piles onto whoever is currently winning. _rng is a field on ServingState so tests are deterministic.

test_state_least_inflight_dispatch asserted the deterministic pick; it passed only because the default RNG happened to agree with it, so it was flaky as written. It now pins the part that is actually contractual (fewest in-flight wins outright) plus two distribution tests: weighted when scores differ, uniform when they do not.

This is the "weighted-random routing tie-break" item from 14-handoff §5, with the soak numbers behind it. CI green (ruff, format, pyright, vulture, 760 tests).

anderdc and others added 2 commits August 28, 2026 19:59
…scored miner

Ties on in-flight were broken by score, and at one request per 20 s against sub-second
completions nothing overlaps, so in-flight is always 0 and every request went to the same
miner. Measured in soak 7 with two healthy 5090s: UID 16 took 12 requests to UID 27's 3,
and the loading pushed its own TTFT to 1030 ms against 461 ms, cutting its credit to 0.68
while UID 27 sat at 0.945 on almost no traffic. The miner doing the work was paid less
for doing it, and the idle one was barely measured.

Among the miners with the fewest in flight the choice is now random, weighted by score:
a better miner is still sent more, and neither is starved. The existing test asserted the
deterministic pick and passed only because the default RNG happened to agree.
@anderdc
anderdc merged commit 49d1191 into test Aug 29, 2026
3 checks passed
@anderdc
anderdc deleted the serving/routing-tie-break branch August 29, 2026 01:54
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