Archived
radiance 1.7.0
- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves every shipped container - Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime - /v1/messages works with Claude Code as it ships (gearwave00001) - a long agent conversation keeps its cached history when the client rewrites its last turn (manueloverride) - a stream's first event goes out with the first token, so llama-benchy measures prefill right - opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42) - four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b) - NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA adapters (baKon) - many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool arguments and the CPU's vision and audio encoders - plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
This commit is contained in:
1 parent
b068190326
commit
1e968f6e1d
739 files changed
+128447
-84632
No files matched your search
Vendored
+29
-2
@@ -20,6 +20,8 @@
|
||||
#include <ctime>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
@@ -285,8 +287,33 @@ struct common_chat_templates {
|
||||
bool has_explicit_template; // Model had builtin template or template overridden was specified.
|
||||
std::unique_ptr<common_chat_template> template_default; // always set (defaults to chatml)
|
||||
std::unique_ptr<common_chat_template> template_tool_use;
|
||||
/* RADIANCE: the differential analysis of template_default ([0]) and template_tool_use ([1]),
|
||||
* made on first use (template_analysis). */
|
||||
mutable std::mutex analysis_lock;
|
||||
mutable std::shared_ptr<const autoparser::autoparser> analysis[2];
|
||||
};
|
||||
|
||||
/* RADIANCE: autoparser::analyze_template renders the template over synthetic messages and reads
|
||||
* nothing but the template, so one analysis serves every request rendered through it. One that
|
||||
* throws is not kept, and the next request analyses again and throws again. */
|
||||
static std::shared_ptr<const autoparser::autoparser> template_analysis(
|
||||
const common_chat_templates * tmpls, const common_chat_template & tmpl) {
|
||||
const size_t slot = &tmpl == tmpls->template_default.get() ? 0 : 1;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(tmpls->analysis_lock);
|
||||
if (tmpls->analysis[slot]) {
|
||||
return tmpls->analysis[slot];
|
||||
}
|
||||
}
|
||||
auto made = std::make_shared<autoparser::autoparser>();
|
||||
made->analyze_template(tmpl);
|
||||
std::lock_guard<std::mutex> lock(tmpls->analysis_lock);
|
||||
if (!tmpls->analysis[slot]) {
|
||||
tmpls->analysis[slot] = std::move(made);
|
||||
}
|
||||
return tmpls->analysis[slot];
|
||||
}
|
||||
|
||||
common_chat_tool_choice common_chat_tool_choice_parse_oaicompat(const std::string & tool_choice) {
|
||||
if (tool_choice == "auto") {
|
||||
return COMMON_CHAT_TOOL_CHOICE_AUTO;
|
||||
@@ -2465,8 +2492,8 @@ static common_chat_params common_chat_templates_apply_jinja(const struct common_
|
||||
|
||||
try {
|
||||
LOG_DBG("%s: using differential autoparser\n", __func__);
|
||||
struct autoparser::autoparser autoparser;
|
||||
autoparser.analyze_template(tmpl);
|
||||
const std::shared_ptr<const autoparser::autoparser> analysis = template_analysis(tmpls, tmpl);
|
||||
const autoparser::autoparser & autoparser = *analysis;
|
||||
auto auto_params = autoparser::peg_generator::generate_parser(tmpl, params, autoparser);
|
||||
|
||||
std::vector<common_chat_msg_delimiter> delimiters;
|
||||
|
||||
Vendored
+9
-1
@@ -606,7 +606,15 @@ static void gather_string_parts_recursive(const value & val, value_string & part
|
||||
} else if (is_val<value_array>(val)) {
|
||||
auto items = cast_val<value_array>(val)->as_array();
|
||||
for (const auto & item : items) {
|
||||
gather_string_parts_recursive(item, parts);
|
||||
/* RADIANCE: `val` is a block's statement results, and every block statement returns
|
||||
* a string, so a list or a dict among them is the value of an expression the template
|
||||
* prints. jinja2 prints its repr; flattening it ran its strings together and printed
|
||||
* nothing for a dict. */
|
||||
if (is_val<value_array>(item) || is_val<value_object>(item)) {
|
||||
parts->val_str.append(item->as_string().str());
|
||||
} else {
|
||||
gather_string_parts_recursive(item, parts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+28
-6
@@ -1496,13 +1496,35 @@ std::string value_to_json(const value & val, int indent, const std::string_view
|
||||
// TODO: avoid circular references
|
||||
std::string value_to_string_repr(const value & val) {
|
||||
if (is_val<value_string>(val)) {
|
||||
const std::string val_str = val->as_string().str();
|
||||
|
||||
if (val_str.find('\'') != std::string::npos) {
|
||||
return value_to_json(val);
|
||||
} else {
|
||||
return "'" + val_str + "'";
|
||||
/* RADIANCE: Python's str repr, which jinja2 prints for a string inside a list or a dict:
|
||||
* single quotes unless the text holds one and no double quote, and backslash escapes for
|
||||
* the backslash, the quote, \t \n \r and the other ASCII controls. Python also escapes
|
||||
* non-printable non-ASCII code points; those pass through here. */
|
||||
const std::string s = val->as_string().str();
|
||||
const char q = s.find('\'') != std::string::npos && s.find('"') == std::string::npos ? '"' : '\'';
|
||||
std::string out(1, q);
|
||||
for (const char ch : s) {
|
||||
const unsigned char c = (unsigned char) ch;
|
||||
if (ch == q || ch == '\\') {
|
||||
out += '\\';
|
||||
out += ch;
|
||||
} else if (ch == '\t') {
|
||||
out += "\\t";
|
||||
} else if (ch == '\n') {
|
||||
out += "\\n";
|
||||
} else if (ch == '\r') {
|
||||
out += "\\r";
|
||||
} else if (c < 0x20 || c == 0x7f) {
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
out += "\\x";
|
||||
out += hex[c >> 4];
|
||||
out += hex[c & 15];
|
||||
} else {
|
||||
out += ch;
|
||||
}
|
||||
}
|
||||
out += q;
|
||||
return out;
|
||||
} else {
|
||||
return val->as_repr();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user