Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions coordinator/registry/solo_tps.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,15 @@ func soloSampleEligible(bc *protocol.BackendCapacity) bool {
}
load := 0
for _, slot := range bc.Slots {
if n := slot.NumRunning + slot.NumWaiting; n > 0 {
load += n
}
if load > 1 {
return false
for _, n := range [...]int{slot.NumRunning, slot.NumWaiting} {
// Compare before adding untrusted counts: load stays in [0, 1],
// so an overflowing busy report cannot appear uncontended.
if n > 1-load {
return false
}
if n > 0 {
load += n
}
}
}
return true
Expand Down
57 changes: 57 additions & 0 deletions coordinator/registry/solo_tps_overflow_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package registry

import (
"math"
"testing"

"github.com/eigeninference/d-inference/coordinator/protocol"
)

func TestHeartbeatRejectsOverflowingSoloOccupancy(t *testing.T) {
for _, counts := range [][2]int{{math.MaxInt, 1}, {1, math.MaxInt}, {math.MaxInt, math.MaxInt}} {
reg := New(testLogger())
registration := testRegisterMessage()
provider := reg.Register("busy", nil, registration)
model := registration.Models[0].ID
if !reg.Heartbeat(provider.ID, &protocol.HeartbeatMessage{
BackendCapacity: &protocol.BackendCapacity{Slots: []protocol.BackendSlotCapacity{{
Model: model, State: "running", NumRunning: counts[0], NumWaiting: counts[1],
ObservedDecodeTPS: 40,
}}},
}) {
t.Fatal("otherwise valid heartbeat was rejected")
}
// Load-inclusive service estimates still accept the reading; a busy
// box cannot donate the same reading as an uncontended quality rate.
if got := reg.tpsRegistry.Median(model, registration.Hardware.ChipFamily); got != 40 {
t.Fatalf("load-inclusive sample was lost: %v", got)
}
if rate, samples := reg.tpsRegistry.SoloMedian(model, chipClassKey(registration.Hardware)); rate != 0 || samples != 0 {
t.Errorf("running/waiting %v produced solo rate %v from %d samples", counts, rate, samples)
}
}
}

func TestSoloSampleEligibilityCountsWithoutOverflow(t *testing.T) {
for _, tc := range []struct {
name string
slots []protocol.BackendSlotCapacity
want bool
}{
{"idle", nil, true},
{"single decode", []protocol.BackendSlotCapacity{{NumRunning: 1}}, true},
{"single waiting", []protocol.BackendSlotCapacity{{NumWaiting: 1}}, true},
{"peers across slots", []protocol.BackendSlotCapacity{{NumRunning: 1}, {NumWaiting: 1}}, false},
{"negative report ignored", []protocol.BackendSlotCapacity{{NumRunning: -1}, {NumRunning: 1}}, true},
{"negative cannot hide peers", []protocol.BackendSlotCapacity{{NumRunning: -1, NumWaiting: 2}}, false},
} {
t.Run(tc.name, func(t *testing.T) {
if got := soloSampleEligible(&protocol.BackendCapacity{Slots: tc.slots}); got != tc.want {
t.Fatalf("solo eligible = %v, want %v", got, tc.want)
}
})
}
if soloSampleEligible(nil) {
t.Fatal("missing capacity is not a solo sample")
}
}
9 changes: 8 additions & 1 deletion docs/architecture/scheduling.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Scheduling: queues, slots, capacity and the warm pool

> Last updated: 2026-09-10 · commit `213b8c2b6`
> Last updated: 2026-09-11 · commit `f8503600f`

Scheduling is the coordinator's model of *how much work the fleet can take
and where the weights are*: the per-model request queue, the per-slot state
Expand Down Expand Up @@ -237,6 +237,13 @@ decode rate is the provider's median solo sample (at least
`defaultQualityCapSoloMinSamples`, the default of
`EIGENINFERENCE_QUALITY_CAP_SOLO_MIN_SAMPLES`), or a seeded/benchmark rate.

Solo samples require at most one running or waiting request across the whole
provider and a running decode in the sampled slot (`coordinator/registry/solo_tps.go`,
`soloSampleEligible`; `coordinator/registry/heartbeat.go`). Each occupancy count
is compared against the remaining allowance before addition, so an overflowing
busy report cannot enter the solo sample pool. The separate load-inclusive TPS
store still receives valid observed rates from busy providers.

### Model slots, pending loads and swaps

**`maxModelSlots`.** The number of models a provider keeps resident at once
Expand Down
Loading