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

+24 -3
View File
@@ -704,13 +704,21 @@ int Engine::step_loop() {
for (const StepEntry& e : plan.e) {
if (e.ckpt_restore < 0) continue;
if (!state_slots_of(e.seq, &ckpt_slots_)) continue;
/* The window behind the hit, in the blocks admit_one seeded at its floor. */
if (ranks_[0]->kv.has_window_snapshot() &&
!ranks_[0]->kv.window_rows(e.seq, e.ctx_len, &ckpt_win_)) {
RAD_ERR("sequence %llu: no window rows at %d to restore into",
(unsigned long long)e.seq, (int)e.ctx_len);
return RAD_E_STATE;
}
for (size_t ri = 0; ri < ranks_.size(); ++ri) {
auto& rk = ranks_[ri];
/* This rank's device, for its own stream and its own state slots. */
if (ranks_.size() > 1) (void)rad_dev_set(rk->device);
const int s = rk->kv.checkpoint_restore(ckpt_slots_.data(),
(int)ckpt_slots_.size(),
e.ckpt_restore, rk->ctx.stream());
e.ckpt_restore, rk->ctx.stream(),
&ckpt_win_);
if (s < 0) {
RAD_ERR("could not restore sequence %llu from checkpoint slot %d on "
"rank %d: %s", (unsigned long long)e.seq,
@@ -809,11 +817,23 @@ int Engine::step_loop() {
for (const StepEntry& e : plan.e) {
if (e.ckpt_slot < 0 || e.ckpt_tok < 0) continue;
if (!state_slots_of(e.seq, &ckpt_slots_)) continue;
/* The window behind the checkpoint position. The chunk that ends there
* still holds it (its ensure kept the window behind the chunk's first
* query), so a miss is a broken invariant -- and skipping would leave the
* cache a slot it commits as valid with somebody else's pages in it. */
if (ranks_[0]->kv.has_window_snapshot() &&
!ranks_[0]->kv.window_rows(e.seq, e.ctx_len + e.ckpt_tok + 1,
&ckpt_win_)) {
RAD_ERR("sequence %llu: the window behind checkpoint %d is not held",
(unsigned long long)e.seq, (int)(e.ctx_len + e.ckpt_tok + 1));
return RAD_E_STATE;
}
for (auto& rk : ranks_) {
if (ranks_.size() > 1) (void)rad_dev_set(rk->device);
const int s = rk->kv.checkpoint_save(ckpt_slots_.data(),
(int)ckpt_slots_.size(),
e.ckpt_slot, rk->ctx.stream());
e.ckpt_slot, rk->ctx.stream(),
&ckpt_win_);
if (s < 0) {
RAD_ERR("rank %d could not snapshot sequence %llu into checkpoint slot "
"%d: %s", rk->index, (unsigned long long)e.seq,
@@ -1924,7 +1944,8 @@ bool Engine::state_slots_of(uint64_t seq, std::vector<int32_t>* out) const {
(*out)[(size_t)g] = s;
any = true;
}
return any;
/* A window snapshot is a snapshot with no state slots (KVManager::has_window_snapshot). */
return any || (kv.has_window_snapshot() && kv.has_sequence(seq));
}
/* ------------------------------------------------------------------ the HTTP frontend */