Archived
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:
1 parent
d59e0bb003
commit
997e1ae05f
11 files changed
+376
-10
No files matched your search
@@ -1272,6 +1272,32 @@ int Builder::declare_drafter(const RadDrafterDecl* d) {
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
/* A SERIAL HEAD THAT READS THE TRUNK'S CACHE AND KEEPS NONE (rad_builder.h). Checked here for the
|
||||
* reason declare_drafter checks everything: the driver only reaches the head once a request
|
||||
* speculates, and a head staged the wrong way round costs acceptance and says nothing. */
|
||||
int Builder::drafter_shared_kv(int pos_offset) {
|
||||
if (finished_) {
|
||||
err(RAD_E_STATE, "drafter_shared_kv after declare finished");
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
if (prog_.drafter.kind != RAD_DRAFT_SERIAL) {
|
||||
err(RAD_E_STATE, "drafter_shared_kv: %s. Only a SERIAL head runs round after round at one "
|
||||
"position; declare it with rad_declare_drafter first.",
|
||||
prog_.drafter.kind == RAD_DRAFT_NONE ? "no drafter is declared"
|
||||
: "the declared drafter is a BLOCK drafter");
|
||||
return RAD_E_STATE;
|
||||
}
|
||||
if (pos_offset != 0 && pos_offset != 1) {
|
||||
err(RAD_E_INVAL, "drafter_shared_kv '%s': pos_offset %d. The rows sit at the committed "
|
||||
"position (0) or one past it (1); nothing else names a position the head "
|
||||
"was trained at.", prog_.drafter_name.c_str(), pos_offset);
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
prog_.drafter_shared_kv = true;
|
||||
prog_.drafter_pos_offset = pos_offset;
|
||||
return RAD_OK;
|
||||
}
|
||||
|
||||
void Builder::note_v(const char* f, va_list ap) {
|
||||
char msg[1024];
|
||||
vsnprintf(msg, sizeof msg, f ? f : "", ap);
|
||||
@@ -1762,6 +1788,11 @@ int rad_declare_drafter(RadBuilder* b, const RadDrafterDecl* d) {
|
||||
return B(b)->declare_drafter(d);
|
||||
}
|
||||
|
||||
int rad_drafter_shared_kv(RadBuilder* b, int pos_offset) {
|
||||
if (!b) return RAD_E_INVAL;
|
||||
return B(b)->drafter_shared_kv(pos_offset);
|
||||
}
|
||||
|
||||
int rad_declare_encoder(RadBuilder* b, const RadEncoderDecl* d) {
|
||||
if (!b) return RAD_E_INVAL;
|
||||
return B(b)->declare_encoder(d);
|
||||
|
||||
Reference in new issue
Block a user