radiance 1.2.1

- A checkpoint restore that found its snapshot slot given back stopped the engine (#33): a
  snapshot handed to an admission is now kept until its step has run, a lost one re-prefills
  that request instead, and a failed restore names the check and the rank.
- The headroom warning had no fixed point (#32): it now checks the room left for a kernel's first
  launch and names the --gpu-headroom-mib value that clears it.
- reasoning_effort (#31): the levels the chat template takes are probed at startup and published
  in /server_info; a level outside them is a 400 on `reasoning_effort` with `supported`;
  --reasoning-effort-map rewrites a client's level.
- rad-convert reads published quantised releases (#29): AMD Quark MXFP4 byte for byte, and
  AutoRound (auto_round:auto_gptq) / GPTQ int4 and int8, with Flash-Next checkpoints that ship
  their experts one by one.
- tool_choice "required" and a named function are served by a call grammar for the whole reply.
This commit is contained in:
Deadcode committed 2026-10-07 10:14:00 +02:00
1 parent e95d397288
commit d23c3e0d17
37 files changed
+1595 -147

No files matched your search

+32 -8
View File
@@ -577,6 +577,13 @@ int chat_format_grammar(const ChatFormat& f, const ChatGrammarRequest& req, Chat
const ojson& tools = req.tools ? *req.tools : none;
const bool has_tools = f.has_tools() && tools.is_array() && !tools.empty();
const bool has_rf = req.json_schema && req.json_schema->is_object() && !req.json_schema->empty();
if (req.require_call && (has_rf || !has_tools)) {
if (why)
*why = has_rf ? "a required tool call and a response format cannot both be the "
"whole reply"
: "a tool call is required, but there are no tools this format can call";
return RAD_E_INVAL;
}
if (!has_rf && !(has_tools && !f.triggers.empty())) return RAD_OK;
const std::string opener = f.call_open.empty() ? f.name_prefix : f.call_open;
@@ -598,12 +605,9 @@ int chat_format_grammar(const ChatFormat& f, const ChatGrammarRequest& req, Chat
b.resolve_refs(schema);
}
if (has_rf) {
/* The whole reply: what follows the generation prompt, the reasoning block, and
* the document, fenced or not. */
b.add_rule("response-format", b.add_schema("response-format-schema",
*req.json_schema));
add_json_rules(b);
/* A grammar that is the whole reply starts where the generation prompt does, so the
* prompt's assistant prefix and the reasoning block come first. */
auto whole_reply = [&]() {
std::string gp = req.generation_prompt;
if (f.has_reasoning() && !f.reasoning_open.empty()) {
const size_t at = gp.find(f.reasoning_open);
@@ -612,6 +616,15 @@ int chat_format_grammar(const ChatFormat& f, const ChatGrammarRequest& req, Chat
std::vector<G> root{ gp.empty() ? eps() : lit(gp), space() };
if (f.has_reasoning() && req.extract_reasoning) root.push_back(reasoning_expr(f, breaks));
root.push_back(space());
return root;
};
if (has_rf) {
/* The whole reply: what follows the generation prompt, the reasoning block, and
* the document, fenced or not. */
b.add_rule("response-format", b.add_schema("response-format-schema",
*req.json_schema));
add_json_rules(b);
std::vector<G> root = whole_reply();
root.push_back(alt({ seq({ lit("```json"), space(), rule_ref("response-format"), space(),
lit("```") }),
rule_ref("response-format") }));
@@ -630,6 +643,7 @@ int chat_format_grammar(const ChatFormat& f, const ChatGrammarRequest& req, Chat
continue;
const auto& fn = tool.at("function");
const std::string name = fn.at("name");
if (!req.only_tool.empty() && name != req.only_tool) continue;
auto params = fn.contains("parameters") ? fn.at("parameters") : ojson::object();
const auto properties = params.contains("properties") ? params.at("properties")
: ojson::object();
@@ -687,6 +701,8 @@ int chat_format_grammar(const ChatFormat& f, const ChatGrammarRequest& req, Chat
b.add_rule(rule_name("tool-" + name), render(func));
choices.push_back(rule_ref(rule_name("tool-" + name)));
}
if (choices.empty() && !req.only_tool.empty())
throw std::invalid_argument("no tool named \"" + req.only_tool + "\" to call");
if (typed) add_json_rules(b);
if (!choices.empty()) b.add_rule("until-suffix", until_pattern({ f.arg_value_suffix }));
@@ -704,13 +720,21 @@ int chat_format_grammar(const ChatFormat& f, const ChatGrammarRequest& req, Chat
: seq({ lit(""), space(), choice, space(), lit("") });
}
b.add_rule("tool-call", render(calls));
b.add_rule("root", "tool-call");
if (req.require_call) {
/* The calls and nothing after them: a complete grammar admits only the end of
* the turn, so the reply stops at the last call's closer. */
std::vector<G> root = whole_reply();
root.push_back(rule_ref("tool-call"));
b.add_rule("root", render(seq(std::move(root))));
} else {
b.add_rule("root", "tool-call");
}
});
} catch (const std::exception& e) {
if (why) *why = e.what();
return RAD_E_INVAL;
}
out->lazy = !has_rf;
out->lazy = !has_rf && !req.require_call;
if (out->lazy) out->trigger_words = f.triggers;
return RAD_OK;
}