draft: cap every adaptive window under load (RADIANCE_DRAFT_ADAPT_BUSY)

The cost table prices a step at one sequence. Under load every row a step
adds is expert bandwidth its neighbours wait on, and the adaptive window
lost 4 % at 8 concurrent requests. With RADIANCE_DRAFT_ADAPT_BUSY=N and
more than N sequences running, every window is capped at
RADIANCE_DRAFT_ADAPT_BUSY_DEPTH (default 3); the estimates keep learning.
The count is taken once a cycle and held to its end, so the plan, the
rounds, expect_draft and set_draft see one cap. Unset, nothing changes.
This commit is contained in:
keptn42 authored and StillDeadcode committed 2026-10-07 11:10:19 +02:00
1 parent 82da8eab69
commit 76727fa050
5 files changed
+215 -14

No files matched your search

+19 -4
View File
@@ -501,13 +501,28 @@ private:
/* THE WINDOW A SEQUENCE MAY DRAFT INTO: the configured depth, or under RADIANCE_DRAFT_ADAPT
* the one its own acceptance pays for (DraftController::depth_for, which starts the estimate
* on the first ask). It is the rule every site that caps a proposal applies -- step(),
* set_draft(), expect_draft() and the rounds in serial_begin() -- and with the policy off it
* is next_depth(), exactly as before. */
* on the first ask), under this cycle's load cap. It is the rule every site that caps a
* proposal applies -- step(), set_draft(), expect_draft() and the rounds in serial_begin() --
* and with the policy off it is next_depth(), exactly as before. */
int draft_cap(SchedReq& s) const {
return draft_.adaptive() ? draft_.depth_for(s.adapt) : draft_.next_depth();
if (!draft_.adaptive()) return draft_.next_depth();
const int d = draft_.depth_for(s.adapt);
return (draft_busy_cap_ > 0 && d > draft_busy_cap_) ? draft_busy_cap_ : d;
}
/* THE LOAD CAP OF THE CYCLE IN FLIGHT (RADIANCE_DRAFT_ADAPT_BUSY, draft.h), 0 for none.
*
* COUNTED ONCE A CYCLE AND HELD, by draft_cycle(), which is the first thing step() and
* promote_next() do -- every cycle opens with exactly one of the two. A cycle's proposal
* passes through four sites -- the plan that verifies it, the rounds that draft the next one,
* expect_draft() and set_draft() -- and the step issued ahead holds them to agree: it was
* built with the count expect_draft() gave it, and set_draft() refuses a different one. A
* cap read live could move between them, because a commit or a client hanging up takes a
* sequence out of running_ mid-cycle; held, it moves only where a cycle starts, and a
* proposal drafted under one cap and planned under the next is only ever cut shorter. */
int32_t draft_busy_cap_ = 0;
void draft_cycle();
/* The built-in prompt-lookup drafter (scheduler.cpp). Fills s.draft and returns how many
* tokens it proposed; 0 when the sequence has no repeated pattern to extend. The pattern
* lengths it tries, longest first. */