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

+21 -6
View File
@@ -2910,15 +2910,17 @@ int Engine::configure_kv() {
slot += ranks_[i]->kv.checkpoint_bytes();
}
const int64_t n = cfg_.checkpoint_slots > 0 ? cfg_.checkpoint_slots : 0;
/* A slot holds linear state or a trunk's window, never both (KVGroupPlan::win_snap). */
const char* what = ranks_[0]->kv.has_window_snapshot() ? "sliding-window" : "linear-state";
if (slot > 0 && n > 0 && cfg_.prefix_cache) {
if (ck_store_.open(slot, slot * n) != RAD_OK) {
RAD_WARN("checkpoint slots: no pinned host memory for %lld snapshot(s) of %s; a "
"hybrid session's prefix hits replay their linear layers from zero. "
"Lower --checkpoint-slots.", (long long)n, humanb(slot).c_str());
RAD_WARN("checkpoint slots: no pinned host memory for %lld %s snapshot(s) of %s; "
"a session's prefix hits prefill from the start. Lower "
"--checkpoint-slots.", (long long)n, what, humanb(slot).c_str());
} else {
RAD_INFO("checkpoint slots: %lld linear-state snapshot(s) of %s in pinned host "
"memory (%s), none of it on the card", (long long)n,
humanb(slot).c_str(), humanb(ck_store_.cap_bytes()).c_str());
RAD_INFO("checkpoint slots: %lld %s snapshot(s) of %s in pinned host memory (%s), "
"none of it on the card", (long long)n, what, humanb(slot).c_str(),
humanb(ck_store_.cap_bytes()).c_str());
}
}
for (auto& r : ranks_)
@@ -3893,6 +3895,19 @@ int Engine::load_vocab() {
vb.chat_template = std::move(t);
}
/* The checkpoint's own end-of-generation list travels as metadata, flattened from
* generation_config.json -- a space-separated list, or one id. */
if (const char* ids = rad_meta_gets(&meta_, "generation.eos_token_id", nullptr)) {
const char* q = ids;
while (*q) {
char* end = nullptr;
const long v = std::strtol(q, &end, 10);
if (end == q) break;
if (v >= 0 && v <= INT32_MAX) vb.eos_ids.push_back((int32_t)v);
q = end;
}
}
auto v = std::make_shared<Vocab>();
RAD_TRY(v->load(std::move(vb)));
vocab_ = v;