sched: --draft-window adaptive applies to block drafters

The adaptive window priced only a serial head's rounds and was refused for a
block drafter, on the grounds that the block is proposed in one pass. But
every verified draft is still a verify row, and on a MoE whose verify reads
the experts each row routes to, rows are not free (16 rows read ~10x the
experts one does). A block drafter now takes the same policy with its rounds
fixed: each sequence verifies the first min(D, its stop) of the block, its
stop from its own measured acceptance and D from the measured step times.
Prompt lookup alone keeps the fixed window and says so.

Speculation stays lossless: what is verified is a prefix of the proposal.

Measured on gemma-4-26B-A4B-it + z-lab DFlash (block 15), 4x R9700, TP4,
together with gemma4k's split-KV merge rewrite (landed in the same build, so
the two are not separated): story at T=1 95 -> 177 tok/s, greedy thinking
~360 -> 572 tok/s; code at T=0 319-334 tok/s (it verifies deep either way).

tests/sched_test.cpp: the block-drafter case now expects the policy on
(4 drafts verified while the estimate is the prior, 1 after 64 rejected
steps, draft_verify_depth[4] and [1] both counted); the prompt-lookup-only
and no-speculation cases are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
AshlynandClaude Opus 5.5 committed 2026-10-12 14:40:04 -05:00
1 parent fb716830c2
commit 29bfe8f00c
2 files changed
+63 -22

No files matched your search

+41 -9
View File
@@ -2170,10 +2170,10 @@ TEST(the_adaptive_window_chooses_the_head_depth_over_the_whole_batch) {
CHECK_EQ(h.plan_step(hone, 0, 3), 2);
}
/* THE FLAG, AND ONLY FOR A SERIAL HEAD. --draft-window adaptive with a block drafter, with prompt
* lookup alone, or with no speculation keeps the configured depth and says so at startup; the
* proposal then reaches the step uncut. The default is the fixed window. */
TEST(the_adaptive_window_is_a_flag_for_a_serial_drafter_and_said_when_it_is_not) {
/* THE FLAG, FOR A DRAFTING HEAD -- SERIAL OR BLOCK. --draft-window adaptive with prompt lookup
* alone, or with no speculation, keeps the configured depth and says so at startup; the proposal
* then reaches the step uncut. The default is the fixed window. */
TEST(the_adaptive_window_is_a_flag_for_a_drafting_head_and_said_when_there_is_none) {
{
Fixture f;
adaptive_fixture(f, 4);
@@ -2192,18 +2192,50 @@ TEST(the_adaptive_window_is_a_flag_for_a_serial_drafter_and_said_when_it_is_not)
Config d;
CHECK(d.draft_window == kDraftWindowDefault); /* the default */
}
for (int kind : { (int)RAD_DRAFT_BLOCK, (int)RAD_DRAFT_NONE }) {
/* A BLOCK DRAFTER TAKES THE POLICY WITH ITS ROUNDS FIXED. It proposes its whole block in one
* pass, and each sequence verifies the first of it up to its own window: the whole block while
* its estimate is the prior, one draft once its drafts stop being taken. Startup says so. */
{
Fixture f;
adaptive_fixture(f, 4);
f.prog.drafter.kind = (decltype(f.prog.drafter.kind))kind;
if (kind == RAD_DRAFT_NONE) f.prog.drafter.depth = 0;
f.prog.drafter.kind = RAD_DRAFT_BLOCK;
int st = RAD_E_STATE;
const std::string log = stderr_of([&] { st = f.start(); });
CHECK_OK(st);
CHECK(f.sch.draft().adaptive());
CHECK(log.find("ADAPTIVE") != std::string::npos);
CHECK(log.find("with a block drafter") != std::string::npos);
CHECK(log.find("the window is fixed") == std::string::npos);
const uint64_t a = f.submit(160, 2000);
CHECK(f.sch.step() != nullptr);
f.commit_plain(11);
int32_t draft[4] = { 21, 22, 23, 24 };
CHECK_OK(f.sch.set_draft(a, draft, 4));
CHECK_EQ(f.sch.find(a)->n_draft, 4);
for (int t = 0; t < 64; ++t) { /* no draft is ever taken */
REQUIRE(f.sch.step() != nullptr);
f.commit_plain(9);
CHECK_OK(f.sch.set_draft(a, draft, 4));
}
CHECK_EQ(f.sch.find(a)->n_draft, 1);
REQUIRE(f.sch.step() != nullptr);
for (const StepEntry& e : f.sch.plan().e) CHECK_EQ(e.n_spec, 1);
CHECK(f.sch.metrics().draft_adaptive);
CHECK(f.sch.metrics().draft_verify_depth[4] > 0);
CHECK(f.sch.metrics().draft_verify_depth[1] > 0);
}
{
Fixture f;
adaptive_fixture(f, 4);
f.prog.drafter.kind = RAD_DRAFT_NONE;
f.prog.drafter.depth = 0;
int st = RAD_E_STATE;
const std::string log = stderr_of([&] { st = f.start(); });
CHECK_OK(st);
CHECK(!f.sch.draft().adaptive());
CHECK(log.find("--draft-window adaptive: the window is fixed at 4") != std::string::npos);
CHECK(log.find(kind == RAD_DRAFT_BLOCK ? "a block drafter" : "prompt lookup only") !=
std::string::npos);
CHECK(log.find("prompt lookup only") != std::string::npos);
const uint64_t a = f.submit(160, 64);
CHECK(f.sch.step() != nullptr);