kv: a group a rank keeps no cache for

rad_kv_group_zero(b, group): the group is declared as on every other rank --
the scheduler indexes groups by position and one block table serves every
rank -- and this rank carves nothing for it: its block count is the shared
table's, its costs are zero, its pool base is null, and issue refuses any op
on this rank that names it. For a rank the geometry gives no attention heads,
whose attention is a fill of zeros and never stores or reads a key. qwen4exp
declares its attention group so on such a rank. The arch test's contract
becomes the real one: same KV groups by position; ops are each rank's own.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-06 11:23:06 +02:00
1 parent 7be92ec8f4
commit 3e629e7a27
9 files changed
+95 -18

No files matched your search

+17
View File
@@ -256,6 +256,14 @@ int KVManager::plan_groups(const std::vector<KVGroupInfo>& groups, const Config&
RAD_ERR("KV group '%s': unknown kind %d", p.name.c_str(), p.kind);
return RAD_E_INVAL;
}
/* A ZERO GROUP COSTS THIS RANK NOTHING: declared for its position and its block count,
* never carved, never read. The validation above still ran on the real sizes, so a zero
* group is a real group on every other rank. */
if (g.zero) {
p.zero = true;
p.bytes_per_block = 0;
p.bytes_per_state = 0;
}
plans_.push_back(std::move(p));
}
bundling_ = compare_bundling(bundles);
@@ -453,6 +461,15 @@ int KVManager::carve_into(Pool& kv_pool) {
int64_t bytes = p.paged() ? p.n_blocks * p.bytes_per_block
: p.n_states * p.bytes_per_state;
if (p.paged()) paged_taken += bytes;
if (p.zero) {
p.base = nullptr;
p.pool_offset = 0;
p.pool_bytes = 0;
RAD_INFO("KV group '%s': this rank keeps no cache for it (rad_kv_group_zero) -- %lld "
"blocks of the shared table, nothing carved", p.name.c_str(),
(long long)p.n_blocks);
continue;
}
int64_t off = 0;
void* ptr = kv_pool.reserve(p.name, bytes, RAD_ALIGN_UNIT, &off);
if (!ptr && !kv_pool.accounting_only()) {
+4
View File
@@ -74,6 +74,10 @@ struct KVGroupPlan {
int64_t window_blocks = 0; /* WINDOW: the per-sequence block cap */
int64_t n_blocks = 0; /* paged groups: blocks carved from the pool */
/* rad_kv_group_zero: this rank keeps no cache for the group. The plan exists for its position
* and its block count (one block table serves every rank), its costs are zero and nothing is
* carved; no op on this rank names it (issue refuses a group with no pool bound). */
bool zero = false;
int64_t n_states = 0; /* LINEAR/CONV: n_seq_states * state_copies */
/* HOW MANY PHYSICAL SLOTS ONE LOGICAL STATE COSTS. One, normally: a sequence owns a state.
* Under speculation a linear kernel needs somewhere to put what it cannot commit yet -- it