Merge Gemma 4 31B: PRs #74, #75, #81 and #86 (sfjes, keptn42), with fixes

The gemma4_bf16 architecture (sliding and global attention, the proportional RoPE ladder, the
assistant head as a drafter that reads the trunk's cache, the vision tower), its w4a8 decode
junctions, the h512/gqa8 and h256/gqa2 attention kernels, compressed-tensors int4 import, multi-EOS
from generation_config, the call/reasoning reply format, a window group that keeps the keys a
prefill chunk still reads, and window snapshots in checkpoint slots so a prefix hit on a
sliding-window trunk resumes.

Fixes on top: the investigation switches and diagnostic blocks out of the served paths; int4 import
through the checkpoint import framework; attention_k_eq_v from the config; the fused junctions only
where every reader takes their pair; a shared-KV head binds no group of its own; the compose file
without HSA_ENABLE_IPC_MODE_LEGACY (TP2 fails with it on ROCm 10.1); a checkpoint carries a window
only where a hit resumes from it; the README says the linked container is keptn42's calibrated GPTQ
build and what the in-tree recipe gives.
This commit is contained in:
Deadcode committed 2026-10-12 20:46:37 +02:00
84 files changed
+10292 -230

No files matched your search

+26 -2
View File
@@ -191,8 +191,14 @@ public:
/* The batch the last build produced for one rank; see BatchBuilder::batch_for. */
const RadBatch* batch_for(int rank) const { return builder_.batch_for(rank); }
/* The advance's view of that build on one rank; see BatchBuilder::advance_args. */
AdvanceArgs advance_args(int rank) const { return builder_.advance_args(rank); }
/* The advance's view of that build on one rank; see BatchBuilder::advance_args. It carries
* the serial head's shape as well, which only the draft passes' modes read. */
AdvanceArgs advance_args(int rank) const {
AdvanceArgs a = builder_.advance_args(rank);
a.shared_kv = serial_shared_ ? 1 : 0;
a.rot_shift = serial_rot_shift_;
return a;
}
void fini();
/* ---------------------------------------------------------- off the step path */
@@ -505,6 +511,18 @@ private:
* also skips on a block-size mismatch. A bound like this lives in exactly one place; a second
* copy is free to drift out of step with the first. */
bool hit_holes_draft_ = true;
/* DOES A HIT HOLE THE TRUNK ITSELF? hit_holes_draft_ is the drafter's guard, and draft_refill_
* repairs a drafter hole by recomputing the prompt's TAIL. A TRUNK group the cache does not
* index admits no such repair: the adopted blocks cover the cached groups only, while the
* windowed trunk layers read the positions below ctx_len this sequence never wrote — the KV of
* whoever held these blocks last. So a trunk hole refuses the hit outright.
*
* THE TRUNK IS WHICH GROUPS? The one a drafter borrows is bound at `base_layer` and above —
* the drafter's layers run after the trunk's (rad_bind_layer_kv at the drafter declare), so a
* group with a bound layer below meta.n_layers belongs to the trunk and a hit must cover it;
* a drafter's own group is the refill's business, not this clamp's. Read off the Program,
* which carries both the bindings and the trunk's layer count. */
bool hit_holes_trunk_ = false;
/* DRAFT REFILL. Where a hit leaves a hole in a WINDOWED block drafter's cache, the drafter is
* declined until its window has slid past the hole, which on the follow-up turn of a chat --
* the turn a prefix hit is for -- is most or all of the reply. So the hit is ended one window
@@ -514,6 +532,12 @@ private:
* that point would give back more than two windows is kept whole. The drafter's window, or 0
* where no hit can leave such a hole. */
int64_t draft_refill_ = 0;
/* A SERIAL HEAD WITH NO CACHE OF ITS OWN (rad_drafter_shared_kv), off the Program at init. It
* owes no history, so serial_begin gives it one row a drafting sequence and none to a sequence
* that does not draft, and its rounds stay at the committed position (advance.h). False and 0
* for every other drafter, whose passes are staged exactly as before. */
bool serial_shared_ = false;
int32_t serial_rot_shift_ = 0;
BatchBuilder builder_;
DraftController draft_;