radiance 1.5.0

- Gemma 4 31B (PRs #74, #75, #81, #86; sfjes, keptn42): sliding and global attention with their
  own kernels, the assistant head as a drafter that reads the trunk's cache, the vision tower, a
  fused w4a8 decode step, bf16 and compressed-tensors int4 checkpoints, and window snapshots so a
  prefix hit on a sliding-window model resumes instead of prefilling again.
  deploy/compose/gemma4-31b-w4a8.yaml serves keptn42's container on two cards
- ParoQuant (PRs #65, #66, #67; malic): Qwen3.8-27B checkpoints with learned Givens rotations,
  as int4, int5 and MXFP4, imported without re-quantising, the prefill's rotations on the matrix
  cores. deploy/compose/qwen3.8-27b-paro.yaml serves them on one card. A ParoQuant container made
  with the PR builds is refused: convert it again with --reuse <old container>
- Gemma 4 26B-A4B with z-lab's DFlash drafter (PR #88; Perire): arch/gemma4 serves Google's bf16
  checkpoint with the routed experts in block fp8 or bf16 (data/recipes/gemma4-26b-a4b-df*.recipe),
  and libr4d gains its windowed paged attention, the fused sandwich-norm joins, expert_scale and
  the sharded draft head's pair_argmax. A prefill chunk runs as two slices with its all-reduces
  beside the compute, bit-exact with the whole step. The 31B's global layers take the windowed
  attention too: an 11.5K-token prefill on two R9700s in 3.1 s instead of 4.9
- a startup that logs nothing for two minutes says where it waits (#89): the system call (a KFD
  request by name), the library that made it, and its stack, which addr2line resolves against the
  binary
- the prefix cache is kept in VRAM and host memory only (#70): the disk tier wrote every block and
  snapshot a prompt produced, and its copies never outlived the process. --prefix-cache-host-mib
  is renamed --prefix-cache-mib; --prefix-cache-dir and --prefix-cache-disk-mib are removed, and
  startup refuses all three with what replaced them. The compose files no longer mount /data, and
  .env no longer needs RADIANCE_STATE
- --prefix-cache-ttl S (default 3600, 0 never): a conversation no request has used for that long
  leaves the cache, whichever tier holds it; radiance:prefix_cache_expired_total counts them. A
  full host tier now drops its least recently used conversations
- --vision-tower-placement vram|ram (#84): ram keeps an encoder tower in pinned host memory and
  gives its VRAM to the KV cache, read over the link once an image
- timings carry ttft_ms and total_ms (#85): the server's own time from the request body's arrival
  to the first and the last token, queueing and tokenisation included
- a KV-cache recall that found a moved expert with nowhere to go stopped halfway and leaked the
  slots it had already freed: after it every recall failed, the cache stayed short until a
  restart, and requests failed with HTTP 500. A recall now waits for the slots it is owed and
  always finishes
- a tool result or tool-call arguments that are not JSON are no longer refused as nesting past
  1024 levels for their unmatched brackets (#90): only text that parses as JSON is held to the
  bound, since nothing else is parsed into a tree
- the host-pool refusal names the limit that applies to pinned memory (RAM less 1/64 and
  1.5 GiB), not ttm.pages_limit
- --embedding-placement auto, removed in 1.3.0, is refused with what replaced it
- for out-of-tree kernel libraries: gemm_nt_q gains two operands (pb1, pb2, the part bounds), and
  the loader requires identical op schemas, so a library built against 1.4.0 must be rebuilt. For
  architecture plugins, rad_op_declared(b, op) asks whether an op is in the loaded vocabulary
  without declaring it
This commit is contained in:
Deadcode committed 2026-10-13 19:35:16 +02:00
commit b93b531f63
127 files changed
+9609 -4796

No files matched your search

+54 -7
View File
@@ -245,7 +245,11 @@ const char* kAcceptedChat[] = {
"functions", "function_call",
};
const char* kAcceptedCompletion[] = { "prompt", "echo" };
/* `preserved_tokens` is llama-server's: control tokens a raw completion's text keeps. On chat the
* reply format decides them (the guarded entry below); a raw completion has no format, and a
* client that renders its own template and parses its own reply -- a tool-call sidecar -- has no
* other way to see a format built of control tokens. */
const char* kAcceptedCompletion[] = { "prompt", "echo", "preserved_tokens" };
const char* kAcceptedEmbedding[] = { "model", "input", "messages", "encoding_format",
"dimensions", "image_tokens", "prompt_name" };
@@ -1233,6 +1237,15 @@ static int json_text_depth(const std::string& s) {
return most;
}
/* A STRING THAT PARSES INTO A TREE DEEPER THAN THE BOUND. Only valid JSON becomes a tree: text
* that is not JSON never becomes one (a tool result that does not parse is rendered as the
* string it is), so its brackets are not nesting, however they count. The count
* runs first and the validation (json::accept, which builds nothing and does not recurse) only
* when it is over. */
static bool json_text_too_deep(const std::string& s) {
return json_text_depth(s) > kJsonMaxDepth && json::accept(s);
}
/* STRINGS THE CHAT TEMPLATE PARSES AS JSON are bounded like the body is (parse_json_bounded). An
* assistant message's tool-call arguments and a tool message's content arrive as strings, one
* level deep in the request, and the template layer parses them into trees and serialises those
@@ -1248,7 +1261,7 @@ static int check_template_json(const json& msg, const std::string& role, ApiErro
if (fn == tc.end() || !fn->is_object()) continue;
auto args = fn->find("arguments");
if (args != fn->end() && args->is_string() &&
json_text_depth(args->get_ref<const std::string&>()) > kJsonMaxDepth) {
json_text_too_deep(args->get_ref<const std::string&>())) {
*err = err_bad("messages[].tool_calls[].function.arguments",
"nests more than " + std::to_string(kJsonMaxDepth) +
" levels deep");
@@ -1260,7 +1273,7 @@ static int check_template_json(const json& msg, const std::string& role, ApiErro
if (role == "tool") {
auto c = msg.find("content");
if (c != msg.end() && c->is_string() &&
json_text_depth(c->get_ref<const std::string&>()) > kJsonMaxDepth) {
json_text_too_deep(c->get_ref<const std::string&>())) {
*err = err_bad("messages[].content", "a tool result nests more than " +
std::to_string(kJsonMaxDepth) +
" levels deep");
@@ -1613,9 +1626,18 @@ static int parse_thinking_budget(const json& b, const OaiDeps& d, const OaiLimit
if (!render.think_open.empty()) o = d.tok->encode(render.think_open, false, true);
n_close = c.size();
n_open = o.size();
if (c.size() == 1 && (render.think_starts_open || o.size() == 1)) {
/* AN OPENER THAT IS ONE CONTROL TOKEN AND THEN TEXT -- Gemma 4's `<|channel>thought` --
* is found by that first token: it is what a reply opening its own block writes first,
* and no text can be. The text after it counts as reasoning, as the markers do. An opener
* with a second control token in it (a channel and a message marker) is not read this
* way, since its first token may open something other than the reasoning. */
bool open_first = o.size() > 1 && d.tok->reply_bytes(o[0]).empty() &&
!d.tok->token_bytes(o[0]).empty();
for (size_t i = 1; open_first && i < o.size(); ++i)
if (d.tok->reply_bytes(o[i]).empty()) open_first = false;
if (c.size() == 1 && (render.think_starts_open || o.size() == 1 || open_first)) {
span.close = c[0];
span.open = o.size() == 1 ? o[0] : -1;
span.open = (o.size() == 1 || open_first) ? o[0] : -1;
span.starts_open = render.think_starts_open;
}
}
@@ -1654,8 +1676,8 @@ static int parse_thinking_budget(const json& b, const OaiDeps& d, const OaiLimit
"as one token";
else
why = "this reply has to open its own reasoning block, and the opener `" +
render.think_open + "` is " + std::to_string(n_open) + " tokens, so the block "
"cannot be found by token";
render.think_open + "` is " + std::to_string(n_open) + " tokens and does not "
"start with a lone control token, so the block cannot be found by token";
*err = err_unsupported(named, why);
return RAD_E_UNSUPPORTED;
}
@@ -2135,6 +2157,29 @@ int parse_completion_request(const std::string& body, const OaiDeps& d, const Oa
if (!get_bool(b, "echo", &out->echo, err)) return RAD_E_INVAL;
/* The control tokens this completion's text keeps (llama-server's field): each string is
* tokenised by the decoder and every control token in it is rendered rather than dropped.
* Bounded as the stop strings are, since the decoder looks each one up per token. */
{
auto pt = b.find("preserved_tokens");
if (pt != b.end() && !pt->is_null()) {
if (!pt->is_array() || pt->size() > (size_t)lim.max_stops) {
*err = err_bad("preserved_tokens", "expected an array of at most " +
std::to_string(lim.max_stops) + " strings");
return RAD_E_INVAL;
}
for (const auto& s : *pt) {
if (!s.is_string() || s.get<std::string>().size() > (size_t)lim.max_stop_bytes) {
*err = err_bad("preserved_tokens", "expected strings of at most " +
std::to_string(lim.max_stop_bytes) +
" bytes");
return RAD_E_INVAL;
}
out->preserved_tokens.push_back(s.get<std::string>());
}
}
}
RAD_TRY(parse_logprobs(b, lim, Endpoint::Completion, out, err));
/* `echo` with logprobs asks for the PROMPT's logprobs too, which are not computed: a prompt
* position's distribution never leaves the card. */
@@ -2569,6 +2614,8 @@ json timings_json(const TimingsOut& t) {
o["predicted_ms"] = t.predicted_ms;
o["predicted_per_token_ms"] = per(t.decode_n, t.predicted_ms);
o["predicted_per_second"] = rate(t.decode_n, t.predicted_ms);
o["ttft_ms"] = t.ttft_ms >= 0.0 ? json(t.ttft_ms) : json(nullptr);
o["total_ms"] = t.total_ms >= 0.0 ? json(t.total_ms) : json(nullptr);
if (t.draft_n > 0) {
o["draft_n"] = t.draft_n;
o["draft_n_accepted"] = t.draft_n_accepted;