abi, sched: RadBatch::anchor_rows, ABI 36

A block drafter's query pass gets, for each drafting sequence, the row of its last committed
position in the context pass just run (StepSlot::hrow, written by the advance on the card).
LiLiCorr's correlator reads the context state there. Appended after bidi_used; main ships
ABI 35 and an appended field is read past the end of an older engine's copy, so the version is
36 and the layout table follows. The pass key reads the pointer.
This commit is contained in:
keptn42 committed 2026-11-04 22:08:06 +01:00
1 parent a1b7643310
commit dccc6329a9
10 files changed
+40 -8

No files matched your search

+3 -1
View File
@@ -968,7 +968,7 @@ int Ctx::lane_join(int from, int to) {
* geometries fail closed via the pass-key contract, while Qwen keys its full-group maximum in the
* architecture callback. `agen_b`, `vgen_b` and `sgen_b` are set only on generator passes, which are
* never recorded (below). */
static_assert(sizeof(void*) != 8 || sizeof(RadBatch) == 472,
static_assert(sizeof(void*) != 8 || sizeof(RadBatch) == 480,
"RadBatch changed: check that Ctx::pass_key reads every new field a pass depends on");
static_assert(sizeof(void*) != 8 || sizeof(RadKVGroupBatch) == 88,
"RadKVGroupBatch changed: check that Ctx::pass_key reads every new field");
@@ -1011,6 +1011,8 @@ uint64_t Ctx::pass_key(const RadBatch* b) const {
ptr(b->token_ids); ptr(b->positions); ptr(b->cu_seqlens); ptr(b->seq_ids);
ptr(b->out_ids); ptr(b->q_lens); ptr(b->ctx_lens); ptr(b->num_accepted);
ptr(b->spec_parent); ptr(b->checkpoint_tok); ptr(b->checkpoint_slot); ptr(b->draft_out_ids);
/* A block drafter's query pass reads it (null on every other pass). */
ptr(b->anchor_rows);
/* Null on a step with no adapter row, which then issues no adapter op (Ctx::issue_lora): the
* two are different passes. The slots themselves are read on the card. */
ptr(b->lora_slot);
+6 -1
View File
@@ -48,7 +48,11 @@ struct StepSlot {
* drafter's context rows by it. 0 after a chain verify, which needs neither. */
int32_t npath;
int32_t path[RAD_SCHED_MAX_SPEC];
int32_t pad[2];
/* The last verify step's row of its last committed position, in that step's own row order,
* which a block drafter's context pass mirrors. ADV_BLOCK hands it to the query pass
* (RadBatch::anchor_rows): LiLiCorr's correlator reads the context state there. */
int32_t hrow;
int32_t pad[1];
};
enum AdvMode : int32_t {
@@ -115,6 +119,7 @@ struct AdvanceArgs {
int32_t n_groups = 0;
char* slab = nullptr; /* this rank's device slab */
int64_t tok_off = 0, pos_off = 0, ctx_off = 0, acc_off = 0, out_off = 0;
int64_t arow_off = -1; /* [n_seq] ADV_BLOCK: each row's StepSlot::hrow; -1 when not carved */
int64_t sid_off = 0, cu_off = 0, q_off = 0;
/* [4][row_pitch] int32: device-row flag; the verify step's token row of the row's first
* verified position; its first sampled row, or -1 for a row that sampled nothing; and one
+3
View File
@@ -153,6 +153,7 @@ RAD_ADV_FN void adv_row(const AdvanceArgs& a, int i) {
S.ctx = head + 1;
S.n_acc = acc + 1;
S.tok[0] = y[acc == 0 ? 0 : S.path[acc - 1]];
S.hrow = rtok + (acc == 0 ? 0 : S.path[acc - 1]); /* rows are nodes, in order */
S.npath = acc;
return;
}
@@ -167,6 +168,7 @@ RAD_ADV_FN void adv_row(const AdvanceArgs& a, int i) {
const int32_t head = ctx[i] + (rtok - k) + acc;
S.acc = acc;
S.head = head;
S.hrow = rtok + acc;
S.ctx = head + 1;
S.n_acc = acc + 1;
S.tok[0] = y[acc];
@@ -296,6 +298,7 @@ RAD_ADV_FN void adv_row(const AdvanceArgs& a, int i) {
for (int32_t j = 1; j < n; ++j) tok[k + j] = aux;
for (int32_t j = 0; j < n; ++j) adv_pos(a, pos, k + j, base + j);
ctx[i] = base;
if (a.arow_off >= 0) adv_i32(a, a.arow_off)[i] = S.hrow;
adv_groups(a, i, k, base, n);
return;
}
+5
View File
@@ -123,6 +123,7 @@ void BatchBuilder::carve(Set& s, char* h) {
/* The advance's per-sequence runtime-window data (advance.h); 0 when there is none. */
pair(&s.h_rpos, &s.d_rpos, S);
pair(&s.h_tlen, &s.d_tlen, S);
pair(&s.h_arow, &s.d_arow, S);
s.h_grp = ::rad::carve<AdvGroup>(h, oh, (int64_t)s.groups.size());
s.d_grp = ::rad::carve<AdvGroup>(d, od, (int64_t)s.groups.size());
for (size_t gi = 0; gi < s.groups.size(); ++gi) {
@@ -1107,6 +1108,7 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
s.h_q[i] = e.n_tokens;
s.h_ctx[i] = e.ctx_len;
s.h_acc[i] = e.n_accepted;
s.h_arow[i] = -1;
if (e.is_prefill) { if (e.n_tokens > max_q_pf) max_q_pf = e.n_tokens; }
else { if (e.n_tokens > max_q_dec) max_q_dec = e.n_tokens; }
}
@@ -1264,6 +1266,8 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
B.num_accepted = cfg_.n_spec > 0 ? on_rank(base, b0, s.d_acc) : nullptr;
/* Staged above on a tree step: each row's parent row, -2 for an ordinary causal one. */
B.spec_parent = plan.spec_is_tree ? on_rank(base, b0, s.d_parent) : nullptr;
/* Pass 1 is a block drafter's query pass (a serial head has no pass 1). */
B.anchor_rows = plan.draft_pass == 1 ? on_rank(base, b0, s.d_arow) : nullptr;
B.rope_pos = mm_on_ ? on_rank(base, b0, s.d_rope) : nullptr;
B.rope_mixed = rope_mixed;
B.n_mm_rows = n_mm;
@@ -1348,6 +1352,7 @@ AdvanceArgs BatchBuilder::advance_args(int rank) const {
a.ctx_off = off(s.d_ctx);
a.acc_off = off(s.d_acc);
a.out_off = off(s.d_out);
a.arow_off = off(s.d_arow);
a.sid_off = off(s.d_sid);
a.cu_off = off(s.d_cu);
a.q_off = off(s.d_q);
+3
View File
@@ -220,6 +220,9 @@ private:
* runtime window (advance.h). Per sequence because each prompt has its own floor. */
int32_t *h_rpos = nullptr, *d_rpos = nullptr;
int32_t *h_tlen = nullptr, *d_tlen = nullptr;
/* [max_seqs] a block drafter's query pass: each row's last committed row in the context
* pass just run (RadBatch::anchor_rows), written on the card by ADV_BLOCK. */
int32_t *h_arow = nullptr, *d_arow = nullptr;
char* h_derived = nullptr; /* derivation staging, byte-addressed */
/* [3][n_tok] rotary positions and [n_tok] encoder-row targets (RadBatch::rope_pos,