radiance 2.1.0

New models. Recursive Flint (39.8B, about 2.5B active) by everplays (#422): `arch/flint`, as an
IQ8R container with rotated int8 experts or a four-bit one, with a sink-aware WMMA prefill
attention and the fused attention prologue at `rotary_dim` 0. Meta Muse Glimmer 30B by
launch80_assets (#423): bf16, an int4 trunk or IQ8R, its windowed vision tower, its DFlash
drafter, the ATEM tool dialect and context extension. Ling-3.0-tiny by RikshaDriver (#441):
served from its GGUF releases or as IQ8R on `bailing_hybrid`, with six more libr3d kernels. Block
FP8, MXFP4 and NVFP4 conversions of the three are not served. IQ8R containers of all three
(round to nearest, no calibration) are on Hugging Face under StillDeadcode: flint-iq8r,
muse-glimmer-30b-iq8r-dflash and ling-3.0-tiny-iq8r. They were checked for sane answers on two
R9700; nothing was benchmarked, and Muse Glimmer's pictures, video and tool calls were not tried.

Speech. Breeze-TTS-2 clones a voice from a reference recording and its transcript, with an
optional delivery direction, by farcryjohn (#436). The published Breeze container needs
converting again with the updated recipe before it can.

Tools. A model entry with `diagnose: DIR` runs a fixed workload on the engine instead of serving
and writes a report: step times, tokens a step, draft acceptance, TTFT and prefill rates by
category, concurrency and prompt length, and with `diagnose-baseline` a token-for-token comparison
against an earlier report (docs/DIAGNOSE.md), by Code000 (#418).

Scheduler. `mixed-step-target-ms` holds a mixed prefill and decode step to a service time, off by
default, by tnhnyzc (#413). `scheduler.stuck-exit` (60s by default, 0 never) ends the process when
the device has advanced nothing for that long, so a restart policy brings a hung server back
(#409, #415, #428).

Fixed. Draft trees with the int8 KV cache, which stopped Gemma 4 31B with DFlash2 on its first
request (#454, diagnosed by aelfwyne). The expert loan held at zero by a few leftover cache blocks
after long sessions (#455, diagnosed by thekk1). The mapped tier's pages kept in the page cache
across a load and a restore, by C_Tamas (#421). Replayed tool calls with blank arguments, and
arguments that are not JSON refused naming the call, by dschmitz (#444). The dashboard's card
temperature reads the junction sensor, by dschmitz (#453). The VRAM shortfall report says what the
KL mode needs, by baKon (#448). The out-of-tree plugin test builds its plugins in parallel and
takes its toolchain from the tree.

Plugin ABI 40: out-of-tree plugins need to be rebuilt.

Thanks to @everplays, @launch80_assets, @RikshaDriver, @farcryjohn, @Code000, @tnhnyzc, @C_Tamas, @dschmitz, @baKon, @aelfwyne and @thekk1.
This commit is contained in:
Deadcode committed 2026-11-15 16:00:05 +01:00
1 parent ddcb9c69bb
commit 2a2b756371
166 files changed
+20749 -327

No files matched your search

+41 -2
View File
@@ -263,6 +263,13 @@ static bool alias_reasoning(const ojson& messages, ojson* out) {
}
return v;
};
/* A call that takes no arguments, as clients replay it: null, or the empty or blank string a
* client stores from a stream that sent none. */
auto no_arguments = [](const ojson& a) {
return a.is_null() ||
(a.is_string() && a.get_ref<const std::string&>().find_first_not_of(" \t\r\n") ==
std::string::npos);
};
auto needs = [&](const ojson& m) {
if (!m.is_object()) return false;
const auto rc = m.find("reasoning_content");
@@ -283,7 +290,7 @@ static bool alias_reasoning(const ojson& messages, ojson* out) {
if (!call.is_object()) continue;
const auto fn = call.find("function");
if (!call.contains("type") || fn == call.end() || !fn->is_object() ||
!fn->contains("arguments") || fn->at("arguments").is_null())
!fn->contains("arguments") || no_arguments(fn->at("arguments")))
return true;
}
return false;
@@ -336,7 +343,7 @@ static bool alias_reasoning(const ojson& messages, ojson* out) {
call.erase("name");
call.erase("arguments");
}
} else if (!fn->contains("arguments") || fn->at("arguments").is_null()) {
} else if (!fn->contains("arguments") || no_arguments(fn->at("arguments"))) {
(*fn)["arguments"] = "{}";
}
}
@@ -344,6 +351,33 @@ static bool alias_reasoning(const ojson& messages, ojson* out) {
return true;
}
/* The first replayed call whose arguments are a string that is not JSON, as
* "messages[i].tool_calls[j].function.arguments is not JSON: <why>", or empty when every call's
* arguments parse. The template refuses such a conversation with the parser's words alone, which reads as
* the template's fault; this names the call. */
static std::string bad_arguments(const ojson& messages) {
if (!messages.is_array()) return "";
for (size_t i = 0; i < messages.size(); ++i) {
const ojson& m = messages[i];
const auto tcs = m.is_object() ? m.find("tool_calls") : m.end();
if (!m.is_object() || tcs == m.end() || !tcs->is_array()) continue;
for (size_t j = 0; j < tcs->size(); ++j) {
const ojson& tc = (*tcs)[j];
const auto fn = tc.is_object() ? tc.find("function") : tc.end();
if (!tc.is_object() || fn == tc.end() || !fn->is_object()) continue;
const auto args = fn->find("arguments");
if (args == fn->end() || !args->is_string()) continue;
try {
(void)ojson::parse(args->get_ref<const std::string&>());
} catch (const std::exception& e) {
return "messages[" + std::to_string(i) + "].tool_calls[" + std::to_string(j) +
"].function.arguments is not JSON: " + e.what();
}
}
}
return "";
}
int ChatTemplate::apply(const ojson& messages, const ojson& tools, const ChatOptions& opt,
ChatPrompt* out) const {
if (!ready()) {
@@ -430,6 +464,11 @@ int ChatTemplate::apply(const ojson& messages, const ojson& tools, const ChatOpt
}
}
if (!served) {
if (const std::string bad = bad_arguments(msgs); !bad.empty()) {
if (!opt.quiet) RAD_WARN("chat: request did not parse: %s", bad.c_str());
out->error = bad;
return RAD_E_INVAL;
}
const std::string w = template_words(e.what());
if (!opt.quiet) RAD_WARN("chat: the model's chat template refused the request: %s",
w.c_str());
+2 -1
View File
@@ -114,7 +114,8 @@ public:
/* Render. `messages` and `tools` are OpenAI-shaped JSON (`tools` may be null or empty).
* Returns RAD_OK, RAD_E_INVAL when the request does not parse, or RAD_E_UNSUPPORTED when the
* template refuses it (e.g. a system message without a system role, or tools without tool
* support). */
* support). Replayed history is read in other servers' shapes first: a turn's reasoning under
* `reasoning` or `thinking`, and a call whose arguments are null, blank or absent. */
int apply(const Json& messages, const Json& tools,
const ChatOptions& opt, ChatPrompt* out) const;
+4 -1
View File
@@ -353,6 +353,7 @@ int chat_format_from_abi(const RadChatFormat* in, ChatFormat* out, std::string*
f.object_bare_keys = c.object_bare_keys != 0;
f.reasoning_anywhere = c.reasoning_anywhere != 0;
f.arg_json_value_prefix = s(c.arg_json_value_prefix);
f.content_open = s(c.content_open);
*out = std::move(f);
return RAD_OK;
}
@@ -468,6 +469,7 @@ std::string chat_format_describe(const ChatFormat& f) {
(f.reasoning_anywhere ? " anywhere" : "");
else
s += " no reasoning";
if (!f.content_open.empty()) s += "; content " + show(f.content_open);
if (f.has_tools() && !f.section_open.empty())
s += "; section " + show(f.section_open) + ".." + show(f.section_close);
if (f.has_tools() && f.object_args()) {
@@ -498,7 +500,8 @@ std::string chat_format_describe(const ChatFormat& f) {
std::vector<std::string> chat_format_markers(const ChatFormat& f) {
std::vector<std::string> out;
for (const std::string* s : { &f.reasoning_open, &f.reasoning_close, &f.section_open,
for (const std::string* s : { &f.reasoning_open, &f.reasoning_close, &f.content_open,
&f.section_open,
&f.section_close, &f.call_open, &f.call_close, &f.name_prefix,
&f.name_suffix, &f.call_end, &f.arg_prefix, &f.arg_name_suffix,
&f.arg_value_prefix, &f.arg_json_value_prefix,
+3
View File
@@ -100,6 +100,9 @@ struct ChatFormat {
* reasoning there; a close with no block open is dropped. Gemma 4 sometimes writes an empty
* block after its answer, or a lone close. Needs `reasoning_open`. */
bool reasoning_anywhere = false;
/* A header the model writes first when it answers without reasoning; dropped when the reply
* starts with it. Empty: none. */
std::string content_open;
/* ------------------------------------------------------------------ tool calls
* `name_prefix` is what opens a call (after `call_open`, when there is one). Empty means the
+149 -9
View File
@@ -1063,7 +1063,8 @@ int ReplyParser::create(std::shared_ptr<const ReplyFormat> fmt, const ReplyOptio
/* A response format replaces the call grammar outright; the calls are not parsed. */
P.calls = want_calls && !opt.response_format;
P.breaks = want_calls && F.f.has_reasoning() && !F.f.reasoning_breaks.empty();
P.pure = !F.f.has_reasoning() && !want_calls && !opt.response_format;
P.pure = !F.f.has_reasoning() && !want_calls && !opt.response_format &&
F.f.content_open.empty();
P.anywhere = F.f.reasoning_anywhere && F.f.has_reasoning() && opt.extract_reasoning &&
!opt.response_format;
@@ -1093,6 +1094,7 @@ enum class St : uint8_t {
LeadWs, /* whitespace before the reply proper: dropped */
ThinkOpen, /* the core of reasoning_open */
ThinkOpenWs, /* the optional whitespace that ends reasoning_open */
ContentOpen, /* content_open, the header of a reply that does not reason */
Think, /* reasoning text */
ThinkCloseWs, /* the optional whitespace that ends reasoning_close */
Text, /* content, watching for the call opener when calls are on */
@@ -1149,6 +1151,7 @@ struct ReplyStream::Impl {
explicit Impl(const ReplyParser::Impl& p) : P(p), F(p.fmt->impl()) {
content.init(P.terminators.empty() ? nullptr : &P.terms, &P.terminators);
st = P.pure ? St::Text : St::LeadWs;
think_hold_on = P.calls && !F.f.reasoning_breaks.empty();
if (P.anywhere) {
text_dfa = P.calls ? &F.text_think : &F.think_only;
n_open = P.calls ? F.openers.size() : 0;
@@ -1211,6 +1214,16 @@ struct ReplyStream::Impl {
std::string vheld;
size_t vs_pos = 0;
bool fenced = false;
/* Channel-scoped protocols (Muse): with tools on, a trailing `to=NAME<|message|>` while
* reasoning streams is the handoff to a tool call, not reasoning text. The reasoning's
* tail is held until it cannot grow into framing or a header; a completed tool-channel
* header is dropped along with everything after it -- the section opener is where the
* call machinery takes over. Without the hold the header lands in the reasoning stream,
* and a model that hesitates at the handoff repeats it (observed on Muse Glimmer: three
* or four `to=read<|message|>` headers before the section, under speculative decoding). */
bool think_hold_on = false;
std::string think_hold;
bool think_handoff = false;
/* The argument object being read: its open brackets; whether a key (not a value) is being
* read; a separator read but not yet written (written only once the next member shows the
@@ -1293,12 +1306,108 @@ struct ReplyStream::Impl {
void think_out(const char* p, size_t n) {
if (n == 0) return;
if (think_handoff) return; /* past the tool-channel header: call framing, dropped */
touch(0);
if (think_text) { msg.reasoning.append(p, n); return; }
for (size_t i = 0; i < n; ++i)
if (!is_blank((unsigned char)p[i])) { think_text = true; break; }
think_pend.append(p, n);
if (think_text) { msg.reasoning += think_pend; think_pend.clear(); }
if (!think_hold_on) {
if (think_text) { msg.reasoning.append(p, n); return; }
for (size_t i = 0; i < n; ++i)
if (!is_blank((unsigned char)p[i])) { think_text = true; break; }
think_pend.append(p, n);
if (think_text) { msg.reasoning += think_pend; think_pend.clear(); }
return;
}
touch(0);
think_hold.append(p, n);
flush_think_hold(false);
}
void emit_reasoning_upto(size_t emit) {
if (emit == 0) return;
const std::string part = think_hold.substr(0, emit);
if (think_text) { msg.reasoning += part; }
else {
for (size_t i = 0; i < part.size(); ++i)
if (!is_blank((unsigned char)part[i])) { think_text = true; break; }
think_pend += part;
if (think_text) { msg.reasoning += think_pend; think_pend.clear(); }
}
}
/* The handoff position from the last `<|eom|>`: the tail reads as the tool-channel
* header -- optional `<|start|>assistant`, ws, `to=`, recipient name bytes (never
* `user`: that transition matches the reply close above and is consumed by it), then
* `<|message|>` or a prefix of it while the header streams. npos: no handoff. */
size_t tool_handoff_at() const {
static const std::string eom = "<|eom|>", start = "<|start|>assistant", to = "to=";
/* The framing is bounded (terminator + assistant + `to=` + a recipient + the message
* marker); scanning only the tail keeps a byte-at-a-time stream linear. */
const size_t wstart = think_hold.size() - std::min(kHoldWindow, think_hold.size());
size_t p = std::string::npos;
for (size_t q = think_hold.find(eom, wstart); q != std::string::npos;
q = think_hold.find(eom, q + 1))
p = q;
if (p == std::string::npos) return std::string::npos;
size_t k = p + eom.size();
if (think_hold.compare(k, start.size(), start) == 0) k += start.size();
while (k < think_hold.size() && is_ws((unsigned char)think_hold[k])) ++k;
if (think_hold.compare(k, to.size(), to) != 0) return std::string::npos;
return p; /* everything from `<|eom|>` on is the tool call's framing */
}
/* Muse's channel protocol, per the reference parsers (vLLM's muse reasoning/tool
* parsers; llama.cpp PR #26841): reasoning streams until `<|eom|>`, and the model
* sometimes leaves the analysis channel WITHOUT it, opening a tool channel directly
* (`<|start|>assistant to=read<|message|>`) -- a documented model-side defect. So the
* reasoning's tail is held while it could still grow into that framing, and once the
* handoff is detected everything from the header on is dropped: the call machinery
* (the section + invoke tags) has already produced the tool_calls events. */
void flush_think_hold(bool final_feed) {
if (think_handoff) return; /* past the handoff: framing, dropped */
size_t emit = think_hold.size();
const size_t handoff = tool_handoff_at();
if (handoff != std::string::npos) {
emit = handoff;
think_handoff = true;
} else if (!final_feed) {
/* Hold a tail that could still grow into the handoff framing: a partial
* `<|eom|>` / `<|start|>` / `<|message|>` marker, or a trailing ` to=NAME`. */
static const std::string markers[] = {"<|eom|>", "<|start|>", "<|message|>"};
for (const std::string& mk : markers)
for (size_t k = std::min(mk.size(), think_hold.size()); k > 0; --k)
if (think_hold.compare(think_hold.size() - k, k, mk, 0, k) == 0)
emit = std::min(emit, think_hold.size() - k);
const size_t wstart_t = think_hold.size() - std::min(kHoldWindow, think_hold.size());
size_t at = std::string::npos;
for (size_t q = think_hold.find("to=", wstart_t); q != std::string::npos;
q = think_hold.find("to=", q + 1))
at = q;
if (at != std::string::npos) {
bool tail = true;
for (size_t k = at + 3; k < think_hold.size(); ++k)
if (!is_name_byte((unsigned char)think_hold[k])) { tail = false; break; }
if (tail) {
size_t a = at;
while (a > 0 && is_ws((unsigned char)think_hold[a - 1])) --a;
emit = std::min(emit, a);
}
}
if (emit >= think_hold.size()) {
emit_reasoning_upto(emit);
think_hold.clear(); /* nothing held: everything goes out now */
return;
}
}
if (emit > 0) emit_reasoning_upto(emit);
think_hold.erase(0, emit);
if (final_feed) think_hold.clear();
}
/* The tail the framing scans read; a longer tail is real reasoning, never framing. */
static constexpr size_t kHoldWindow = 160;
static bool is_name_byte(unsigned char c) {
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||
c == '_' || c == '.' || c == '-';
}
void text_out(const char* p, size_t n) {
@@ -2051,6 +2160,20 @@ struct ReplyStream::Impl {
return p + 1;
}
/* No block: what was held is read again as whatever follows one. */
st = after_no_block();
read_again(lhold);
lhold.clear();
return p;
}
case St::ContentOpen: {
const unsigned char c = (unsigned char)*p;
if (lpos < F.f.content_open.size() && (unsigned char)F.f.content_open[lpos] == c) {
lhold.push_back((char)c);
if (++lpos == F.f.content_open.size()) { lhold.clear(); st = after_think(); }
return p + 1;
}
/* Not the header: what was held is content (or the start of the document). */
st = after_think();
read_again(lhold);
lhold.clear();
@@ -2066,10 +2189,11 @@ struct ReplyStream::Impl {
case St::Think: {
const Dfa& d = P.breaks ? F.think_breaks : F.think;
p = scan(d, p, e, &hit, [this](const char* q, size_t n) { think_out(q, n); });
if (hit == 0) { trail = 0; st = St::ThinkCloseWs; }
if (hit == 0) { flush_think_hold(true); trail = 0; st = St::ThinkCloseWs; }
else if (hit > 0) {
const std::string& marker = d.pattern(hit);
if (!F.section_open_core.empty() && marker == F.section_open_core) {
flush_think_hold(true);
open_section();
st = St::Text;
} else if (!F.section_open_core.empty() && !section_active) {
@@ -2754,10 +2878,17 @@ struct ReplyStream::Impl {
return e;
}
St after_lead() const {
St after_lead() {
if (F.f.has_reasoning() && P.opt.extract_reasoning)
return F.open_core.empty() ? St::Think : St::ThinkOpen;
return after_think();
return after_no_block();
}
/* The reply did not open a reasoning block: its content_open header, when the format has one,
* is matched from the first byte (the bytes of a failed reasoning opener are read again). */
St after_no_block() {
if (F.f.content_open.empty()) return after_think();
lpos = 0;
return St::ContentOpen;
}
St after_think() const { return P.opt.response_format ? St::RfWs : St::Text; }
@@ -2887,6 +3018,14 @@ struct ReplyStream::Impl {
rerun();
}
if (st == St::ObjStr || st == St::ObjQStr) str_flush();
/* The reply ended inside a header that never completed: its bytes are the reply. */
while (!F.f.content_open.empty() && !lhold.empty() &&
(st == St::ContentOpen || st == St::ThinkOpen)) {
st = st == St::ThinkOpen ? after_no_block() : after_think();
read_again(lhold);
lhold.clear();
rerun();
}
while (in_loose_attempt()) {
fail_attempt();
rerun();
@@ -2935,6 +3074,7 @@ struct ReplyStream::Impl {
}
hold.clear();
ds = 0;
if (think_hold_on) flush_think_hold(true);
if (!think_text) think_pend.clear();
content.finish(msg.content);
if (cur >= 0) publish(cur, true);