Archived
kv: a window group keeps the keys a prefill chunk still reads
ensure() recycled a RAD_KV_WINDOW group against the end of the step, so a prefill chunk lost the keys its first rows read (a 2185-token prompt kept no window KV for positions 0..1151). Recycle below the step's first query (keep_from = n_computed), size the caps for one extra chunk, and trim the window when a prefill chunk is committed. The old test pinned the bug. Found while debugging #75 (Gemma 4).
This commit is contained in:
1 parent
77c266ce8f
commit
921b02b60b
6 files changed
+145
-29
No files matched your search
@@ -185,8 +185,12 @@ void BatchBuilder::size_set(Set& s, const std::vector<KVGroupInfo>& groups) {
|
||||
s.groups[gi].block_size = e.block_size;
|
||||
int64_t mb = 1;
|
||||
if (e.paged) {
|
||||
int64_t span = (e.kind == RAD_KV_WINDOW && e.window > 0 && e.window < max_ctx_)
|
||||
? e.window : max_ctx_;
|
||||
/* A WINDOW row holds the window behind the step's first query AND the step's own
|
||||
* tokens (KVManager::ensure keeps both), so it is sized for a whole chunk past the
|
||||
* window -- plus the speculative lookahead, which a verify row carries on top. */
|
||||
const int64_t wspan = e.window + max_tok_ + 2 * ((int64_t)std::max(cfg_.n_spec, 0) + 1);
|
||||
int64_t span = (e.kind == RAD_KV_WINDOW && e.window > 0 && wspan < max_ctx_)
|
||||
? wspan : max_ctx_;
|
||||
mb = (span + e.block_size - 1) / e.block_size + 1;
|
||||
}
|
||||
s.groups[gi].max_blocks = mb;
|
||||
|
||||
Reference in new issue
Block a user