Archived
speculation: a group the window snapshot restores is no hole in a drafter's KV after a prefix hit
On Gemma 4 (sliding layers the prefix cache does not index, no linear state) a hit resumes the trunk's window from a window snapshot. The check for a hole in a block drafter's own KV after a hit counted every paged group the prefix cache does not index, the trunk's windowed one included, so it found a hole the snapshot fills. z-lab's DFlash drafter keeps a full-attention cache, which the prefix cache indexes; with that false hole its floor sat at the hit, and with no window to slide it was declined for the rest of every turn after a hit (on the 31B: 1.00 tokens a step on those turns, 4.25 with this). The scheduler now counts a group the snapshot restores (IKVManager::window_snapshot, the KV manager's KVGroupPlan::win_snap) as no hole, and the startup line says how many: `draft floor: 3 paged group(s), 2 prefix-cached, 1 in the window snapshot -> a hit leaves no hole`. A drafter's own windowed group is not in the snapshot, so DFlash2 and every model with linear state are unchanged. Tests: sched_test (a full-attention drafter drafts at once after a hit the window snapshot resumes, and with the trunk's window counted as a hole never drafts again that turn; the fixture gains a full-attention trunk). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c1c71b147
commit
66c86b9f89
5 files changed
+118
-40
No files matched your search
@@ -84,19 +84,28 @@ int Scheduler::init(Program& prog, const Config& cfg, IKVManager* kv, IPrefixCac
|
||||
"the prefix cache, checkpoints and speculation",
|
||||
rswa_windows_.size(), (long long)rswa_windows_[0].tokens);
|
||||
|
||||
/* A hit can leave a drafter's own cache short only where a paged group is not prefix-cached
|
||||
* (scheduler.h, hit_holes_draft_). With the cache off cached_groups() is empty and this is
|
||||
* true, which costs nothing: no hits are taken, and every first block pass is at ctx_len 0. */
|
||||
/* A hit can leave a drafter's own cache short only where a paged group is neither
|
||||
* prefix-cached nor carried by the window snapshot a hit resumes from (scheduler.h,
|
||||
* hit_holes_draft_). With the cache off cached_groups() is empty and this is true, which
|
||||
* costs nothing: no hits are taken, and every first block pass is at ctx_len 0. */
|
||||
{
|
||||
/* Paged as the cache counts it (KVGroupPlan::paged(), via block_tokens()), not kvgeom_'s
|
||||
* `paged` flag, which is also true for an empty placeholder group and would pin this
|
||||
* predicate true. */
|
||||
size_t n_paged = 0;
|
||||
for (size_t i = 0; i < kvgeom_.g.size(); ++i)
|
||||
if (kv->block_tokens((int32_t)i) > 0) ++n_paged;
|
||||
hit_holes_draft_ = pc->cached_groups().size() < n_paged;
|
||||
RAD_INFO("draft floor: %zu paged group(s), %zu prefix-cached -> a hit %s",
|
||||
n_paged, pc->cached_groups().size(),
|
||||
size_t n_paged = 0, n_snap = 0;
|
||||
for (size_t i = 0; i < kvgeom_.g.size(); ++i) {
|
||||
if (kv->block_tokens((int32_t)i) <= 0) continue;
|
||||
++n_paged;
|
||||
const auto& cg = pc->cached_groups();
|
||||
/* Snapshots are taken only where the trunk has a window to snapshot too
|
||||
* (ChunkGeometry::window_ckpt); without them no drafter window rides in one. */
|
||||
if (cfg.prefix_cache && geo_.window_ckpt && kv->window_snapshot((int32_t)i) &&
|
||||
std::find(cg.begin(), cg.end(), (int32_t)i) == cg.end())
|
||||
++n_snap;
|
||||
}
|
||||
hit_holes_draft_ = pc->cached_groups().size() + n_snap < n_paged;
|
||||
RAD_INFO("draft floor: %zu paged group(s), %zu prefix-cached, %zu in the window snapshot "
|
||||
"-> a hit %s", n_paged, pc->cached_groups().size(), n_snap,
|
||||
hit_holes_draft_ ? "leaves a hole in a drafter's own KV" : "leaves no hole");
|
||||
}
|
||||
/* The trunk's share: a paged group a trunk layer reads (a bound layer below the trunk's layer
|
||||
|
||||
Reference in new issue
Block a user