drafter: a serial head that keeps no cache of its own

rad_drafter_shared_kv(b, pos_offset), an additive builder export: the
declared SERIAL head reads the trunk's K and V and writes none (Gemma 4's
assistant head has a query projection and nothing else per layer). A
plugin that does not call it drafts exactly as before; RAD_ABI_VERSION is
untouched (same pattern as rad_kv_group_zero).

For such a head the serial driver changes in two places:

- No history is owed. The history pass carries round 1 only: one row a
  drafting sequence, at the committed position, with the token the trunk
  chose after it and the trunk's hidden state there. A sequence that does
  not draft gets no row; a step with nothing to draft runs no pass.
- Every round runs at that same position, over the same context. seqused
  ends at the committed position: past it, the trunk's cache holds the K
  and V of drafts the verify rejected, or nothing.

`pos_offset` (0 or 1) is where the rows sit for the rotary, relative to the
committed position; it moves nothing else.

Card side: ADV_HIST and ADV_ROUND take the shape from AdvanceArgs::shared_kv
and rot_shift, which the scheduler fills from the Program. Host side:
serial_begin/serial_batch stage one row and a constant ceiling.

Tests: build_test checks the export's refusals; sched_test stages one verify
step both ways (the old path pinned: five history rows, rounds stepping),
checks that a cacheless head runs no pass when nothing drafts, and runs the
card's advance rows directly for both shapes.
This commit is contained in:
keptn42 committed 2026-10-10 16:29:34 +00:00
1 parent d59e0bb003
commit 997e1ae05f
11 files changed
+376 -10

No files matched your search

+14 -2
View File
@@ -191,8 +191,14 @@ public:
/* The batch the last build produced for one rank; see BatchBuilder::batch_for. */
const RadBatch* batch_for(int rank) const { return builder_.batch_for(rank); }
/* The advance's view of that build on one rank; see BatchBuilder::advance_args. */
AdvanceArgs advance_args(int rank) const { return builder_.advance_args(rank); }
/* The advance's view of that build on one rank; see BatchBuilder::advance_args. It carries
* the serial head's shape as well, which only the draft passes' modes read. */
AdvanceArgs advance_args(int rank) const {
AdvanceArgs a = builder_.advance_args(rank);
a.shared_kv = serial_shared_ ? 1 : 0;
a.rot_shift = serial_rot_shift_;
return a;
}
void fini();
/* ---------------------------------------------------------- off the step path */
@@ -522,6 +528,12 @@ private:
* that point would give back more than two windows is kept whole. The drafter's window, or 0
* where no hit can leave such a hole. */
int64_t draft_refill_ = 0;
/* A SERIAL HEAD WITH NO CACHE OF ITS OWN (rad_drafter_shared_kv), off the Program at init. It
* owes no history, so serial_begin gives it one row a drafting sequence and none to a sequence
* that does not draft, and its rounds stay at the committed position (advance.h). False and 0
* for every other drafter, whose passes are staged exactly as before. */
bool serial_shared_ = false;
int32_t serial_rot_shift_ = 0;
BatchBuilder builder_;
DraftController draft_;