draft: an adaptive draft window per sequence (RADIANCE_DRAFT_ADAPT)

One depth for every request is too shallow for code and JSON and too deep
for prose. With RADIANCE_DRAFT_ADAPT=1, --num-speculative-tokens becomes
the ceiling and each sequence drafts into the window d that maximises
E(d)/T(d): the tokens a step is expected to emit from the sequence's own
smoothed acceptance at each position, over the step's cost
(RADIANCE_DRAFT_COST, depth:ms pairs). The serial head runs as many rounds
as the deepest window in the step. A window moves only past a hysteresis
and a hold, since a new window is a new pass shape. Acceptance is
unchanged. /metrics gains radiance:draft_depth_adaptive and
radiance:draft_verify_depth_total{depth} while it is on. Unset, nothing
changes. Greedy at up to 6 against fixed 3: code +7.7 %, JSON +16.3 %.
This commit is contained in:
keptn42 authored and StillDeadcode committed 2026-10-07 11:10:19 +02:00
1 parent 73691a1189
commit 82da8eab69
11 files changed
+830 -10

No files matched your search

+5
View File
@@ -114,6 +114,11 @@ struct SchedMetrics {
int draft_depth_seen = 0;
int64_t draft_pos_reached [MAX_DRAFT_POS] = {};
int64_t draft_pos_accepted[MAX_DRAFT_POS] = {};
/* THE ADAPTIVE DRAFT WINDOW (RADIANCE_DRAFT_ADAPT), all zero while it is off: the mean window
* of the running sequences, and the verifies by the window they carried (index = drafts). */
bool draft_adaptive = false;
double draft_depth_adaptive = 0.0;
int64_t draft_verify_depth[MAX_DRAFT_POS + 1] = {};
int64_t preemptions = 0;
int64_t total_requests = 0;
/* ENGINE STEPS. One forward pass of the model plus whatever draft rounds followed it, which