Archived
radiance 1.14.0
New models and formats: - libr3d: a kernel library for RDNA3 (gfx11) cards - nomic-embed-text-v2-moe (the nomicbert plugin) - Gemma 4 E2B with its per-layer MLP width, and Google's unmodified E2B/E4B directories in bf16 - DeepSeek-V4.1-Flash converted straight from its release: the Engram tables, the fused imatrix and rad-convert --chat-template for a release that ships no template - GGUF Q8_0, Q4_K and Q6_K tensors import as their planes; rad-convert writes them without a recipe - Qwen3.8-Flash-Next-FP8 converts and serves through qwen4exp_fp8 Speed: - hc_read's decode kernels as one grid (34.7 -> 25.2 us at 4 rows) and its tiled up-mix pipelined - gemm_fp8a8: the narrow form's scales staged through LDS (Flash-Next int8 at 32 rows 83.6 -> 68.3 us), the gated three-tile form at 8 waves (gate_up at 48 rows 272.9 -> 180.6 us) - Qwen3.8-27B: the delta net's out-projection read beside its decode recurrent update (x1 19.40 -> 19.10 ms a step), and the verify's split-KV attention sized by context depth (x3 at 180K 42.4 -> 40.3 ms a step) - Hy-Memory (HYV3) decode: fused QK norm, RoPE and KV store, residual adds folded into the norms, coalesced one-token expert GEMMs - spechub: the coupled verify walks the live candidates only (151 -> 31 us a launch) Speculation: - DFlash2: lossless coupled acceptance at T > 0 (--draft-coupling on) - A block drafter's proposals verified as a tree, on by default for the Gemma 4 31B's DFlash2, with a block-16 tree that runs its short block under load Features: - Decode-hot residency: --draft-expert-placement host, --expert-profile, --expert-pin-top, and --expert-stats FILE for the routed experts each layer selects - --ngram-placement ram=DIR: one n-gram table shared by engines on separate cards - Prefix cache: --prefix-resume exact (default) resumes a hit on the cold run's own chunk grid, so it answers bit-identically; snapshots at a head other prompts share, from 528-token prompts, and for tip-only one drafter window below the tip; hits on models whose KV groups have different block sizes; the snapshot store keeps a floor of 8 ahead of --host-headroom-mib - Typed tool-call argument tags; rad-chatparse --request renders and reads back one request as the server does - MiniMax-H3: keyframes ride a latent upscale - Gemma 3's fused all-reduce junction on the lossy wire Fixes: - A speculative step shorter than its band (an MTP step of 4 rows at gqa 8) no longer stops the engine with a scratch refusal at issue (#293) - --p2p off: prefill back to 1.12.0's rate; 1.13.0's push check read a host-memory slot over the link twice (#323) - A chat template that cannot render a conversation is refused at load, not mid-request - imatrix entries found under llama.cpp's spelling; the W4A8 prefill's tail scale read; the GDN conv kernels on an f32 weight; dense integer rows at the group they compute (a Q8_0 weight at group 32) - --expert-profile refuses a profile recorded on another model - hc_read's one-grid wait traps past its deadline instead of reading a stale value Changes: Plugin ABI 31, unchanged. RADIANCE_DRAFT_TREE, DFLASH2_TREE_NODES, DFLASH2_TREE_TEMP and DFLASH_Q_TEMP are gone (trees run where the probe says they pay; temperatures 1.25 / 0.6).
This commit is contained in:
1 parent
481fcd5df0
commit
4a61d7296b
160 files changed
+8790
-6819
No files matched your search
@@ -23,4 +23,24 @@ int step_advance(const AdvanceArgs& a, RadStream s) {
|
||||
#endif
|
||||
}
|
||||
|
||||
int step_compact(const AdvanceArgs& a, RadStream s) {
|
||||
if (a.n_seq <= 0 || a.n_pool <= 0) return RAD_OK;
|
||||
if (device_is_host()) {
|
||||
RAD_TRY(rad_stream_sync(s));
|
||||
const int items = adv_compact_items(a);
|
||||
for (int i = 0; i < a.n_seq; ++i)
|
||||
for (int w = 0; w < items; ++w) {
|
||||
int p = 0, l = 0, h = 0;
|
||||
if (adv_compact_item(a, w, &p, &l, &h)) adv_compact(a, i, p, l, h, 0, 1);
|
||||
}
|
||||
return RAD_OK;
|
||||
}
|
||||
#if defined(RAD_HAVE_HIP) && RAD_HAVE_HIP
|
||||
return rad_step_compact_launch(&a, (void*)s) == 0 ? RAD_OK : RAD_E_DEVICE;
|
||||
#else
|
||||
(void)s;
|
||||
return RAD_E_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
} /* namespace rad */
|
||||
+53
-1
@@ -35,7 +35,20 @@ struct StepSlot {
|
||||
int32_t acc; /* drafts the last verify step accepted */
|
||||
/* The next verify step's input tokens: the bonus token, then the draft head's proposals. */
|
||||
int32_t tok[1 + RAD_SCHED_MAX_SPEC];
|
||||
int32_t pad[3];
|
||||
/* A tree drafter's proposal (rad_drafter_tree): par[j] is the parent of node j + 1, a node
|
||||
* index in [0, j], where node 0 is the bonus token tok[0] and node j + 1 is tok[j + 1].
|
||||
* `ntree` is the number of nodes it describes, written by ADV_BTAKE from the drafter's
|
||||
* parents plane; 0 means tok[1..] is a chain. */
|
||||
int32_t par[RAD_SCHED_MAX_SPEC];
|
||||
int32_t ntree;
|
||||
/* The last verify's accepted root path: path[t] is the node committed (t + 1)-th, so the
|
||||
* committed tokens are tok[path[0]], tok[path[1]], ... and the step's anchor sits at
|
||||
* ctx - 1 - npath. ADV_COMPACT moves those nodes' K and V from where the verify stored them
|
||||
* (its row index) to where they belong (their depth), and ADV_CTXTREE positions the
|
||||
* 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];
|
||||
};
|
||||
|
||||
enum AdvMode : int32_t {
|
||||
@@ -47,6 +60,26 @@ enum AdvMode : int32_t {
|
||||
/* A block drafter (RAD_DRAFT_BLOCK) on the card: */
|
||||
ADV_BLOCK = 6, /* before the query pass: the anchor at the committed end, then the masks */
|
||||
ADV_BTAKE = 7, /* after it: its `round` proposals into the state, behind the bonus token */
|
||||
/* A tree drafter (rad_drafter_tree), whose verify rows are a tree rather than a chain: */
|
||||
ADV_CTXTREE = 8, /* before the context pass: the accepted path's rows at their depth, the
|
||||
* rejected rows stored nowhere */
|
||||
};
|
||||
|
||||
/* The most paged KV groups one ADV_COMPACT moves (the trunk's sliding and global groups and a
|
||||
* drafter's own, with room). */
|
||||
enum { kAdvMaxPools = 6 };
|
||||
|
||||
/* One paged group's cache on one rank, as ADV_COMPACT addresses it: `n_layers` caches of
|
||||
* [n_blocks, n_head, block_size, row_bytes] bytes, `layer_stride` apart from `base`
|
||||
* (core/runtime/kvbind.cpp composes that shape). `grp` indexes the batch's AdvGroup array, whose
|
||||
* block table maps a position to a block. */
|
||||
struct AdvPool {
|
||||
char* base;
|
||||
int64_t layer_stride;
|
||||
int32_t n_layers;
|
||||
int32_t n_head;
|
||||
int32_t row_bytes;
|
||||
int32_t grp;
|
||||
};
|
||||
|
||||
/* One KV group, as the builder stages it for this build. Offsets are bytes into the rank's slab,
|
||||
@@ -112,12 +145,31 @@ struct AdvanceArgs {
|
||||
* position of those rows, 0 or 1 past the committed position. Zero for every other head. */
|
||||
int32_t shared_kv = 0;
|
||||
int32_t rot_shift = 0;
|
||||
/* A tree drafter (rad_drafter_tree). ADV_BTAKE: the proposal's parents plane, row i's from
|
||||
* i * src_pitch as the tokens are; null for a chain drafter. */
|
||||
const int32_t* par = nullptr;
|
||||
/* ADV_TRUNK: RadBatch::spec_parent [n_tok] in the slab, or -1 when the build stages none.
|
||||
* A tree row's entry is its parent's row within the sequence's block (-1 for the bonus
|
||||
* token); every other row's is -2, an ordinary causal row. */
|
||||
int64_t parent_off = -1;
|
||||
/* ADV_COMPACT: every paged group's cache on this rank. */
|
||||
AdvPool pool[kAdvMaxPools] = {};
|
||||
int32_t n_pool = 0;
|
||||
};
|
||||
|
||||
/* Issue one advance on `s`. The rows are independent, so the card runs them in parallel. */
|
||||
int step_advance(const AdvanceArgs& a, RadStream s);
|
||||
|
||||
/* ADV_COMPACT, after ADV_ACCEPT on a tree verify and before anything reads the trunk's cache: for
|
||||
* every row whose StepSlot holds an accepted path, move the K and V each path node's verify row
|
||||
* stored (at the anchor's position + its row index) to its committed position (+ its depth), in
|
||||
* every pool of `a`, every layer and every head. A separate kernel from the advance because it
|
||||
* moves bytes across the whole cache rather than patching a row's few integers. */
|
||||
int step_compact(const AdvanceArgs& a, RadStream s);
|
||||
|
||||
} /* namespace rad */
|
||||
|
||||
/* The launcher in advance.hip: one kernel onto `stream` through hipLaunchKernel. */
|
||||
extern "C" int rad_step_advance_launch(const rad::AdvanceArgs* args, void* stream);
|
||||
/* And ADV_COMPACT's. */
|
||||
extern "C" int rad_step_compact_launch(const rad::AdvanceArgs* args, void* stream);
|
||||
@@ -59,8 +59,51 @@ __global__ __launch_bounds__(kThreads) void r4dchain_step_advance(rad::AdvanceAr
|
||||
}
|
||||
}
|
||||
|
||||
/* ADV_COMPACT: block (x, y) is work item x (a pool, layer and head) of batch row y; its threads
|
||||
* split the K|V row into 16-byte chunks. Chained like the advance where launches chain, every
|
||||
* block waiting for the kernels before it and counting itself in after its moves. */
|
||||
constexpr int kCompactThreads = 64;
|
||||
__device__ __forceinline__ void step_compact_body(const rad::AdvanceArgs& a) {
|
||||
int p = 0, l = 0, h = 0;
|
||||
if (!rad::adv_compact_item(a, (int)blockIdx.x, &p, &l, &h)) return;
|
||||
rad::adv_compact(a, (int)blockIdx.y, p, l, h, (int)threadIdx.x, kCompactThreads);
|
||||
}
|
||||
__global__ __launch_bounds__(kCompactThreads) void rad_step_compact(rad::AdvanceArgs a) {
|
||||
step_compact_body(a);
|
||||
}
|
||||
__global__ __launch_bounds__(kCompactThreads) void r4dchain_step_compact(rad::AdvanceArgs a) {
|
||||
const ChainRec* r = chain_rec();
|
||||
if (r) {
|
||||
if (threadIdx.x == 0)
|
||||
while (__hip_atomic_load(r->ctr, __ATOMIC_RELAXED, __HIP_MEMORY_SCOPE_AGENT) < r->target)
|
||||
__builtin_amdgcn_s_sleep(1);
|
||||
__syncthreads();
|
||||
__builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent");
|
||||
}
|
||||
step_compact_body(a);
|
||||
if (r) {
|
||||
__builtin_amdgcn_fence(__ATOMIC_RELEASE, "agent");
|
||||
__syncthreads();
|
||||
if (threadIdx.x == 0)
|
||||
__hip_atomic_fetch_add(r->ctr, 1ull, __ATOMIC_RELEASE, __HIP_MEMORY_SCOPE_AGENT);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" int rad_step_compact_launch(const rad::AdvanceArgs* args, void* stream) {
|
||||
if (!args || args->n_seq <= 0) return 0;
|
||||
const int items = rad::adv_compact_items(*args);
|
||||
if (items <= 0) return 0;
|
||||
if (!rad_dev_chain_enabled())
|
||||
hipLaunchKernelGGL(rad_step_compact, dim3((unsigned)items, (unsigned)args->n_seq),
|
||||
dim3(kCompactThreads), 0, (hipStream_t)stream, *args);
|
||||
else
|
||||
hipLaunchKernelGGL(r4dchain_step_compact, dim3((unsigned)items, (unsigned)args->n_seq),
|
||||
dim3(kCompactThreads), 0, (hipStream_t)stream, *args);
|
||||
return hipGetLastError() == hipSuccess ? 0 : -1;
|
||||
}
|
||||
|
||||
extern "C" int rad_step_advance_launch(const rad::AdvanceArgs* args, void* stream) {
|
||||
if (!args || args->n_seq <= 0) return 0;
|
||||
const unsigned blocks = (unsigned)((args->n_seq + kThreads - 1) / kThreads);
|
||||
|
||||
+171
-13
@@ -28,6 +28,20 @@ RAD_ADV_FN bool adv_is_eog(const AdvanceArgs& a, int32_t t) {
|
||||
return lo < a.n_eog && a.eog[lo] == t;
|
||||
}
|
||||
|
||||
/* Group `e`'s slot for position `p` of batch row `i`, or -1 past its block table. A runtime
|
||||
* window's position at or past ring_pos is in its ring (see adv_groups). */
|
||||
RAD_ADV_FN int32_t adv_slot(const AdvanceArgs& a, const AdvGroup& e, int i, int32_t p) {
|
||||
const int32_t first = adv_i32(a, e.first_off)[i];
|
||||
const int32_t* bt = adv_i32(a, e.bt_off) + (int64_t)i * e.pitch;
|
||||
int32_t bi = (p - first) / e.block_size;
|
||||
if (e.ring && e.ring_blocks > 0 && adv_i32(a, e.tlen_off)[i] > 0) {
|
||||
const int32_t rpos = adv_i32(a, e.rpos_off)[i];
|
||||
if (p >= rpos) bi = rpos / e.block_size + ((p - rpos) / e.block_size) % e.ring_blocks;
|
||||
}
|
||||
return (p >= first && bi >= 0 && bi < e.pitch && bt[bi] >= 0)
|
||||
? bt[bi] * e.block_size + p % e.block_size : -1;
|
||||
}
|
||||
|
||||
/* Every group's slots for the row's `n` positions (from the positions just written) and its
|
||||
* length from `base`. A position past the block table gets slot -1 ("no slot"); the builder sizes
|
||||
* tables for the furthest reachable position, so only a row whose output is unused hits this.
|
||||
@@ -43,16 +57,18 @@ RAD_ADV_FN bool adv_is_eog(const AdvanceArgs& a, int32_t t) {
|
||||
* off the table once the ring wraps.
|
||||
*
|
||||
* `len`, when given, is the length's count from `base` in place of `n` (ADV_HIST: rows that
|
||||
* repeat a position must not lengthen the context). */
|
||||
* repeat a position must not lengthen the context). `at`, when given, is where each row stores its
|
||||
* K and V instead of its position: a tree verify's rows rotate at their depth but store at their
|
||||
* row index, since siblings share a depth (ADV_TRUNK), and a context row the tree rejected stores
|
||||
* nowhere (-1, ADV_CTXTREE). */
|
||||
RAD_ADV_FN void adv_groups(const AdvanceArgs& a, int i, int32_t k, int32_t base, int32_t n,
|
||||
int32_t len = -1) {
|
||||
int32_t len = -1, const int32_t* at = nullptr) {
|
||||
const AdvGroup* G = reinterpret_cast<const AdvGroup*>(a.slab + a.grp_off);
|
||||
const int32_t* pos = adv_i32(a, a.pos_off);
|
||||
for (int g = 0; g < a.n_groups; ++g) {
|
||||
const AdvGroup& e = G[g];
|
||||
const int32_t first = adv_i32(a, e.first_off)[i];
|
||||
/* Per sequence: each prompt has its own floor and its own table (advance.h). */
|
||||
const int32_t rpos = e.ring ? adv_i32(a, e.rpos_off)[i] : 0;
|
||||
const int32_t tlen = e.ring ? adv_i32(a, e.tlen_off)[i] : 0;
|
||||
const bool ring = e.ring && tlen > 0;
|
||||
int64_t used = (int64_t)base + (len >= 0 ? len : n) - first;
|
||||
@@ -62,20 +78,22 @@ RAD_ADV_FN void adv_groups(const AdvanceArgs& a, int i, int32_t k, int32_t base,
|
||||
}
|
||||
adv_i32(a, e.used_off)[i] = (int32_t)used;
|
||||
if (!e.paged) continue;
|
||||
const int32_t* bt = adv_i32(a, e.bt_off) + (int64_t)i * e.pitch;
|
||||
int32_t* slot = adv_i32(a, e.slot_off);
|
||||
for (int32_t j = 0; j < n; ++j) {
|
||||
const int32_t p = pos[k + j];
|
||||
int32_t bi = (p - first) / e.block_size;
|
||||
if (ring && p >= rpos && e.ring_blocks > 0)
|
||||
bi = rpos / e.block_size +
|
||||
((p - rpos) / e.block_size) % e.ring_blocks;
|
||||
slot[k + j] = (p >= first && bi >= 0 && bi < e.pitch && bt[bi] >= 0)
|
||||
? bt[bi] * e.block_size + p % e.block_size : -1;
|
||||
const int32_t p = at ? at[j] : pos[k + j];
|
||||
slot[k + j] = p >= 0 ? adv_slot(a, e, i, p) : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* A tree's node depths from its parents: node 0 (the bonus token) at 0, node j + 1 one below
|
||||
* par[j]. A parent outside [0, j] is a drafter bug; it is read as the previous node, so the row
|
||||
* still stores and rotates somewhere sane, and the verify rejects whatever it proposed. */
|
||||
RAD_ADV_FN int32_t adv_parent(const StepSlot& S, int32_t j) {
|
||||
const int32_t p = S.par[j - 1];
|
||||
return (p < 0 || p >= j) ? j - 1 : p;
|
||||
}
|
||||
|
||||
/* Writes a row's position and moves its rotary components by the same amount. A row whose
|
||||
* position does not change keeps the host's components. */
|
||||
RAD_ADV_FN void adv_pos(const AdvanceArgs& a, int32_t* pos, int32_t row, int32_t p) {
|
||||
@@ -108,10 +126,39 @@ RAD_ADV_FN void adv_row(const AdvanceArgs& a, int i) {
|
||||
|
||||
switch (a.mode) {
|
||||
case ADV_ACCEPT: {
|
||||
const int32_t* y = a.src + rout;
|
||||
/* A tree verify, which the trunk's spec_parent row says (its first entry is -1, the root,
|
||||
* whoever staged it: ADV_TRUNK for a card row, the builder for a host row): accept_tree's
|
||||
* rule. From the bonus token, follow the first child (lowest node index) whose token is
|
||||
* the target's pick at its parent's row, as long as one is; then the same
|
||||
* end-of-generation cut over the tokens that walk emits. */
|
||||
const int32_t* tp = a.parent_off >= 0 ? adv_i32(a, a.parent_off) + rtok : nullptr;
|
||||
if (tp && aux > 0 && tp[0] == -1) {
|
||||
const int32_t* d = tok + rtok; /* node j's token is d[j], 1 <= j <= aux */
|
||||
const int32_t a0 = rtok - k; /* parents count rows from the sequence's first */
|
||||
int32_t cur = 0, acc = 0;
|
||||
for (;;) {
|
||||
int32_t nxt = -1;
|
||||
for (int32_t j = cur + 1; j <= aux; ++j)
|
||||
if (tp[j] - a0 == cur && d[j] == y[cur]) { nxt = j; break; }
|
||||
if (nxt < 0) break;
|
||||
S.path[acc++] = nxt;
|
||||
cur = nxt;
|
||||
}
|
||||
for (int32_t t = 0; t <= acc; ++t)
|
||||
if (adv_is_eog(a, y[t == 0 ? 0 : S.path[t - 1]])) { acc = t; break; }
|
||||
const int32_t head = ctx[i] + (rtok - k) + acc;
|
||||
S.acc = acc;
|
||||
S.head = head;
|
||||
S.ctx = head + 1;
|
||||
S.n_acc = acc + 1;
|
||||
S.tok[0] = y[acc == 0 ? 0 : S.path[acc - 1]];
|
||||
S.npath = acc;
|
||||
return;
|
||||
}
|
||||
/* accept_greedy's rule, then collect_step's end-of-generation cut: a draft is accepted
|
||||
* while it equals the target's pick at its position, and the run stops at an
|
||||
* end-of-generation token, not after it. */
|
||||
const int32_t* y = a.src + rout;
|
||||
const int32_t* d = tok + rtok + 1;
|
||||
int32_t acc = 0;
|
||||
while (acc < aux && d[acc] == y[acc]) ++acc;
|
||||
@@ -123,16 +170,64 @@ 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];
|
||||
S.npath = 0;
|
||||
return;
|
||||
}
|
||||
case ADV_TRUNK: {
|
||||
const int32_t base = S.ctx;
|
||||
if (a.parent_off >= 0) {
|
||||
int32_t* par = adv_i32(a, a.parent_off);
|
||||
/* A row verifying fewer nodes than the drafter proposed (a window cut it) verifies
|
||||
* their prefix, which is a tree too: every parent precedes its child. */
|
||||
if (n > 1 && S.ntree >= n - 1) {
|
||||
/* A tree: node j stores its K and V at base + j (siblings share a depth, so the
|
||||
* position cannot address them) and rotates at base + its depth, the position the
|
||||
* token would have if its path were committed. Attention reads spec_parent to see
|
||||
* only a row's own ancestors inside the block. */
|
||||
int32_t dep[1 + RAD_SCHED_MAX_SPEC], at[1 + RAD_SCHED_MAX_SPEC];
|
||||
for (int32_t j = 0; j < n; ++j) {
|
||||
const int32_t p = j == 0 ? -1 : adv_parent(S, j);
|
||||
dep[j] = j == 0 ? 0 : dep[p] + 1;
|
||||
tok[k + j] = S.tok[j];
|
||||
par[k + j] = p;
|
||||
adv_pos(a, pos, k + j, base + dep[j]);
|
||||
at[j] = base + j;
|
||||
}
|
||||
ctx[i] = base;
|
||||
adv_i32(a, a.acc_off)[i] = S.n_acc;
|
||||
adv_groups(a, i, k, base, n, -1, at);
|
||||
return;
|
||||
}
|
||||
for (int32_t j = 0; j < n; ++j) par[k + j] = -2;
|
||||
}
|
||||
for (int32_t j = 0; j < n; ++j) { tok[k + j] = S.tok[j]; adv_pos(a, pos, k + j, base + j); }
|
||||
ctx[i] = base;
|
||||
adv_i32(a, a.acc_off)[i] = S.n_acc;
|
||||
adv_groups(a, i, k, base, n);
|
||||
return;
|
||||
}
|
||||
case ADV_CTXTREE: {
|
||||
/* The drafter's context pass over a tree verify's rows (one per node, in node order, as
|
||||
* the trunk tapped them), a card row only where the host marked the step's entry as one.
|
||||
* Only the accepted path is context: path node t's row writes at the anchor + t + 1,
|
||||
* rotated there, which is where its token now sits, and every rejected node's row stores
|
||||
* nowhere. Run after ADV_ACCEPT, which wrote the path, and before ADV_BTAKE. A chain
|
||||
* verify's path is its first `acc` rows (npath 0). */
|
||||
const int32_t base = S.head - S.acc;
|
||||
int32_t at[1 + RAD_SCHED_MAX_SPEC];
|
||||
at[0] = base;
|
||||
adv_pos(a, pos, k, base);
|
||||
for (int32_t j = 1; j < n; ++j) { at[j] = -1; adv_pos(a, pos, k + j, base); }
|
||||
for (int32_t t = 0; t < S.acc; ++t) {
|
||||
const int32_t r = t < S.npath ? S.path[t] : t + 1;
|
||||
if (r < 1 || r >= n) continue;
|
||||
at[r] = base + t + 1;
|
||||
adv_pos(a, pos, k + r, base + t + 1);
|
||||
}
|
||||
ctx[i] = base;
|
||||
adv_groups(a, i, k, base, n, -1, at);
|
||||
return;
|
||||
}
|
||||
case ADV_HIST: {
|
||||
if (a.shared_kv) {
|
||||
/* A head that reads the trunk's cache and keeps none (rad_drafter_shared_kv). With no
|
||||
@@ -205,13 +300,76 @@ RAD_ADV_FN void adv_row(const AdvanceArgs& a, int i) {
|
||||
return;
|
||||
}
|
||||
case ADV_BTAKE:
|
||||
/* Row i is the query pass's i-th block, which is the i-th drafting sequence. */
|
||||
/* Row i is the query pass's i-th block, which is the i-th drafting sequence. A tree
|
||||
* drafter's parents come with the tokens, at the same pitch. */
|
||||
for (int32_t j = 0; j < a.round; ++j)
|
||||
S.tok[1 + j] = a.src[(int64_t)i * a.src_pitch + j];
|
||||
if (a.par) {
|
||||
for (int32_t j = 0; j < a.round; ++j) S.par[j] = a.par[(int64_t)i * a.src_pitch + j];
|
||||
S.ntree = a.round;
|
||||
} else {
|
||||
S.ntree = 0;
|
||||
}
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* ADV_COMPACT for one (batch row, pool, layer, head): the moves the row's accepted path asks
|
||||
* for, `c0` and every `cstep`-th 16-byte chunk of each K|V row. Node path[t] stored at
|
||||
* base + path[t] and belongs at base + t + 1. path[] increases (a parent's index is below its
|
||||
* child's) and path[t] >= t + 1, so in t order no move overwrites a node a later move still reads:
|
||||
* a destination base + t + 1 is either the node's own place or a place a node already moved out
|
||||
* of. Each caller keeps one chunk set across every t, so its reads and writes stay in order. */
|
||||
RAD_ADV_FN void adv_compact(const AdvanceArgs& a, int i, int p, int l, int h, int c0, int cstep) {
|
||||
/* Only a row that sampled in this step: ADV_ACCEPT just wrote its slot. Any other row's slot
|
||||
* may hold a path from an earlier request that used the same slot. */
|
||||
const int32_t* rows = adv_i32(a, a.row_off);
|
||||
if (rows[2 * a.row_pitch + i] < 0) return;
|
||||
const StepSlot& S = a.st[adv_i32(a, a.sid_off)[i]];
|
||||
const int32_t np = S.npath < S.acc ? S.npath : S.acc;
|
||||
if (np <= 0) return;
|
||||
const AdvPool& P = a.pool[p];
|
||||
if (!P.base || l >= P.n_layers || h >= P.n_head) return;
|
||||
const AdvGroup& e = reinterpret_cast<const AdvGroup*>(a.slab + a.grp_off)[P.grp];
|
||||
if (!e.paged) return;
|
||||
const int32_t base = S.head - S.acc;
|
||||
const int32_t bs = e.block_size;
|
||||
char* lay = P.base + (int64_t)l * P.layer_stride;
|
||||
const int32_t chunks = P.row_bytes / 16;
|
||||
for (int32_t t = 0; t < np; ++t) {
|
||||
const int32_t src = base + S.path[t], dst = base + t + 1;
|
||||
if (src == dst) continue;
|
||||
const int32_t ss = adv_slot(a, e, i, src), ds = adv_slot(a, e, i, dst);
|
||||
if (ss < 0 || ds < 0) continue;
|
||||
const uint32_t* from = reinterpret_cast<const uint32_t*>(
|
||||
lay + (((int64_t)(ss / bs) * P.n_head + h) * bs + ss % bs) * P.row_bytes);
|
||||
uint32_t* to = reinterpret_cast<uint32_t*>(
|
||||
lay + (((int64_t)(ds / bs) * P.n_head + h) * bs + ds % bs) * P.row_bytes);
|
||||
for (int32_t c = c0; c < chunks; c += cstep) {
|
||||
const uint32_t v0 = from[4 * c], v1 = from[4 * c + 1], v2 = from[4 * c + 2],
|
||||
v3 = from[4 * c + 3];
|
||||
to[4 * c] = v0; to[4 * c + 1] = v1; to[4 * c + 2] = v2; to[4 * c + 3] = v3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The (pool, layer, head) of ADV_COMPACT's work item `w`, counting every pool's layers x heads in
|
||||
* order; false past the last. */
|
||||
RAD_ADV_FN bool adv_compact_item(const AdvanceArgs& a, int w, int* p, int* l, int* h) {
|
||||
for (int q = 0; q < a.n_pool; ++q) {
|
||||
const int n = a.pool[q].n_layers * a.pool[q].n_head;
|
||||
if (w < n) { *p = q; *l = w / a.pool[q].n_head; *h = w % a.pool[q].n_head; return true; }
|
||||
w -= n;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
RAD_ADV_FN int adv_compact_items(const AdvanceArgs& a) {
|
||||
int n = 0;
|
||||
for (int q = 0; q < a.n_pool; ++q) n += a.pool[q].n_layers * a.pool[q].n_head;
|
||||
return n;
|
||||
}
|
||||
|
||||
} /* namespace rad */
|
||||
+29
-10
@@ -862,14 +862,6 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
(long long)max_seqs_, (long long)max_tok_);
|
||||
return nullptr;
|
||||
}
|
||||
if (plan.spec_is_tree) {
|
||||
/* spec_parent is in the ABI and allocated, but no drafter emits a tree, so tree parents
|
||||
* and positions are not written. Filling in the linear-chain answer would verify a tree
|
||||
* against the wrong causal mask. */
|
||||
RAD_ERR("tree-layout speculation was requested but is not implemented in this build");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Set& s = set_;
|
||||
const int64_t n_seq = (int64_t)plan.e.size();
|
||||
|
||||
@@ -957,6 +949,29 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
s.h_tok[k + j] = token_at(e, (int64_t)e.ctx_len + j + shift);
|
||||
s.h_pos[k + j] = e.ctx_len + j;
|
||||
}
|
||||
/* A tree verify (RadBatch::spec_parent): every verify block of a tree step is staged as
|
||||
* a tree, a chain proposal (prompt lookup) as the tree whose node j hangs off j - 1, so
|
||||
* the card's acceptance and the host's agree on every row. Node j stores its K and V at
|
||||
* its row's position (the slots below are unchanged) and rotates at the anchor + its
|
||||
* depth. A parent is named by its row within the sequence's rows (from cu_seqlens), the
|
||||
* index an attention kernel has. A card row is restaged by ADV_TRUNK from its StepSlot. */
|
||||
if (plan.spec_is_tree) {
|
||||
for (int32_t j = 0; j < e.n_tokens; ++j) s.h_parent[k + j] = -2;
|
||||
if (e.produces_token && !e.is_prefill && e.n_spec > 0 &&
|
||||
e.n_spec < e.n_tokens && e.n_spec <= RAD_SCHED_MAX_SPEC) {
|
||||
const int32_t a0 = e.n_tokens - 1 - e.n_spec; /* the anchor's row */
|
||||
int32_t dep[1 + RAD_SCHED_MAX_SPEC];
|
||||
dep[0] = 0;
|
||||
s.h_parent[k + a0] = -1;
|
||||
for (int32_t j = 1; j <= e.n_spec; ++j) {
|
||||
int32_t p = e.draft_parent ? e.draft_parent[j - 1] : j - 1;
|
||||
if (p < 0 || p >= j) p = j - 1;
|
||||
dep[j] = dep[p] + 1;
|
||||
s.h_parent[k + a0 + j] = a0 + p;
|
||||
s.h_pos[k + a0 + j] = e.ctx_len + a0 + dep[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Every row of a sequence runs with its request's adapter (RadBatch::lora_slot), fixed at
|
||||
* admission; a placeholder row with no request is a base row. */
|
||||
if (lora_on_) {
|
||||
@@ -973,7 +988,8 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
(e.req && e.req->media && !e.req->media->rope.empty()) ? &e.req->media->rope : nullptr;
|
||||
for (int32_t j = 0; j < e.n_tokens; ++j) {
|
||||
int32_t v[3];
|
||||
const int64_t p = (int64_t)e.ctx_len + j;
|
||||
/* h_pos, not ctx_len + j: a tree verify's rows rotate at their depth. */
|
||||
const int64_t p = (int64_t)s.h_pos[k + j];
|
||||
if (rl) rl->at(p, v);
|
||||
else v[0] = v[1] = v[2] = (int32_t)p;
|
||||
s.h_rope[k + j] = v[0];
|
||||
@@ -1166,7 +1182,8 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
* without drafts may follow one that had drafts, and the linear kernels need its accepted
|
||||
* count instead of their absent-operand default of 1. */
|
||||
B.num_accepted = cfg_.n_spec > 0 ? on_rank(base, b0, s.d_acc) : nullptr;
|
||||
B.spec_parent = nullptr; /* a linear chain; the tree case is refused above */
|
||||
/* 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;
|
||||
B.rope_pos = mm_on_ ? on_rank(base, b0, s.d_rope) : nullptr;
|
||||
B.rope_mixed = rope_mixed;
|
||||
B.n_mm_rows = n_mm;
|
||||
@@ -1205,6 +1222,7 @@ const RadBatch* BatchBuilder::build(const StepPlan& plan, const IKVManager& kv,
|
||||
++ring_.live;
|
||||
last_n_seq_ = n_seq;
|
||||
last_n_tok_ = n_tok;
|
||||
last_tree_ = plan.spec_is_tree;
|
||||
ring_.head = off + used;
|
||||
out_last_ = out_next_;
|
||||
out_next_ = (out_next_ + 1) % kOut;
|
||||
@@ -1236,6 +1254,7 @@ AdvanceArgs BatchBuilder::advance_args(int rank) const {
|
||||
a.cu_off = off(s.d_cu);
|
||||
a.q_off = off(s.d_q);
|
||||
a.row_off = off(s.d_rows);
|
||||
a.parent_off = last_tree_ ? off(s.d_parent) : -1;
|
||||
a.row_pitch = (int32_t)max_seqs_;
|
||||
a.grp_off = off(s.d_grp);
|
||||
if (mm_on_) {
|
||||
|
||||
@@ -41,6 +41,10 @@ struct StepEntry {
|
||||
int32_t ckpt_restore = -1;
|
||||
const int32_t* draft = nullptr; /* the drafter's proposal, appended after the committed tail */
|
||||
int32_t n_draft = 0;
|
||||
/* A tree drafter's proposal (rad_drafter_tree): draft_parent[j] is the parent of draft[j] as a
|
||||
* node index (0 the anchor, j + 1 draft[j]). Null for a chain. Read only on a tree step
|
||||
* (StepPlan::spec_is_tree), where a null one is staged as the chain. */
|
||||
const int32_t* draft_parent = nullptr;
|
||||
/* First logits row, written into `out_ids`, that this entry reads, or -1 for the default
|
||||
* rule. The MTP history pass uses it to gather the 1 + n_spec trunk rows of a verifying
|
||||
* sequence; the DFlash2 query pass uses it to name the mask rows of its own block. Which
|
||||
@@ -315,6 +319,7 @@ private:
|
||||
int64_t pay_words_ = 0; /* payload build_groups wrote, in int32 words */
|
||||
void forget_tables();
|
||||
int64_t last_n_seq_ = 0;
|
||||
bool last_tree_ = false; /* the last build staged spec_parent (advance_args' parent_off) */
|
||||
|
||||
int64_t derived_bytes_ = 0;
|
||||
std::vector<Derived> derived_;
|
||||
|
||||
+34
-20
@@ -38,6 +38,30 @@ int64_t prefill_shared_tok(const Config& cfg) {
|
||||
return std::max(std::min(cfg.max_tok, I), cfg.max_tok - (cfg.prefill_span - 1) * I);
|
||||
}
|
||||
|
||||
/* What a prefix hit restores beside the cached blocks: linear state, or a trunk's sliding window.
|
||||
* Only the trunk's window makes a model take window snapshots; a block drafter's rides in them
|
||||
* where they exist (KVManager::set_drafter_window_snapshot) and is recomputed by draft refill
|
||||
* where they do not. A RAD_KV_RING group has no snapshot at all
|
||||
* (KVManager::declare_runtime_window): its window is each sequence's own prompt length, which no
|
||||
* slot could describe, so it is sized for the context plus a ring and is never checkpointed. */
|
||||
static void restored_state(const Program& prog, bool* linear, bool* window) {
|
||||
*linear = *window = false;
|
||||
for (const KVGroupInfo& kg : prog.kv_groups) {
|
||||
if (kg.decl.kind != RAD_KV_FULL && kg.decl.kind != RAD_KV_WINDOW &&
|
||||
kg.decl.kind != RAD_KV_RING)
|
||||
*linear = true;
|
||||
else if (kg.decl.kind == RAD_KV_WINDOW && kg.block_size > 0 && !kg.layers.empty() &&
|
||||
!kg.drafter)
|
||||
*window = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool window_snapshots(const Program& prog, const Config& cfg) {
|
||||
bool linear = false, window = false;
|
||||
restored_state(prog, &linear, &window);
|
||||
return !linear && window && cfg.prefix_cache && cfg.checkpoint_interval > 0;
|
||||
}
|
||||
|
||||
int chunk_geometry_resolve(const Program& prog, const Config& cfg, ChunkGeometry* out) {
|
||||
if (!out) return RAD_E_INVAL;
|
||||
ChunkGeometry g;
|
||||
@@ -46,22 +70,12 @@ int chunk_geometry_resolve(const Program& prog, const Config& cfg, ChunkGeometry
|
||||
/* lcm across every paged group. libr4d uses 16 for all of them, but a sliding-window group
|
||||
* served by a different kernel may differ (§7.2). */
|
||||
bool has_linear = false, has_window = false;
|
||||
restored_state(prog, &has_linear, &has_window);
|
||||
for (const KVGroupInfo& kg : prog.kv_groups) {
|
||||
if (kg.decl.kind == RAD_KV_FULL || kg.decl.kind == RAD_KV_WINDOW ||
|
||||
kg.decl.kind == RAD_KV_RING) {
|
||||
if (kg.block_size > 0) {
|
||||
g.attn_block = lcm64(g.attn_block, kg.block_size);
|
||||
note(g.why, "attn_block", kg.block_size, kg.name.c_str());
|
||||
/* A drafter's window is recomputed by draft refill; only the trunk's needs a
|
||||
* snapshot for a prefix hit to resume. A RAD_KV_RING group has no snapshot at all
|
||||
* (KVManager::declare_runtime_window): its window is each sequence's own prompt
|
||||
* length, which no slot could describe, so it is sized for the context plus a ring
|
||||
* and is never checkpointed. */
|
||||
if (kg.decl.kind == RAD_KV_WINDOW && !kg.layers.empty() && !kg.drafter)
|
||||
has_window = true;
|
||||
}
|
||||
} else {
|
||||
has_linear = true;
|
||||
if ((kg.decl.kind == RAD_KV_FULL || kg.decl.kind == RAD_KV_WINDOW ||
|
||||
kg.decl.kind == RAD_KV_RING) && kg.block_size > 0) {
|
||||
g.attn_block = lcm64(g.attn_block, kg.block_size);
|
||||
note(g.why, "attn_block", kg.block_size, kg.name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,11 +166,11 @@ int chunk_geometry_resolve(const Program& prog, const Config& cfg, ChunkGeometry
|
||||
}
|
||||
|
||||
/* The resume grid (--prefix-resume exact): where an idle server's prefill chunks start. A
|
||||
* prefill alone in its step takes the budget, rounded down to the quantum, and stops at every
|
||||
* interval boundary it reaches where chunks split at the interval (linear state, or periodic
|
||||
* window snapshots); a span carries h intervals from the second one on. An interval past the
|
||||
* budget must then be a multiple of the budget's chunk, or the chunk after a checkpoint would
|
||||
* start off the grid every cold run cuts: rounded up, as the quantum rounds it, since a longer
|
||||
* prefill alone in its step takes the budget, rounded down to the quantum. Where chunks split
|
||||
* at the interval (linear state, or periodic window snapshots) it stops at every interval
|
||||
* boundary it reaches, and a span carries h intervals from the second one on. An interval past
|
||||
* the budget must be a multiple of the budget's chunk, or the chunk after a checkpoint would
|
||||
* start off the cold run's grid; it is rounded up, as the quantum rounds it, since a longer
|
||||
* interval costs only retention. */
|
||||
const int64_t I0 = g.checkpoint_interval;
|
||||
const bool splits = I0 > 0 && (!g.window_ckpt || g.window_periodic);
|
||||
|
||||
+13
-8
@@ -61,14 +61,14 @@ struct ChunkGeometry {
|
||||
bool window_periodic = false;
|
||||
|
||||
/* --prefix-resume exact (Config::prefix_exact): a prefix hit resumes only where a cold prefill
|
||||
* of the same prompt starts a chunk, so the tokens a hit recomputes are cut into the chunks a
|
||||
* cold run cuts them into. A kernel may round a row differently at another chunk length (a
|
||||
* split-K count chosen from M, a small-M path); computed in the same chunks, the hit's output
|
||||
* is the cold run's, bit for bit, on an idle server. The grid is where an idle server's prefill
|
||||
* chunks start: 0, then grid_origin + k * grid. `grid` is the checkpoint interval where chunks
|
||||
* split at it and it fits the budget, times the span from the second interval on (origin = the
|
||||
* interval), and otherwise --max-num-batched-tokens rounded down to the quantum (the interval
|
||||
* is then rounded up to a multiple of it). Zero when not exact. */
|
||||
* of the same prompt starts a chunk, so the tokens it recomputes are cut into the cold run's
|
||||
* chunks. A kernel may round a row differently at another chunk length (a split-K count chosen
|
||||
* from M, a small-M path); in the same chunks, on an idle server, the hit's output is the cold
|
||||
* run's bit for bit. The grid is where an idle server's prefill chunks start: 0, then
|
||||
* grid_origin + k * grid. Where chunks split at the interval and it fits the budget, `grid` is
|
||||
* the interval times the span the budget holds, from grid_origin = the interval when that span
|
||||
* is over 1. Otherwise `grid` is --max-num-batched-tokens rounded down to the quantum, and the
|
||||
* interval is rounded up to a multiple of it. Zero when not exact. */
|
||||
bool exact = false;
|
||||
int64_t grid = 0;
|
||||
int64_t grid_origin = 0;
|
||||
@@ -91,6 +91,11 @@ struct ChunkGeometry {
|
||||
* (RadBuildCtx::max_mixed_tok) and the scheduler plans by it, so the two agree. */
|
||||
int64_t prefill_shared_tok(const Config& cfg);
|
||||
|
||||
/* ChunkGeometry::window_ckpt from the program and the configuration alone, without resolving or
|
||||
* reporting the geometry: a trunk's sliding window, no linear state, a prefix cache and an
|
||||
* interval. Bring-up asks it before the geometry is resolved (Engine::drafter_window_snap). */
|
||||
bool window_snapshots(const Program& prog, const Config& cfg);
|
||||
|
||||
/* Resolve the geometry from the declared program and the operator's budgets.
|
||||
*
|
||||
* Returns RAD_E_INVAL when cfg.max_tok is too small (the required number is in
|
||||
|
||||
@@ -172,10 +172,14 @@ struct IPrefixCache {
|
||||
|
||||
/* Longest cached prefix, plus the checkpoint covering the linear state for a prefix of it.
|
||||
* `blocks_out` receives block ids per cached group, in cached_groups() order, for
|
||||
* IKVManager::adopt: n_attn_tokens over the group's own block size of them. `cap`, when not null, ends the hit early (HitCap, core/mem/prefix.h). */
|
||||
* IKVManager::adopt: n_attn_tokens over the group's own block size of them. `cap`, when not
|
||||
* null, ends the hit early (HitCap, core/mem/prefix.h). */
|
||||
virtual CacheHit lookup(const Request& r, std::vector<std::vector<int32_t>>* blocks_out,
|
||||
const HitCap* cap) const = 0;
|
||||
virtual const std::vector<int32_t>& cached_groups() const = 0;
|
||||
/* The drafter's refill window (Scheduler::init): retention keeps a snapshot that deep below a
|
||||
* session's tip, so a refill-capped hit has one to end on (PrefixCache::set_drafter_floor). */
|
||||
virtual void set_drafter_floor(int64_t) {}
|
||||
|
||||
/* Publish what this sequence computed so a later request sharing the prefix can adopt it.
|
||||
* `blocks[i]` is the block table of cached_groups()[i]; `n_tokens` is how many tokens are
|
||||
@@ -472,6 +476,7 @@ struct PCBinding final : IPrefixCache {
|
||||
}
|
||||
void release(const Request& r) override { m->release(r.id); }
|
||||
const std::vector<int32_t>& cached_groups() const override { return m->cached_groups(); }
|
||||
void set_drafter_floor(int64_t tokens) override { m->set_drafter_floor(tokens); }
|
||||
|
||||
/* Indexes prompt ++ output: the next turn sends the reply back in its prompt, so indexing the
|
||||
* prompt alone would stop hitting at the first assistant token. */
|
||||
|
||||
+101
-43
@@ -146,7 +146,10 @@ int Scheduler::init(Program& prog, const Config& cfg, IKVManager* kv, IPrefixCac
|
||||
RAD_INFO("draft refill: a prefix hit ends %lld tokens before the prompt's end, so the "
|
||||
"drafter's window is recomputed", (long long)draft_refill_);
|
||||
}
|
||||
if (pc) pc->set_drafter_floor(draft_refill_);
|
||||
|
||||
/* A tree drafter (rad_drafter_tree): every trunk step verifies its proposals as trees. */
|
||||
tree_ = cfg.n_spec > 0 && prog.drafter.kind == RAD_DRAFT_BLOCK && prog.drafter_tree;
|
||||
serial_shared_ = cfg.n_spec > 0 && prog.drafter.kind == RAD_DRAFT_SERIAL &&
|
||||
prog.drafter_shared_kv;
|
||||
serial_rot_shift_ = serial_shared_ ? prog.drafter_pos_offset : 0;
|
||||
@@ -363,12 +366,18 @@ bool Scheduler::committed_seq(uint64_t seq, uint64_t* n_out, bool* live) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
int Scheduler::set_draft(uint64_t id, const int32_t* tokens, int n) {
|
||||
int Scheduler::set_draft(uint64_t id, const int32_t* tokens, int n, const int32_t* parents) {
|
||||
std::lock_guard<std::mutex> lk(mu_);
|
||||
auto it = by_id_.find(id);
|
||||
if (it == by_id_.end()) return RAD_E_NOTFOUND;
|
||||
SchedReq& s = *reqs_[(size_t)it->second];
|
||||
if (n < 0) return RAD_E_INVAL;
|
||||
/* A tree's parents travel with its tokens; a prefix of a tree is a tree (every parent
|
||||
* precedes its child), so the caps below keep them valid. */
|
||||
s.draft_tree = parents != nullptr;
|
||||
if (parents)
|
||||
for (int i = 0; i < n && i < RAD_SCHED_MAX_SPEC; ++i) s.draft_par[i] = parents[i];
|
||||
s.req->draft_parent = parents ? s.draft_par : nullptr;
|
||||
|
||||
/* The step issued ahead already verifies these: it was planned with the drafter's count and
|
||||
* the card has the tokens. The host copy is what its commit emits accepted tokens from, so it
|
||||
@@ -479,9 +488,9 @@ void Scheduler::trim_prefix_cache() {
|
||||
if (!pc_ || !cfg_.prefix_cache) return;
|
||||
const std::vector<int32_t>& cg = pc_->cached_groups();
|
||||
if (cg.empty()) return;
|
||||
/* An entry covers the lcm of the cached groups' blocks and holds that over a group's block of
|
||||
* its blocks (PrefixCache::blocks_per_entry); the trim asks for entries, as many as the group
|
||||
* furthest short needs. */
|
||||
/* An entry covers the lcm of the cached groups' block sizes and holds lcm / B blocks of a
|
||||
* group with B-token blocks (PrefixCache::blocks_per_entry). The trim asks for entries, as
|
||||
* many as the group furthest short needs. */
|
||||
int64_t entry = 0;
|
||||
for (int32_t g : cg) {
|
||||
const int64_t bs = kvgeom_.g[(size_t)g].block_size;
|
||||
@@ -874,10 +883,10 @@ int64_t Scheduler::plan_chunk(int64_t n_computed, int64_t n_target, int64_t budg
|
||||
if (geo_.checkpoints() && geo_.exact) {
|
||||
/* --prefix-resume exact: checkpoints only where an idle cold prefill of this prompt starts
|
||||
* a chunk (ChunkGeometry::grid), so a hit that resumes at one recomputes the cold run's
|
||||
* own chunks. Splits as below at the interval and a span's end; the tail snapshot is at
|
||||
* the start of the prompt's last chunk (tail_checkpoint), a boundary an idle chunk already
|
||||
* ends on, so it costs a copy and no step. A step that shares the budget (another
|
||||
* request, decode rows) may straddle it, and is split there. */
|
||||
* own chunks. Splits at the interval and a span's end as nearest does (below). The tail
|
||||
* snapshot is at the start of the prompt's last chunk (tail_checkpoint), a boundary an
|
||||
* idle chunk already ends on, so it costs a copy and no step. A step that shares the
|
||||
* budget (another request, decode rows) may straddle it, and is split there. */
|
||||
const int64_t I = geo_.checkpoint_interval;
|
||||
const bool periodic = !geo_.window_ckpt || geo_.window_periodic;
|
||||
const int64_t next = periodic ? ((n_computed / I) + 1) * I : INT64_MAX;
|
||||
@@ -895,28 +904,27 @@ int64_t Scheduler::plan_chunk(int64_t n_computed, int64_t n_target, int64_t budg
|
||||
} else if (periodic && (n_computed + want) % I == 0 && geo_.on_grid(n_computed + want)) {
|
||||
if (checkpoint_pos) *checkpoint_pos = n_computed + want;
|
||||
}
|
||||
/* A request's own checkpoint (Request::checkpoint_at) as below, wherever it falls: the
|
||||
* head the request shares with others resumes there by design. */
|
||||
/* A request's own checkpoint (Request::checkpoint_at), wherever it falls, as nearest
|
||||
* takes it: the head the request shares with others resumes there by design. */
|
||||
const int64_t keep = keep_at / geo_.quantum * geo_.quantum;
|
||||
if (keep > n_computed && keep <= n_computed + want && keep <= n_target) {
|
||||
want = keep - n_computed;
|
||||
if (checkpoint_pos) *checkpoint_pos = keep;
|
||||
}
|
||||
} else if (geo_.checkpoints()) {
|
||||
/* --prefix-resume nearest, or no prefix cache: interval checkpoints, and a tail snapshot
|
||||
* as deep in the prompt as the rules below allow. */
|
||||
const int64_t I = geo_.checkpoint_interval;
|
||||
int64_t next = ((n_computed / I) + 1) * I; /* strictly after n_computed */
|
||||
if (geo_.window_ckpt && !geo_.window_periodic) {
|
||||
/* An explicit tail-only policy should not pay for intermediate
|
||||
* window copies or chunk splits just to retire those snapshots. */
|
||||
next = INT64_MAX;
|
||||
} else if (geo_.window_ckpt) {
|
||||
/* A tail-only window snapshot is unreachable after a prompt edit.
|
||||
* Keep interval checkpoints too; the ordinary retention policy bounds
|
||||
* their storage. Preserve the tail before the template's changed suffix,
|
||||
* even when the prompt ends exactly on an interval boundary. */
|
||||
const int64_t tail = tail_checkpoint(n_target);
|
||||
if (tail > n_computed) next = std::min(next, tail);
|
||||
}
|
||||
/* Otherwise a window keeps interval snapshots too (a tail-only one is unreachable after a
|
||||
* prompt edit; the ordinary retention policy bounds their storage), each splitting the
|
||||
* prefill at its boundary. The tail's is taken inside the chunk that carries it
|
||||
* (wtail below), so it splits nothing. */
|
||||
/* A span (ChunkGeometry::span) starts only on an interval boundary past the first
|
||||
* interval, and its chunk is the span's intervals in a row, each the piece a span of 1
|
||||
* makes a chunk of its own. Not from a prompt's start: the first interval may be served on
|
||||
@@ -930,16 +938,26 @@ int64_t Scheduler::plan_chunk(int64_t n_computed, int64_t n_target, int64_t budg
|
||||
want = far - n_computed;
|
||||
else if (n_computed + want > next && n_computed + want < n_target)
|
||||
want = (n_computed + want) / I * I - n_computed;
|
||||
if ((geo_.window_ckpt && n_computed + want == next) ||
|
||||
(!geo_.window_ckpt && (n_computed + want) % I == 0)) {
|
||||
/* A window snapshot at the prompt's tail, a block short of its end (the next turn's
|
||||
* rendering may differ there), even where the prompt ends on an interval boundary. The
|
||||
* window's rows behind it are still held when the chunk ends (a window slides from a
|
||||
* step's first query, KVManager::recycle_window), so it is taken inside whichever chunk
|
||||
* carries that position, and the prompt is not split there: no extra step. It wins over
|
||||
* an interval snapshot at the same chunk's end, which lies past it. */
|
||||
const int64_t wtail = geo_.window_ckpt ? tail_checkpoint(n_target) : -1;
|
||||
if (wtail > n_computed && wtail <= n_computed + want) {
|
||||
if (checkpoint_pos) *checkpoint_pos = wtail;
|
||||
} else if ((geo_.window_ckpt && n_computed + want == next) ||
|
||||
(!geo_.window_ckpt && (n_computed + want) % I == 0)) {
|
||||
if (checkpoint_pos) *checkpoint_pos = n_computed + want;
|
||||
} else if (n_computed + want == n_target) {
|
||||
/* Also one at the prompt's tail. The next turn resumes from the deepest snapshot
|
||||
* under its hit, which on the interval alone can be nearly an interval short of this
|
||||
* prompt's end, re-prefilled every turn. The final chunk splits at the last quantum
|
||||
* boundary, and the remainder (under a quantum) runs as the next step's chunk
|
||||
* (tail_checkpoint decides when that is worth it). */
|
||||
const int64_t tail = tail_checkpoint(n_target);
|
||||
* prompt's end, re-prefilled every turn. Linear state is what the chunk's last token
|
||||
* leaves, so the final chunk splits at the last quantum boundary and the remainder
|
||||
* (under a quantum) runs as the next step's chunk (tail_checkpoint decides when that
|
||||
* is worth it). A window's tail snapshot is taken above, inside its chunk. */
|
||||
const int64_t tail = geo_.window_ckpt ? -1 : tail_checkpoint(n_target);
|
||||
if (tail > n_computed) {
|
||||
want = tail - n_computed;
|
||||
if (checkpoint_pos) *checkpoint_pos = tail;
|
||||
@@ -974,36 +992,46 @@ int64_t Scheduler::plan_chunk(int64_t n_computed, int64_t n_target, int64_t budg
|
||||
}
|
||||
if (aligned < end) {
|
||||
want = aligned - n_computed;
|
||||
if (checkpoint_pos) *checkpoint_pos = -1;
|
||||
/* A checkpoint at the old end goes with it (the chunk that reaches it takes it); a
|
||||
* window's tail snapshot the trimmed chunk still carries stays, or the next chunk
|
||||
* would start past it and the prompt take none. */
|
||||
if (checkpoint_pos && *checkpoint_pos > aligned) *checkpoint_pos = -1;
|
||||
}
|
||||
}
|
||||
return want;
|
||||
}
|
||||
|
||||
/* The tail checkpoint of a `target`-token prompt, or -1: its last quantum boundary, only past the
|
||||
* first interval (a shorter prompt is cheap to redo) and only where it gains at least a quarter
|
||||
* interval over the interval checkpoint below it, which pays for the extra step. */
|
||||
/* The tail checkpoint of a `target`-token prompt, or -1. Under --prefix-resume exact, where its
|
||||
* last chunk starts (below). Under nearest, its last quantum boundary, only past the first
|
||||
* interval (a shorter prompt is cheap to redo) and only where it gains at least a quarter
|
||||
* interval over the interval checkpoint below it, which pays for the extra step; a window
|
||||
* snapshot follows its own rule (below). */
|
||||
int64_t Scheduler::tail_checkpoint(int64_t target) const {
|
||||
const int64_t I = geo_.checkpoint_interval, Q = geo_.quantum;
|
||||
if (I <= 0 || Q <= 0) return -1;
|
||||
if (geo_.exact) {
|
||||
/* --prefix-resume exact: where the prompt's last chunk starts on the resume grid, so an
|
||||
* exact repeat re-prefills that chunk as the cold run did, and an appended turn that chunk
|
||||
* and what it added. A window snapshot keeps its margin below (next comment): the grid
|
||||
* point under the end less a block. Past the first interval, as below. */
|
||||
* and what it added. A window snapshot keeps nearest's margin (next comment): the grid
|
||||
* point under the end less a block. From the first interval on, as nearest's linear-state
|
||||
* rule (a window's lower floor, kWindowSnapshotMin, is nearest's only). */
|
||||
const int64_t margin = geo_.window_ckpt ? std::max<int64_t>(Q, 16) : 1;
|
||||
const int64_t t = geo_.grid_floor(target - margin);
|
||||
if (geo_.window_ckpt) return t >= I ? t : -1;
|
||||
return t > I ? t : -1;
|
||||
}
|
||||
const int64_t tail = target / Q * Q;
|
||||
/* A window snapshot is taken at the tail of any prompt of an interval or more, a block short
|
||||
* of the end: the next turn re-renders the last few tokens (the generation prompt is replaced
|
||||
* by the reply), and a snapshot past where the two renderings diverge is unreachable. Prompts
|
||||
* that left fewer than ~8 tokens in their last block always missed. */
|
||||
/* A window snapshot is taken at the tail of a prompt, a block short of its end: the next turn
|
||||
* re-renders the last few tokens (the generation prompt is replaced by the reply), and a
|
||||
* snapshot past where the two renderings diverge is unreachable. Prompts that left fewer than
|
||||
* ~8 tokens in their last block always missed. It is taken where that position is at least
|
||||
* kWindowSnapshotMin, or an interval where that is lower: from a 528-token prompt at a quantum
|
||||
* of 16. The snapshot is the only way a hit resumes on a model whose windowed layers the cache
|
||||
* does not index, so the floor is low: copying the window out and back costs a few
|
||||
* milliseconds, recomputing the prompt a prefill. */
|
||||
if (geo_.window_ckpt) {
|
||||
const int64_t t = (target - std::max<int64_t>(Q, 16)) / Q * Q;
|
||||
return t >= I ? t : -1;
|
||||
return t >= std::min<int64_t>(I, kWindowSnapshotMin) ? t : -1;
|
||||
}
|
||||
return tail > I && tail - tail / I * I >= std::max<int64_t>(Q, I / 4) ? tail : -1;
|
||||
}
|
||||
@@ -1248,8 +1276,10 @@ int Scheduler::admit_one(SchedReq& s, int64_t budget, int64_t reserve) {
|
||||
* tenant wrote, so the model would attend to the previous request's KV. Zero the reuse
|
||||
* and re-prefill unless a window snapshot covers it.
|
||||
*
|
||||
* A drafter's own group (bound at base_layer and above) is not this clamp's business:
|
||||
* draft refill caps the hit so the recompute covers the drafter's window. */
|
||||
* A drafter's own group (bound at base_layer and above) is not this clamp's business: it
|
||||
* rides in the window snapshot where the engine puts it there
|
||||
* (IKVManager::window_snapshot), and otherwise draft refill caps the hit so the recompute
|
||||
* covers the drafter's window. */
|
||||
if (reuse > 0 && (hit_holes_trunk_ || (hit_needs_window_ && !win_hit))) {
|
||||
reuse = 0;
|
||||
s.hit_cut = SchedReq::HitCut::Window;
|
||||
@@ -1407,6 +1437,7 @@ const RadBatch* Scheduler::step() {
|
||||
if (pc_) pc_->begin_step();
|
||||
|
||||
plan_.reset();
|
||||
plan_.spec_is_tree = tree_;
|
||||
step_prefill_tok_ = 0;
|
||||
step_decode_tok_ = 0;
|
||||
|
||||
@@ -1623,14 +1654,17 @@ const RadBatch* Scheduler::step() {
|
||||
e.n_draft = s.n_draft;
|
||||
e.is_prefill = prefill;
|
||||
e.ngram = !prefill && s.draft_ngram && s.n_draft > 0;
|
||||
/* A tree drafter's parents, unless prompt lookup replaced its proposal with a chain. */
|
||||
e.draft_parent = (!prefill && s.draft_tree && !e.ngram) ? s.draft_par : nullptr;
|
||||
r.draft_parent = e.n_spec ? e.draft_parent : nullptr;
|
||||
e.produces_token = (r.n_computed + want >= target);
|
||||
/* The snapshot a hit resumes from, consumed once: the state is in the slot for the whole
|
||||
* sequence after this, and restoring it again on a later chunk would rewind it. */
|
||||
e.ckpt_restore = s.ckpt_src;
|
||||
s.ckpt_src = -1;
|
||||
/* The checkpoint is the state after the chunk's last token, which the split put at the
|
||||
* interval boundary. */
|
||||
if (ckpt > 0) reserve_ckpt(e, r, ckpt, (int32_t)(want - 1));
|
||||
/* The checkpoint is the state after the chunk's token at `ckpt`: its last, where the split
|
||||
* put the interval boundary there, or inside it for a window snapshot (plan_chunk). */
|
||||
if (ckpt > 0) reserve_ckpt(e, r, ckpt, (int32_t)(ckpt - r.n_computed - 1));
|
||||
s.entry = (int32_t)plan_.e.size();
|
||||
s.sched_tokens = (int32_t)want;
|
||||
plan_.e.push_back(e);
|
||||
@@ -1698,6 +1732,7 @@ const RadBatch* Scheduler::step() {
|
||||
* preemption may still carry a drafter's proposal. */
|
||||
r.n_draft = 0;
|
||||
r.draft = nullptr;
|
||||
r.draft_parent = nullptr;
|
||||
e.n_accepted = 1; /* one-based; a prefill rolls nothing back */
|
||||
e.conv_cursor = s.conv_cursor;
|
||||
e.draft = s.draft;
|
||||
@@ -1708,7 +1743,8 @@ const RadBatch* Scheduler::step() {
|
||||
* restoring again on a later chunk would rewind the recurrence to the hit. */
|
||||
e.ckpt_restore = s.ckpt_src;
|
||||
s.ckpt_src = -1;
|
||||
if (s.pending_ckpt > 0) reserve_ckpt(e, r, s.pending_ckpt, s.sched_tokens - 1);
|
||||
if (s.pending_ckpt > 0)
|
||||
reserve_ckpt(e, r, s.pending_ckpt, (int32_t)(s.pending_ckpt - r.n_computed - 1));
|
||||
s.entry = (int32_t)plan_.e.size();
|
||||
plan_.e.push_back(e);
|
||||
plan_.n_tok += s.sched_tokens;
|
||||
@@ -1748,7 +1784,7 @@ const RadBatch* Scheduler::step() {
|
||||
if (grown > had && kv_->ensure_from(r.id, r.n_computed + grown, r.n_computed) >= 0) {
|
||||
e.n_tokens = (int32_t)grown;
|
||||
e.produces_token = (r.n_computed + grown >= s.seq_len());
|
||||
if (ckpt > 0) reserve_ckpt(e, r, ckpt, (int32_t)(grown - 1));
|
||||
if (ckpt > 0) reserve_ckpt(e, r, ckpt, (int32_t)(ckpt - r.n_computed - 1));
|
||||
s.sched_tokens = (int32_t)grown;
|
||||
plan_.n_tok += grown - had;
|
||||
budget -= grown - had;
|
||||
@@ -2003,6 +2039,7 @@ const RadBatch* Scheduler::step_next_locked() {
|
||||
if (ends_every_request()) return nullptr;
|
||||
|
||||
plan_next_.reset();
|
||||
plan_next_.spec_is_tree = tree_;
|
||||
for (const StepEntry& e : plan_.e) {
|
||||
if (e.slot < 0 || (size_t)e.slot >= reqs_.size()) return nullptr;
|
||||
SchedReq& s = *reqs_[(size_t)e.slot];
|
||||
@@ -2034,6 +2071,8 @@ const RadBatch* Scheduler::step_next_locked() {
|
||||
n.n_accepted = 1; /* the card's: StepSlot::n_acc */
|
||||
n.conv_cursor = s.conv_cursor;
|
||||
n.draft = s.draft; /* published before this step commits (set_draft) */
|
||||
/* And the tree drafter's parents, which the card verifies by (ADV_BTAKE took them). */
|
||||
n.draft_parent = tree_ ? s.draft_par : nullptr;
|
||||
n.n_draft = d;
|
||||
n.is_prefill = false;
|
||||
n.produces_token = true;
|
||||
@@ -2080,7 +2119,11 @@ void Scheduler::promote_next() {
|
||||
s.entry_next = -1;
|
||||
s.draft_next = 0;
|
||||
s.sched_tokens = plan_.e[i].n_tokens;
|
||||
if (s.req) { s.req->n_draft = plan_.e[i].n_spec; s.req->draft = s.draft; }
|
||||
if (s.req) {
|
||||
s.req->n_draft = plan_.e[i].n_spec;
|
||||
s.req->draft = s.draft;
|
||||
s.req->draft_parent = tree_ && plan_.e[i].n_spec ? s.draft_par : nullptr;
|
||||
}
|
||||
}
|
||||
++m_.steps_decode;
|
||||
/* A step issued ahead during a hold is one of its decode-only steps. */
|
||||
@@ -2241,7 +2284,12 @@ int Scheduler::commit(StepResult& res) {
|
||||
if (lp_failed || (lp && lp->token < 0)) { lp_failed = true; return; }
|
||||
if (!server::sink_push(r.sink, t, lp)) overflowed = true;
|
||||
};
|
||||
for (int32_t j = 0; j < a; ++j) emit(s.draft[j], j);
|
||||
/* On a tree step the accepted drafts are the path's nodes, in path order. */
|
||||
const int32_t* path = res.path ? res.path + (size_t)i * RAD_SCHED_MAX_SPEC : nullptr;
|
||||
for (int32_t j = 0; j < a; ++j) {
|
||||
const int32_t d = path ? path[j] - 1 : j;
|
||||
emit(d >= 0 && d < e.n_spec ? s.draft[d] : s.draft[j], j);
|
||||
}
|
||||
if (res.token) emit(res.token[i], a);
|
||||
r.n_computed = valid;
|
||||
step_decode_tok_ += 1 + a;
|
||||
@@ -2692,6 +2740,7 @@ int Scheduler::block_begin(int block, int depth, int window, int32_t mask, Block
|
||||
d.card = e.card;
|
||||
d.ctx_len = e.ctx_len;
|
||||
d.n_tokens = e.n_tokens;
|
||||
d.n_spec = e.produces_token && !e.is_prefill ? e.n_spec : 0;
|
||||
|
||||
/* Every entry of the trunk step gets a row, in order, running or not: the context pass's
|
||||
* row i must be the trunk's row i, so leaving out a sequence the commit just finished
|
||||
@@ -2811,6 +2860,15 @@ const RadBatch* Scheduler::block_context(int step) {
|
||||
/* The context pass reads tapped hidden states, not token ids: nothing to shift and no
|
||||
* draft. */
|
||||
e.produces_token = false;
|
||||
/* A tree verify's rows are restaged on the card from its accepted path (ADV_CTXTREE):
|
||||
* only that path is context, each node at its committed position. Not a placeholder,
|
||||
* whose blocks may already be free. */
|
||||
if (tree_ && d.dev && !d.mirror && d.n_spec > 0 && d.n_tokens == 1 + d.n_spec) {
|
||||
e.dev = true;
|
||||
e.dev_tok = (int32_t)block_plan_.n_tok;
|
||||
e.dev_out = -1;
|
||||
e.dev_aux = 0;
|
||||
}
|
||||
block_plan_.e.push_back(e);
|
||||
block_plan_.n_tok += e.n_tokens;
|
||||
}
|
||||
|
||||
+23
-5
@@ -46,6 +46,10 @@ struct SchedReq {
|
||||
int32_t draft[RAD_SCHED_MAX_SPEC] = {};
|
||||
int32_t n_draft = 0;
|
||||
int32_t conv_cursor = 0;
|
||||
/* A tree drafter's parents for `draft` (StepEntry::draft_parent), valid while `draft_tree`;
|
||||
* a chain proposal (prompt lookup, or a chain drafter) clears it. */
|
||||
int32_t draft_par[RAD_SCHED_MAX_SPEC] = {};
|
||||
bool draft_tree = false;
|
||||
|
||||
/* A serial drafter's valid history: positions [0, draft_filled) of the head's own layer hold
|
||||
* K and V for the sequence's real tokens. Only the head writes that layer, so before drafting
|
||||
@@ -140,6 +144,9 @@ public:
|
||||
* accepted drafts first, then the sampled token) is lp[first_row[i] + j]. */
|
||||
const TokenLogprobs* lp = nullptr;
|
||||
const int32_t* first_row = nullptr; /* [n_seq] */
|
||||
/* A tree step's accepted nodes, [n_seq][RAD_SCHED_MAX_SPEC]: entry i's t-th accepted
|
||||
* draft is draft[path[i][t] - 1]. Null on a chain step, where it is draft[t]. */
|
||||
const int32_t* path = nullptr;
|
||||
};
|
||||
|
||||
/* What commit left a sequence at: its committed length and whether it is still Running.
|
||||
@@ -262,7 +269,8 @@ public:
|
||||
|
||||
/* The drafter's proposal for a request's next step. n is clamped to the sequence's window
|
||||
* (draft_cap): the controller's depth, or what the adaptive policy gives the sequence. */
|
||||
int set_draft(uint64_t id, const int32_t* tokens, int n);
|
||||
/* `parents`: a tree drafter's (rad_drafter_tree), node j + 1's parent node, null for a chain. */
|
||||
int set_draft(uint64_t id, const int32_t* tokens, int n, const int32_t* parents = nullptr);
|
||||
|
||||
/* ---------------------------------------------------------- media the encoder owes
|
||||
* A request carrying media is admitted only once every item is encoded; until then it keeps
|
||||
@@ -400,11 +408,14 @@ public:
|
||||
* block drafter's block length is chosen by. Read before block_begin(). */
|
||||
int decoded_seqs() const;
|
||||
/* Whether a block drafter runs its short block (--draft-short-from `from`), given whether it
|
||||
* ran it last step and this step's decoded_seqs(): on from `from`, off again only at two
|
||||
* below, so a load wavering at the threshold does not switch the pass shape every step. */
|
||||
* ran it last step and this step's decoded_seqs(): on from `from`, and off again two below or
|
||||
* at one sequence below `from`, where the long block pays. Two below keeps a load wavering at
|
||||
* a threshold of 3 or more from switching the pass shape every step. From 2 there is no such
|
||||
* margin: a load between one and two sequences switches every step (block_shape reads it per
|
||||
* step), and the one sequence left after an overlap runs the long block again. */
|
||||
static bool short_block_on(bool was_on, int64_t decoded, int64_t from) {
|
||||
if (decoded >= from) return true;
|
||||
if (decoded + 2 <= from) return false;
|
||||
if (decoded <= 1 || decoded + 2 <= from) return false;
|
||||
return was_on;
|
||||
}
|
||||
const RadBatch* block_context(int step);
|
||||
@@ -425,11 +436,15 @@ public:
|
||||
SchedMetrics observed_metrics() const;
|
||||
int observed_requests(ReqStat* out, int max) const;
|
||||
|
||||
/* plan_chunk's tail-checkpoint rule (see the definition). */
|
||||
/* plan_chunk's tail-checkpoint rule for each --prefix-resume mode (see the definition). */
|
||||
int64_t tail_checkpoint(int64_t target) const;
|
||||
/* The least recompute a snapshot at a shared head (CacheHit::branch_at) must save each later
|
||||
* request for the chunk split that takes it. */
|
||||
static constexpr int64_t kSharedHeadMin = 256;
|
||||
/* The lowest position tail_checkpoint takes a window snapshot at (ChunkGeometry::window_ckpt),
|
||||
* or the interval where that is lower. A prompt reaches it at kWindowSnapshotMin +
|
||||
* max(quantum, 16) tokens: 528 at a quantum of 16. */
|
||||
static constexpr int64_t kWindowSnapshotMin = 512;
|
||||
/* Visible for tests: the chunk the scheduler would give a request at `n_computed` under a
|
||||
* token budget, and the checkpoint position it will land on (-1 for none). `keep_at` is the
|
||||
* request's own checkpoint (Request::checkpoint_at), 0 for none. */
|
||||
@@ -520,6 +535,8 @@ private:
|
||||
* at the committed position (advance.h). False and 0 for every other drafter. */
|
||||
bool serial_shared_ = false;
|
||||
int32_t serial_rot_shift_ = 0;
|
||||
/* A tree drafter (rad_drafter_tree): every trunk plan is StepPlan::spec_is_tree. */
|
||||
bool tree_ = false;
|
||||
BatchBuilder builder_;
|
||||
DraftController draft_;
|
||||
|
||||
@@ -662,6 +679,7 @@ private:
|
||||
int32_t card = -1;
|
||||
int32_t ctx_len = 0;
|
||||
int32_t n_tokens = 0;
|
||||
int32_t n_spec = 0; /* the trunk entry's drafts: a tree verify when > 0 */
|
||||
int64_t base_pos = 0; /* the anchor's position: the sequence's next one */
|
||||
bool can_draft = false;
|
||||
/* On the card: the anchor's position is the card's, and `base_pos` the furthest it can
|
||||
|
||||
Reference in new issue
Block a user