Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

fix(placement): check boot evidence and receipts for every listed cell (#995)

Krisztian Gajdar1518299aa6c6
diff --git a/packages/sie_placement/README.md b/packages/sie_placement/README.md
index 479d50783..8419567a9 100644
--- a/packages/sie_placement/README.md
+++ b/packages/sie_placement/README.md
@@ -120,7 +120,8 @@ a lane share its queue pool.
that the lane's containers may be placed on when `cell` cannot be placed. No
fallback cell repeats `cell` or another fallback cell. A realized card is
billed at its own price, so the planner prices such a lane at its dearest
-member.
+member. A container may boot and serve on any listed cell, so the planner
+holds a lane it keeps to its evidence at every one of them.
## Capacity
@@ -543,6 +544,15 @@ the lane's floor, or the floor itself where no identity whose `comeAliveP95S` is
placement lacks becomes a measurement request. Such a placement on a lane the
price list cannot price has no cost to compare, so the identity keeps it.
+A lane with fallback cells is held to this at every cell it lists. A placement
+there lacks evidence where any listed cell has no receipt at the lane's
+container shape and concurrency or, for a cold warmth or a lazy resident, no
+boot or load. An identity pinned beside others needs, in place of those
+receipts, the co-residency receipt at the lane's `cell`. The placement is known
+to miss a bound where the evidence at any listed cell misses it: the slowest
+receipt at that cell misses a warm bound, the come-alive measured there is over
+the bound, or the boot or load there did not succeed.
+
An identity that stays on its current placement keeps that lane exactly as it
is, beside whoever else the lane hosts: its cell, container shape,
concurrency and envelope, capped by the reviewed ceiling. A lazy resident
@@ -667,7 +677,9 @@ The report renders as a `placement-report` document:
its receipt's warm latencies, a measured come-alive over the bound, an
unreliable product, and with no `measured` value a boot or load at its lane
that did not succeed, or a cold or `lazy-resident` warmth under a bound of
- `0`, which needs no measurement.
+ `0`, which needs no measurement. Each bound is named once. On a lane with
+ fallback cells it carries the worst measurement among the listed cells: none
+ where one of them has no `measured` value, otherwise the largest.
- `capacity`: for each ceiling of the `capacity` document, its `scope`
(`total`, `type` with its `gpuProduct`, or `shared-quota` with
`heldElsewhere`), the `ceiling`, the `accelerators` the plan's envelope
@@ -709,7 +721,10 @@ The report renders as a `placement-report` document:
requests of an identity without a placement or a current one carry no bound
and rank first. The evidence a kept current placement lacks is requested at
its lane, named in `lane` with its `concurrency`, and also ranks first without
- a bound; a profile it asks for there is not asked for again.
+ a bound; a profile it asks for there is not asked for again. On a lane with
+ fallback cells a receipt and boot evidence are requested for each listed cell
+ that lacks them, named in the request's `cell`, and a co-residency receipt
+ for the lane's `cell`.
- `comeAliveLevers`: cold and `lazy-resident` warmths whose measured come-alive
misses the bound on a cell that meets the warm bounds for less than the
choice, or than a kept identity's current placement, listed only when
diff --git a/packages/sie_placement/src/sie_placement/planner.py b/packages/sie_placement/src/sie_placement/planner.py
index c6526e53a..50de8f423 100644
--- a/packages/sie_placement/src/sie_placement/planner.py
+++ b/packages/sie_placement/src/sie_placement/planner.py
@@ -891,20 +891,27 @@ class _Planner:
) -> tuple[MeasurementRequest, ...]:
if cost is None:
return ()
- missing: list[tuple[Measurement, RequestReason]] = []
+ missing: list[tuple[Cell, Measurement, RequestReason]] = []
beside = self.pinned_beside(identity) if beside is None else beside
if beside:
if self.co_receipt(identity, lane, beside) is None:
- missing.append((Measurement.CO_RESIDENCY_RECEIPT, RequestReason.UNMEASURED))
- elif self.slowest_receipt(identity, lane) is None:
- refused = (identity, lane.cell.machine_profile) in self.refused_profiles
- missing.append((Measurement.RECEIPT, RequestReason.REFUSED if refused else RequestReason.UNMEASURED))
- if entry.warmth in BOOT_WARMTHS and (identity, lane.cell, lane.container_shape, entry.warmth) not in self.boots:
- missing.append((Measurement.BOOT_EVIDENCE, RequestReason.UNMEASURED))
+ missing.append((lane.cell, Measurement.CO_RESIDENCY_RECEIPT, RequestReason.UNMEASURED))
+ else:
+ for cell in lane.cells:
+ if self.slowest_receipt(identity, lane, cell) is None:
+ refused = (identity, cell.machine_profile) in self.refused_profiles
+ reason = RequestReason.REFUSED if refused else RequestReason.UNMEASURED
+ missing.append((cell, Measurement.RECEIPT, reason))
+ if entry.warmth in BOOT_WARMTHS:
+ missing.extend(
+ (cell, Measurement.BOOT_EVIDENCE, RequestReason.UNMEASURED)
+ for cell in lane.cells
+ if (identity, cell, lane.container_shape, entry.warmth) not in self.boots
+ )
requests = [
MeasurementRequest(
identity=identity,
- cell=lane.cell,
+ cell=cell,
container_shape=lane.container_shape,
concurrency=lane.concurrency,
lane=lane.name,
@@ -915,7 +922,7 @@ class _Planner:
saving_bound=None,
co_residents=tuple(sorted(beside)) if measurement is Measurement.CO_RESIDENCY_RECEIPT else (),
)
- for measurement, reason in missing
+ for cell, measurement, reason in missing
]
if entry.warmth is Warmth.LAZY_RESIDENT:
pinned = self.current_pinned[lane.name] - {identity}
@@ -1085,7 +1092,7 @@ class _Planner:
current = self.keepable(identity)
if current is not None and not any(option.current for option in options):
entry, lane = current
- if not self.kept_blockers(identity, entry, lane, self.slowest_receipt(identity, lane)):
+ if not self.kept_blockers(identity, entry, lane):
cost = self.current_cost(identity, entry, lane)
cheaper = [option for option in feasible if cost is not None and round(cost - option.cost, 2) > 0]
chosen = min(cheaper, key=lambda option: option.rank) if cheaper else None
@@ -1500,26 +1507,33 @@ class _Planner:
)
return replace(lane, max_containers=ceiling, envelope=envelope)
- def slowest_receipt(self, identity: str, lane: PlanLane) -> Receipt | None:
- matching = [(order, receipt) for order, receipt in self.receipts.get(identity, []) if _runs_on(receipt, lane)]
+ def slowest_receipt(self, identity: str, lane: PlanLane, cell: Cell | None = None) -> Receipt | None:
+ matching = [
+ (order, receipt)
+ for order, receipt in self.receipts.get(identity, [])
+ if _runs_on(receipt, lane) and (cell is None or receipt.cell == cell)
+ ]
if not matching:
return None
return min(matching, key=lambda pair: (pair[1].throughput.requests_per_second, pair[0]))[1]
- def kept_blockers(
- self, identity: str, entry: PlanIdentity, lane: PlanLane, receipt: Receipt | None
- ) -> tuple[Blocker, ...]:
+ def kept_blockers(self, identity: str, entry: PlanIdentity, lane: PlanLane) -> tuple[Blocker, ...]:
level = self.levels[identity]
- blockers = [] if receipt is None else list(_warm_blockers(level, receipt))
+ blockers: list[Blocker] = []
+ for cell in lane.cells:
+ receipt = self.slowest_receipt(identity, lane, cell)
+ if receipt is not None:
+ blockers.extend(_warm_blockers(level, receipt))
if entry.warmth in BOOT_WARMTHS:
- boot = self.boots.get((identity, lane.cell, lane.container_shape, entry.warmth))
- if boot is not None and boot.seconds is not None:
- blocker = _come_alive_blocker(level, boot.seconds)
- blockers.extend(() if blocker is None else (blocker,))
- elif boot is not None or level.come_alive_p95_s == 0:
- blockers.append(Blocker(field="comeAliveP95S", bound=level.come_alive_p95_s, measured=None))
+ for cell in lane.cells:
+ boot = self.boots.get((identity, cell, lane.container_shape, entry.warmth))
+ if boot is not None and boot.seconds is not None:
+ blocker = _come_alive_blocker(level, boot.seconds)
+ blockers.extend(() if blocker is None else (blocker,))
+ elif boot is not None or level.come_alive_p95_s == 0:
+ blockers.append(Blocker(field="comeAliveP95S", bound=level.come_alive_p95_s, measured=None))
blockers.extend(self.reliability_blockers(level, lane.cells))
- return tuple(blockers)
+ return _worst(blockers)
def demand_hours(self, lane: PlanLane, identity: str, receipt: Receipt | None) -> float | None:
requests = self.requests.get(identity, ())
@@ -1603,7 +1617,7 @@ class _Planner:
if feasible:
return replace(choice, chosen=min(feasible, key=lambda option: option.rank))
entry, lane = current
- if standing or self.kept_blockers(identity, entry, lane, self.slowest_receipt(identity, lane)):
+ if standing or self.kept_blockers(identity, entry, lane):
return None
cost = self.current_cost(identity, entry, lane)
gaps = self.current_gaps(identity, entry, lane, cost, choice.beside)
@@ -1987,11 +2001,7 @@ class _Planner:
if price_savings:
levers.extend(self.levers(choice, new_plan, total))
nearest = self.next_cheaper(choice, baseline, new_plan, total)
- reports.append(
- self._identity_report(
- choice, names, kept, costs.get(choice.identity), receipts.get(choice.identity), nearest
- )
- )
+ reports.append(self._identity_report(choice, names, kept, costs.get(choice.identity), nearest))
identity_changes, lane_changes = _changes(self.current_plan, new_plan)
report = Report(
placement=self.parameters.placement,
@@ -2025,7 +2035,6 @@ class _Planner:
names: Mapping[str, str],
kept: Mapping[str, tuple[PlanIdentity, PlanLane]],
cost: float | None,
- receipt: Receipt | None,
next_cheaper: Option | None,
) -> IdentityReport:
current = self.current.get(choice.identity)
@@ -2047,7 +2056,7 @@ class _Planner:
lane=entry.lane,
monthly_cost=cost,
unplaced_reason=reason,
- blocked_by=self.kept_blockers(choice.identity, entry, lane, receipt),
+ blocked_by=self.kept_blockers(choice.identity, entry, lane),
next_cheaper=next_cheaper,
)
return replace(report, unplaced_reason=reason)
@@ -2151,6 +2160,17 @@ def _distinct(requests: Iterable[MeasurementRequest]) -> tuple[MeasurementReques
return tuple(kept.values())
+def _worst(blockers: Iterable[Blocker]) -> tuple[Blocker, ...]:
+ worst: dict[str, Blocker] = {}
+ for blocker in blockers:
+ known = worst.get(blocker.field)
+ if known is None or (
+ known.measured is not None and (blocker.measured is None or blocker.measured > known.measured)
+ ):
+ worst[blocker.field] = blocker
+ return tuple(worst.values())
+
+
def _scarcity_reason(option: _Option, bound: int | None) -> ScarcityReason | None:
fields = _fields(option.blockers)
if fields == [PLACEMENT_FAILURE_FIELD]:
diff --git a/packages/sie_placement/tests/test_availability.py b/packages/sie_placement/tests/test_availability.py
index 7762a5d0a..a524c1e7a 100644
--- a/packages/sie_placement/tests/test_availability.py
+++ b/packages/sie_placement/tests/test_availability.py
@@ -523,6 +523,92 @@ def test_a_lane_with_fallback_cells_hosts_no_lazy_resident():
assert all(request.warmth is not Warmth.LAZY_RESIDENT for request in result.report.measurement_requests)
+def listed(warmth=Warmth.COLD_WITH_BOUND) -> Plan:
+ floor = 1 if warmth is Warmth.PINNED else 0
+ return plan_of([lane("listed", fallbacks=(A100,), floor=floor)], {IDENTITY: ("listed", warmth)})
+
+
+ ("first", "fallback", "measured"),
+ [
+ (attempt(boot=60.0), attempt(cell=A100, boot=200.0), 200.0),
+ (attempt(boot=150.0), attempt(cell=A100, boot=200.0), 200.0),
+ (attempt(boot=200.0), attempt(cell=A100, boot=150.0), 200.0),
+ (attempt(boot=200.0), attempt(cell=A100, outcome=BootOutcome.FAILED), None),
+ (attempt(outcome=BootOutcome.TIMED_OUT), attempt(cell=A100, boot=200.0), None),
+ ],
+)
+def test_a_kept_cold_lane_names_the_worst_come_alive_of_its_listed_cells(first, fallback, measured):
+ current = listed()
+ result = run(one(120), [], [first, fallback], current=current)
+ report = result.report.identity(IDENTITY)
+ assert report.status is IdentityStatus.KEPT
+ assert report.blocked_by == (Blocker(field="comeAliveP95S", bound=120, measured=measured),)
+ assert result.plan == current
+
+
+def test_a_cold_lane_whose_fallback_cell_boots_over_the_bound_moves_to_a_measured_option():
+ current = listed()
+ receipts = [receipt(), receipt(cell=A100)]
+ result = run(one(120), receipts, [attempt(boot=60.0), attempt(cell=A100, boot=200.0)], current=current)
+ report = result.report.identity(IDENTITY)
+ assert (report.status, report.chosen.cell, report.chosen.fallback_cells, report.chosen.warmth) == (
+ IdentityStatus.PLACED,
+ L4,
+ (),
+ Warmth.COLD_WITH_BOUND,
+ )
+ assert [entry.lane for entry in result.plan.identities] == ["org-model-l4"]
+ kept = run(one(120), receipts, [attempt(boot=60.0), attempt(cell=A100, boot=100.0)], current=current)
+ assert kept.plan == current
+ assert kept.report.unchanged
+ assert kept.report.identity(IDENTITY).blocked_by == ()
+ assert kept.report.measurement_requests == ()
+
+
+def test_an_unplaced_attempt_on_a_fallback_cell_withdraws_the_cold_posture_of_a_kept_lane():
+ current = listed()
+ boots = [attempt(boot=60.0), attempt(cell=A100, boot=60.0), unplaced(A100)]
+ report = run(one(120), [], boots, current=current).report.identity(IDENTITY)
+ assert (report.status, report.blocked_by) == (
+ IdentityStatus.KEPT,
+ (Blocker(field="comeAliveP95S", bound=120, measured=None),),
+ )
+ moved = run(one(120), [receipt(), receipt(cell=A100)], boots, current=current)
+ assert [(entry.lane, entry.warmth) for entry in moved.plan.identities] == [("org-model-l4", Warmth.COLD_WITH_BOUND)]
+
+
[email protected](("measured", "asked"), [(L4, A100), (A100, L4)])
+def test_a_kept_lane_asks_for_the_receipt_and_boot_evidence_each_listed_cell_lacks(measured, asked):
+ current = listed()
+ result = run(one(120), [receipt(cell=measured)], [attempt(cell=measured, boot=60.0)], current=current)
+ assert result.plan == current
+ report = result.report.identity(IDENTITY)
+ assert (report.status, report.unplaced_reason, report.blocked_by) == (
+ IdentityStatus.KEPT,
+ UnplacedReason.CURRENT_UNMEASURED,
+ (),
+ )
+ assert [
+ (request.cell, request.container_shape, request.concurrency, request.lane, request.measure, request.reason)
+ for request in result.report.measurement_requests
+ ] == [
+ (asked, SHAPE, 8, "listed", (Measurement.BOOT_EVIDENCE,), RequestReason.UNMEASURED),
+ (asked, SHAPE, 8, "listed", (Measurement.RECEIPT,), RequestReason.UNMEASURED),
+ ]
+ assert all(request.warmth is Warmth.COLD_WITH_BOUND for request in result.report.measurement_requests)
+
+
+def test_a_kept_lane_is_held_to_the_warm_bound_at_every_listed_cell():
+ current = listed(Warmth.PINNED)
+ receipts = [receipt(rps=5.0), receipt(cell=A100, p99=300.0)]
+ result = run(one(0), receipts, scarce(), current=current)
+ report = result.report.identity(IDENTITY)
+ assert (report.status, report.lane) == (IdentityStatus.KEPT, "listed")
+ assert report.blocked_by == (Blocker(field="warmP99Ms", bound=250, measured=300.0),)
+ assert result.plan == current
+
+
def two_lanes(**overrides):
receipts = [receipt("org/a"), receipt("org/b", A100)]
return run(levels(**{"org/a": 0, "org/b": 0}), receipts, buffer_containers=1, **overrides)