merge 1.12.0: gemma4 E2B/E4B and Nemotron Bolt E4B arrive; the ref2va audio, rows and ABI work carried across

conv1d keeps both stride forms: upstream's causal codec downsample with cu_div (Fish Audio) and the port's explicit-pad non-causal one (the H3 audio encoder's), in libref, libavx and libr4d alike; the ABI takes upstream's 27 on top of the port's RadVideoGenBatch growth.
This commit is contained in:
gearwave00001 committed 2026-10-24 19:03:26 -05:00
commit 7c3b5ab7d5
285 files changed
+30500 -2898

No files matched your search

+36 -4
View File
@@ -35,6 +35,7 @@
#include <algorithm>
#include <atomic>
#include <chrono>
#include <iterator>
#include <memory>
@@ -107,6 +108,8 @@ inline SchedMetrics bridge_metrics(const rad::SchedMetrics& m) {
o.hit_cut_tokens = m.hit_cut_tokens;
o.prefix_expired = m.prefix_expired;
o.prefix_ckpt_expired = m.prefix_ckpt_expired;
o.prefix_released = m.prefix_released;
o.prefix_ckpt_released = m.prefix_ckpt_released;
o.prefill_tps = m.prefill_tps;
o.decode_tps = m.decode_tps;
@@ -202,6 +205,24 @@ public:
int64_t reset_prefix_cache() override { return s_->reset_prefix_cache(); }
int release_session(const std::string& label, uint64_t id, int64_t keep_tokens,
SessionReleased* out) override {
SessionRelease r;
const int rc = s_->release_session(label, id, keep_tokens, &r);
if (out) {
out->sessions = r.sessions;
out->entries = r.entries;
out->tokens = r.tokens;
out->device_bytes = r.device_bytes;
out->host_bytes = r.host_bytes;
out->snapshots = r.snapshots;
out->kept_tokens = r.kept_tokens;
out->kept_shared = r.kept_shared;
out->kept_live = r.kept_live;
}
return rc;
}
/* The stored conversations. The tiers keep monotonic timestamps; idle and age are converted
* to "seconds ago" here, so only the monotonic clock is authoritative. */
TierCounters tier_counters() const override {
@@ -708,10 +729,21 @@ public:
std::shared_ptr<mm::Item>* out, std::string* why) override {
if (!accepts(k)) { if (why) *why = "this kind of media is not served"; return RAD_E_UNSUPPORTED; }
if (k == MediaKind::Audio) return p_->audio(bytes.data(), bytes.size(), out, why);
return k == MediaKind::Image
? p_->image(bytes.data(), bytes.size(), opts.image_tokens, out, why,
opts.max_pixels)
: p_->video(bytes.data(), bytes.size(), out, why);
if (k == MediaKind::Video) return p_->video(bytes.data(), bytes.size(), out, why);
mm::ImageMode mode;
mode.kind = (int32_t)opts.image_mode;
mode.base_size = opts.image_base_size;
mode.image_size = opts.image_size;
mode.several = opts.several_pictures;
/* The host share of a picture (decode, resample, patch staging), apart from the tower
* pass engine_mm.cpp times. */
const auto t0 = std::chrono::steady_clock::now();
const int rc = p_->image(bytes.data(), bytes.size(), opts.image_tokens, out, why,
opts.max_pixels, mode);
RAD_DEBUG("mm: host processor %lld bytes -> %.1f ms (rc %d)", (long long)bytes.size(),
std::chrono::duration<double, std::milli>(
std::chrono::steady_clock::now() - t0).count(), rc);
return rc;
}
int encoder_image(const uint8_t* bytes, size_t n, int32_t ratio, int32_t max_side,
+143 -18
View File
@@ -11,11 +11,18 @@
* `guidance_scale` (the model's guidance: the denoiser's for a music model, the frame model's for
* a speech one) and, for a model with a denoiser, `num_inference_steps`.
*
* References, for a model that clones a voice (RadAudioGenDecl::tmpl_ref): `references` is an
* array of {"audio", "text"}, a clip of the voice (a data: URL or the base64 of an audio file,
* decoded to mono at the model's rate and padded to whole frames) and what it says; at most the
* model's count of them and seconds together. The prompt is then the references' template, each
* reference rendered from the model's item, its transcript and a row a frame of its clip.
*
* Prompt: the plugin's template with its slots filled, each text first rewritten by the plugin
* into the form the model was trained on (rad_arch_text_prepare). The template is tokenised with
* its special tokens and the texts without, so a caller cannot write the model's control tokens
* into a lyric. A model that declares the unconditional branch's own template gets that one
* rendered from the same texts.
* into a lyric; a model that declares `input_special` has its input tokenised with them too (its
* speaker tags), its prepare() refusing the control tokens. A model that declares the
* unconditional branch's own template gets that one rendered from the same texts.
*
* Response: the whole piece, once it is finished, as `response_format` wav (16-bit PCM, the
* model's rate and channels) or pcm (the same samples raw, little-endian). Streamed as the
@@ -29,6 +36,7 @@
#include "oai.h"
#include "gen/audio.h"
#include "mm/media.h"
#include "rad_internal.h"
#include <nlohmann/json.hpp>
@@ -109,6 +117,9 @@ int Server::speech_request(const json& body, const std::string& text,
return fail(err_bad("instructions", "this model needs instructions, as a non-empty "
"string: for a song its genre, mood, vocals and "
"instruments"));
if (!inst.empty() && info.tmpl.empty())
return fail(err_unsupported("instructions", "this model takes no instructions; its "
"direction is written in the input"));
if (body.contains("speed") && !body["speed"].is_null() &&
!(body["speed"].is_number() && body["speed"].get<double>() == 1.0))
return fail(err_unsupported("speed", "this model keeps its own tempo; the instructions "
@@ -156,6 +167,8 @@ int Server::speech_request(const json& body, const std::string& text,
if (!body["guidance_scale"].is_number() || !(body["guidance_scale"].get<double>() >= 1.0) ||
body["guidance_scale"].get<double>() > 30.0)
return fail(err_bad("guidance_scale", "expected a number in [1, 30]"));
if (info.branches == 1 && body["guidance_scale"].get<double>() != 1.0)
return fail(err_unsupported("guidance_scale", "this model runs without guidance"));
r->cfg = (float)body["guidance_scale"].get<double>();
}
bool seed_given = false;
@@ -170,33 +183,141 @@ int Server::speech_request(const json& body, const std::string& text,
r->seed = (((uint64_t)rd() << 32) ^ rd()) & (((uint64_t)1 << 53) - 1);
}
/* ---- the references: a clip of a voice and what it says, each */
struct Ref { std::string text; int64_t frames = 0; };
std::vector<Ref> refs;
if (body.contains("references") && !body["references"].is_null()) {
const json& rs = body["references"];
if (!rs.is_array())
return fail(err_bad("references", "expected an array of {\"audio\", \"text\"}"));
if (!rs.empty() && info.tmpl_ref.empty())
return fail(err_unsupported("references", "this model takes no reference audio; its "
"voice is described in the input"));
if ((int64_t)rs.size() > info.ref_max)
return fail(err_bad("references", "at most " + std::to_string(info.ref_max) +
" references a request"));
const int64_t hop = std::max<int64_t>(1, info.ref_hop);
r->ref_cu.assign(1, 0);
for (size_t i = 0; i < rs.size(); ++i) {
const std::string at = "references[" + std::to_string(i) + "]";
const json& e = rs[i];
if (!e.is_object())
return fail(err_bad(at, "expected an object {\"audio\", \"text\"}"));
for (auto it = e.begin(); it != e.end(); ++it)
if (it.key() != "audio" && it.key() != "text")
return fail(err_bad(at + "." + it.key(), "a reference is its audio and its "
"text"));
if (!e.contains("audio") || !e["audio"].is_string())
return fail(err_bad(at + ".audio", "the clip is required, as a data: URL or "
"base64 of an audio file"));
if (!e.contains("text") || !e["text"].is_string() || blank(e["text"].get<std::string>()))
return fail(err_bad(at + ".text", "the clip's transcript is required, as a "
"non-empty string"));
/* The file: a data: URL, or its base64 alone (as fish-speech's server takes it). */
const std::string& a = e["audio"].get_ref<const std::string&>();
std::vector<uint8_t> bytes;
if (a.rfind("data:", 0) == 0) {
ApiError ue;
if (decode_media_url(a, at + ".audio", &bytes, &ue) < 0) return fail(ue);
} else if (!base64_decode(a, &bytes)) {
return fail(err_bad(at + ".audio", "invalid base64"));
}
/* Mono at the model's rate; one sample past what is left of the budget is decoded,
* so a clip too long is refused rather than cut. */
const int64_t left = info.ref_max_samples - (int64_t)r->ref_audio.size();
std::vector<float> pcm;
std::string dwhy;
if (left < hop)
return fail(err_bad(at + ".audio", "the references are longer than this model "
"takes"));
if (mm::decode_audio(bytes.data(), bytes.size(), (int32_t)info.ref_rate, left + 1,
&pcm, &dwhy) < 0)
return fail(err_bad(at + ".audio", "the clip could not be used: " + dwhy));
if (pcm.empty()) return fail(err_bad(at + ".audio", "the clip holds no audio"));
const int64_t padded = ((int64_t)pcm.size() + hop - 1) / hop * hop;
if (padded > left)
return fail(err_bad(at + ".audio", "the references hold more than " +
rad::fmt("%g", (double)info.ref_max_samples /
(double)info.ref_rate) +
" seconds together; this model takes no "
"more"));
pcm.resize((size_t)padded, 0.0f);
r->ref_audio.insert(r->ref_audio.end(), pcm.begin(), pcm.end());
r->ref_cu.push_back((int32_t)r->ref_audio.size());
Ref ref;
std::string why;
if (deps_.audio->prepare(RAD_TEXT_REFERENCE, e["text"].get<std::string>(), &ref.text,
&why) < 0)
return fail(err_bad(at + ".text", why));
ref.frames = padded / hop;
refs.push_back(std::move(ref));
}
if (refs.empty()) r->ref_cu.clear();
}
if (!refs.empty() && !inst.empty())
return fail(err_unsupported("instructions", "a request with references takes no "
"instructions; the clips set the voice"));
/* ---- the prompt */
std::string i2, t2, why;
if (!inst.empty() && deps_.audio->prepare(RAD_TEXT_INSTRUCTIONS, inst, &i2, &why) < 0)
return fail(err_bad("instructions", why));
if (deps_.audio->prepare(RAD_TEXT_INPUT, text, &t2, &why) < 0)
return fail(err_bad("input", why));
auto encode = [&](const std::string& t, bool special, std::vector<int32_t>* ids_out) {
if (t.empty()) return;
const auto ids = deps_.tok->encode(t, false, /*parse_special=*/special);
ids_out->insert(ids_out->end(), ids.begin(), ids.end());
};
auto subst = [](std::string t, const std::string& key, const std::string& v) {
for (size_t p = t.find(key); p != std::string::npos; p = t.find(key, p + v.size()))
t.replace(p, key.size(), v);
return t;
};
/* One reference (ref_item): its header, the transcript in it, tokenised as one segment with
* its special tokens (the speaker tags prepare() allows), a row a frame of its clip, and what
* follows the clip as another segment. */
int64_t frame0 = 0;
auto render_ref = [&](size_t i, std::vector<int32_t>* ids_out) {
static const std::string kAudio = "{audio}";
const std::string idx = std::to_string(i + 1);
const size_t a = info.ref_item.find(kAudio);
encode(subst(subst(info.ref_item.substr(0, a), "{index}", idx), "{text}", refs[i].text),
true, ids_out);
r->ref_frame.resize(ids_out->size(), -1);
for (int64_t f = 0; f < refs[i].frames; ++f) {
ids_out->push_back(0);
r->ref_frame.push_back((int32_t)(frame0 + f));
}
frame0 += refs[i].frames;
encode(subst(info.ref_item.substr(a + kAudio.size()), "{index}", idx), true, ids_out);
};
/* A template a segment at a time: its own text with special tokens, each slot without. */
auto render = [&](const std::string& t, std::vector<int32_t>* ids_out) {
static const std::string kInst = "{instructions}", kInput = "{input}";
static const std::string kInst = "{instructions}", kInput = "{input}",
kRefs = "{references}";
size_t at = 0;
while (at <= t.size()) {
const size_t a = t.find(kInst, at), b = t.find(kInput, at);
const size_t p = std::min(a, b);
const std::string lit =
t.substr(at, p == std::string::npos ? std::string::npos : p - at);
if (!lit.empty()) {
const auto ids = deps_.tok->encode(lit, false, /*parse_special=*/true);
ids_out->insert(ids_out->end(), ids.begin(), ids.end());
}
const size_t a = t.find(kInst, at), b = t.find(kInput, at), c = t.find(kRefs, at);
const size_t p = std::min(a, std::min(b, c));
encode(t.substr(at, p == std::string::npos ? std::string::npos : p - at), true,
ids_out);
if (p == std::string::npos) break;
if (p == c) {
for (size_t i = 0; i < refs.size(); ++i) render_ref(i, ids_out);
at = p + kRefs.size();
continue;
}
const bool is_inst = p == a;
const auto ids = deps_.tok->encode(is_inst ? i2 : t2, false, /*parse_special=*/false);
ids_out->insert(ids_out->end(), ids.begin(), ids.end());
/* The input keeps its special tokens only for a model that asks (its speaker tags);
* the plugin's prepare() has refused the ones a caller may not write. */
encode(is_inst ? i2 : t2, !is_inst && info.input_special, ids_out);
at = p + (is_inst ? kInst : kInput).size();
}
};
render(inst.empty() ? info.tmpl_plain : info.tmpl, &r->tokens);
render(!refs.empty() ? info.tmpl_ref : inst.empty() ? info.tmpl_plain : info.tmpl,
&r->tokens);
if (!refs.empty()) r->ref_frame.resize(r->tokens.size(), -1);
if (!info.neg_tmpl.empty()) render(info.neg_tmpl, &r->neg_tokens);
const size_t n_prompt = std::max(r->tokens.size(), r->neg_tokens.size());
if ((int64_t)n_prompt > info.max_prompt)
@@ -225,7 +346,7 @@ HttpResponse Server::handle_speech(const HttpRequest& req) {
static const char* kKnown[] = {
"model", "input", "instructions", "voice", "response_format", "speed", "stream",
"stream_format", "seed", "max_new_tokens", "duration", "num_inference_steps",
"guidance_scale", "user",
"guidance_scale", "user", "references",
};
for (auto it = body.begin(); it != body.end(); ++it) {
bool known = false;
@@ -339,9 +460,13 @@ HttpResponse Server::handle_speech(const HttpRequest& req) {
std::string pcm;
for (const gen::AudioChunk& c : chunks) append_pcm16(c.samples, &pcm);
const double secs = (double)pcm.size() / 2.0 / (double)(info.channels * info.sample_rate);
RAD_INFO("audio: %.1f s from %lld frames in %lld windows, %.1f s%s", secs,
(long long)ticket->frames, (long long)ticket->windows,
(double)(ticket->t_done_ns - ticket->t_submit_ns) * 1e-9,
auto sec = [](int64_t a, int64_t b) { return a > 0 && b >= a ? (double)(b - a) * 1e-9 : 0.0; };
RAD_INFO("audio: %.1f s from %lld frames in %lld windows, %.1f s: queue and prompt %.1f s, "
"first audio %.1f s, frames %.1f s%s", secs, (long long)ticket->frames,
(long long)ticket->windows, sec(ticket->t_submit_ns, ticket->t_done_ns),
sec(ticket->t_submit_ns, ticket->t_prompt_ns),
sec(ticket->t_submit_ns, ticket->t_first_audio_ns),
sec(ticket->t_prompt_ns, ticket->t_frames_ns),
ticket->model_ended ? "" : " (the request's length)");
HttpResponse res;
res.status = 200;
+178 -183
View File
@@ -55,6 +55,18 @@ HttpResponse Server::handle_control_vector(const HttpRequest& req) {
}
if (req.method == "POST") {
/* The default applies to every client's requests that name no choice, so a server
* started without --api-key takes the change from a loopback client only, as it does a
* runtime adapter load. */
if (opt_.api_key.empty() && !req.peer_is_loopback()) {
ApiError e;
e.status = 403;
e.type = "permission_error";
e.message = "without --api-key, the control-vector default is changed only from a "
"loopback client; start the server with --api-key to change it from "
"elsewhere";
return error_response(e, req.peer);
}
json body;
try {
body = json::parse(req.body.empty() ? "{}" : req.body);
@@ -138,6 +150,8 @@ HttpResponse Server::handle_sessions(const HttpRequest&) {
o["snapshot_store"] = { { "bytes_each", c.ck_bytes }, { "slots", c.ck_slots } };
/* Entries and snapshots removed by --prefix-cache-ttl, from whichever tier held them. */
o["expired"] = { { "entries", sm.prefix_expired }, { "snapshots", sm.prefix_ckpt_expired } };
/* And the ones a client gave up on purpose (DELETE /sessions). */
o["released"] = { { "entries", sm.prefix_released }, { "snapshots", sm.prefix_ckpt_released } };
/* Step-thread time spent on tier moves; every request waits through it. */
o["stall"] = { { "restores", c.restores }, { "restore_ms", (double)c.restore_ns / 1e6 },
{ "flushes", c.flushes }, { "flush_ms", (double)c.flush_ns / 1e6 } };
@@ -167,6 +181,83 @@ HttpResponse Server::handle_sessions(const HttpRequest&) {
return HttpResponse::json_body(200, json_dump(o));
}
/* ------------------------------------------------------------------ DELETE /sessions
*
* A client that deletes a conversation, or replaces everything past a prefix of it, knows the
* rest is dead before the TTL does. Named by the label it sent (`session_id`, or Anthropic's
* `metadata.user_id`), or by the engine id `/sessions` shows. `keep_tokens` keeps the chain's
* start. Shared blocks and blocks a live request reads stay; a request of the same conversation
* in flight is a 409, since its close would publish the chain again. */
HttpResponse Server::handle_session_release(const HttpRequest& req) {
if (!deps_.sched)
return error_response(err_not_implemented("the server has no engine attached"), req.peer);
const std::string label = req.param("label");
uint64_t id = 0;
const std::string id_s = req.param("id");
if (!id_s.empty()) {
if (id_s.find_first_not_of("0123456789") != std::string::npos || id_s.size() > 19)
return error_response(err_bad("id", "expected the session's engine id, a decimal "
"integer as /sessions reports it"), req.peer);
id = std::stoull(id_s);
if (id == 0) return error_response(err_bad("id", "0 names no session"), req.peer);
}
if (label.empty() && id == 0)
return error_response(err_bad("label", "name the session: DELETE /sessions/<label>, "
"?label=<label> or ?id=<engine id>"), req.peer);
int64_t keep_tokens = 0;
const std::string keep_s = req.param("keep_tokens");
if (!keep_s.empty()) {
if (keep_s.find_first_not_of("0123456789") != std::string::npos || keep_s.size() > 12)
return error_response(err_bad("keep_tokens", "expected a non-negative integer: the "
"prefix to keep, in tokens"), req.peer);
keep_tokens = std::stoll(keep_s);
}
SessionReleased r;
const int rc = deps_.sched->release_session(label, id, keep_tokens, &r);
if (rc == RAD_E_UNSUPPORTED)
return error_response(err_not_implemented(
"this engine has no prefix cache (started with --no-prefix-cache, or the model "
"declares no cacheable KV group)"), req.peer);
const std::string who = label.empty() ? "id " + std::to_string(id) : "'" + label + "'";
if (rc == RAD_E_NOTFOUND) {
ApiError e;
e.status = 404;
e.type = "not_found_error";
e.param = label.empty() ? "id" : "label";
e.message = "no stored session " + who + "; GET /sessions lists them";
return error_response(e, req.peer);
}
if (rc == RAD_E_STATE) {
ApiError e;
e.status = 409;
e.type = "conflict_error";
e.code = "session_in_use";
e.message = "a request of session " + who + " is queued or running; cancel it or wait "
"for it to finish, then release again";
return error_response(e, req.peer);
}
if (rc == RAD_E_INVAL)
return error_response(err_bad("keep_tokens", rad_strerror(rc)), req.peer);
if (rc < 0) return error_response(err_internal(rad_strerror(rc)), req.peer);
json o;
if (!label.empty()) o["label"] = label;
if (id != 0) o["id"] = id;
o["keep_tokens"] = keep_tokens;
o["sessions"] = r.sessions;
o["entries"] = r.entries;
o["tokens"] = r.tokens;
o["device_bytes"] = r.device_bytes;
o["host_bytes"] = r.host_bytes;
o["snapshots"] = r.snapshots;
o["kept"] = { { "tokens", r.kept_tokens }, { "shared", r.kept_shared },
{ "live", r.kept_live } };
metrics_.observe_http(200);
return HttpResponse::json_body(200, json_dump(o));
}
HttpResponse Server::handle_stats(const HttpRequest&) {
json o;
o["model"] = opt_.model_id;
@@ -222,6 +313,8 @@ HttpResponse Server::handle_stats(const HttpRequest&) {
o["ckpt_evictions"] = { { "retention", m.prefix_ckpt_retired },
{ "store_full", m.prefix_ckpt_lru } };
o["ckpt_refused"] = m.prefix_ckpt_refused;
o["released"] = { { "entries", m.prefix_released },
{ "snapshots", m.prefix_ckpt_released } };
o["hit_cuts"] = { { "no_snapshot", m.hit_cut_no_snapshot },
{ "windowed_group", m.hit_cut_window },
{ "adopt_failed", m.hit_cut_adopt },
@@ -568,16 +661,10 @@ h1 { margin:0; font-size:13.5px; font-weight:600; letter-spacing:-.005em; }
.stack { display:grid; gap:14px; }
@media (max-width:1000px) {
.body { grid-template-columns:minmax(0,1fr); }
/* On a phone the page is one column you drag with your thumb. A nested scroller that
* refuses to chain (overscroll-behavior:contain, set for the desktop wheel so a scroll
* over the request table does not move the page behind it) traps the drag here: you
* scroll the card, it bottoms out, and the page will not follow, so you reach for the
* margins where no scroller lives to get the page moving again. On narrow screens let
* the scroll chain to the document; the desktop containment stays.
* .body .hold, not .hold: the base .hold rule is defined LATER in this file, so a bare
* .hold override here would match and still LOSE the cascade (equal specificity, later
* wins) -- judge slice 31 caught exactly that dead-code trap, and the operator's thumb
* confirmed it on the request table. .body .hold wins on specificity regardless of order. */
/* In one column a nested scroller with overscroll-behavior:contain (there so a desktop wheel
* over the request table does not move the page) traps a touch drag once it bottoms out, so
* narrow screens let the scroll chain to the document. `.body .hold` rather than `.hold`: the
* base .hold rule comes later in this sheet and would win at equal specificity. */
.body .panel > .pbody, .body .hold { overscroll-behavior:auto; }
}
@@ -1488,66 +1575,31 @@ function setMetric(key, value, text) {
spark(key, hist[key]);
}
/* BEST / RECENT / NOW ON THE OTHER FOUR TILES, in the shape the decode step established.
*
* WHAT THESE ARE NOT: engine figures. The engine publishes a floor and a recent window for the
* decode step alone (step_ns_decode_best / _recent); for tok/s, requests in flight and acceptance
* it publishes ONE figure per poll and nothing older. So these three figures are page-side, and
* they mean:
* best / highest - the extreme this page session has seen AT THE CURRENT CONCURRENCY.
* Resets on reload, not on restart.
* recent - the mean over the last 15 s at that concurrency; 5 s on prefill, whose
* events are shorter than the window that would fit them. Shorter
* than the sparkline on purpose:
* a 60 s mean still read 31 tok/s fifty seconds after the lane went
* quiet, which is the lane being remembered rather than measured.
/* Best / recent / now on the decode, prefill, in-flight and acceptance tiles. The engine
* publishes a floor and a recent window only for the decode step; for these it publishes one
* figure per poll, so the three figures are the page's own:
* best / highest - the extreme this page has seen at the current concurrency; it resets on
* reload, not on a server restart. "highest" where more is not better.
* recent - the mean of the last RECENT samples at that concurrency.
* now - the current value as a percentage of that extreme.
* "highest" rather than "best" on the two tiles where more is not better: a lane at its highest
* request count is busy, not good. The word carries a direction the number alone does not.
* Figures are kept per concurrency ("@cN" past one), because a batched rate read against the
* single-stream best reports a batch arriving as a level change. Requests in flight keeps one
* bucket, since its value is the concurrency, and it samples idle polls too. Idle polls record
* nothing in a concurrency bucket, and the line keeps the last active concurrency's figures
* without a now clause. There is no ~99 cap as on the decode step: the extreme comes from the
* same series as `now`, so 100% is exact.
*
* PER-CONCURRENCY BUCKETS, the decode step's structure: a c8 rate read against the
* single-stream best reports the batch arriving as a level change -- the mistake that took
* the old drift line out. Every figure on the line describes the current concurrency, and
* past c1 the line says so ("@c8"). Requests in flight is the exception: its value IS the
* concurrency, so bucketing it by concurrency would pin "highest" to the current number
* forever -- it keeps one session-wide bucket. While the lane is idle nothing new is
* recorded and the line keeps the last active concurrency's figures: frozen, no now clause,
* which is what the Decode Step tile does at idle.
*
* NO ~99 CAP HERE, unlike the decode step. That cap exists because `now` there is a 500 ms poll
* mean measured against a 32-step window mean -- different instruments, so a fast stretch can read
* faster than the floor without being one. Here the extreme is computed FROM the same series as
* `now`, so exceeding it is arithmetically impossible and 100% is exact: you are at your best.
*/
/* RECENT'S OWN WINDOW, deliberately shorter than the sparkline's. HIST is 60 s and that is right
* for a picture -- a sparkline wants the whole minute to show shape. It is wrong for a number:
* measured over real traffic (two 5 s bursts inside a quiet minute), a 60 s mean still read 31.7
* tok/s fifty seconds after the lane went quiet, and 30 s only brought that to 26.9. Fifteen
* seconds decays to zero within a quarter-minute of silence while still tracking the running mean
* mid-burst (52.8 against an actual 53.3). Ten and five overshoot -- 79 and 144 against that same
* 53 -- which is the current value wearing a different name, and the big number above already is
* that. `best`/`highest` stay full-session: an extreme wants every chance to be broken.
* Idle polls do not enter an active bucket -- the lane is not at that concurrency while it
* sleeps -- but they DO count in requests in flight's window, whose value is meaningful
* while nothing runs.
*
* PREFILL GETS ITS OWN WINDOW (RECENT_PREFILL, 5 s). Measured: small prompts prefill in 1.5-6 s
* above 100 tok/s; the operator's compaction reload -- the big one -- runs 7-15 s by his own
* count. A 15 s mean cannot report a 7 s event while it is running: it reaches barely half the
* peak by the event's end, then spends a quarter-minute averaging it down. Five seconds is
* shorter than the shortest event, so `recent` rides the prefill while it happens instead of
* diluting it. The engine's own figure is already a windowed rate (its help text: "over the
* scheduler's recent window"), so this window sits on top of the engine's smoothing -- it
* decides how long the page remembers, not how sharply the engine measures. */
const RECENT = 30; /* 15 s at the 500 ms poll WHILE the quantity keeps updating; a quantity
that skips polls (acceptance, which only samples when it drafts) spans
30 UPDATES, which under sparse drafting is minutes, not 15 s. */
const RECENT_PREFILL = 10; /* 5 s: shorter than the shortest prefill event (see above) */
* RECENT is shorter than the sparkline's 60 s: a 60 s mean still shows a burst long after the lane
* went quiet, and 15 s decays within a quarter-minute while still tracking the mean mid-burst.
* Prefill's window is 5 s, so `recent` follows a prefill of several seconds while it runs instead
* of diluting it; the engine's prefill rate is itself already windowed. */
const RECENT = 30; /* 15 s at the 500 ms poll for a figure sampled every poll; acceptance is
sampled only on polls that drafted, so its 30 samples can span minutes */
const RECENT_PREFILL = 10; /* 5 s */
const extAt = {}, winAt = {};
let lastActiveC = 0;
/* `win` false records the extreme only. Acceptance keeps its own pooled ring (accPool) and
* reads `highest` from extAt, so a window here would be a second, never-read copy of the
* same samples -- dead weight that a reviewer reasonably reads as a second figure. */
/* `win` false records the extreme only: acceptance pools its window in accPool and reads only
* `highest` from extAt. */
function noteSample(key, c, value, cap, win) {
if (value == null || !finite(value)) return;
const e = extAt[key] || (extAt[key] = {});
@@ -1558,12 +1610,11 @@ function noteSample(key, c, value, cap, win) {
s.push(value); if (s.length > (cap || RECENT)) s.shift();
}
function triple(key, c, label, fmt, showNow) {
/* RECENT IS A WINDOW MEAN, not a window maximum -- a maximum would sit equal to `best` on
* any steady lane, and two figures that always agree read as a broken instrument. */
/* `recent` is a window mean: a window maximum would equal `best` on any steady lane. */
const e = extAt[key];
if (!e || !(c in e)) return "";
/* A bucket whose extreme is zero still has a story -- requests in flight has seen nothing yet --
* so it renders. Only the `now` clause needs a nonzero extreme to divide by. */
/* A bucket whose extreme is zero still renders (requests in flight before the first request);
* only the `now` clause needs a nonzero extreme to divide by. */
const s = winAt[key][c];
let sum = 0;
for (const v of s) sum += v;
@@ -1571,14 +1622,13 @@ function triple(key, c, label, fmt, showNow) {
const now = s[s.length - 1];
const tag = typeof c === "number" && c > 1 ? "@c" + c : "";
let out = label + " " + fmt(e[c]) + " · recent " + fmt(recent);
/* THE SAME GUARD THE DECODE STEP USES: no `now` clause while nothing is running. A rate of
* zero is the lane being idle, not the lane being slow, and "now 0% of best" reads as a
* fault. The "@cN" tag rides the tail, exactly where the decode step puts it. */
/* No `now` clause while nothing runs, as on the decode step: a zero rate is an idle lane, and
* "now 0% of best" would read as a fault. */
if (showNow !== false && e[c] > 0) out += " · now " + Math.round(100 * now / e[c]) + "% of " + label + tag;
return out;
}
/* The acceptance tile's detail line: highest stays the full-session extreme of window ratios
* (an extreme is an extreme), but recent and now are POOLED ratios of sums (see above). */
/* The acceptance tile's detail line. `highest` is the session's extreme of per-poll ratios;
* `recent` is a pooled ratio of sums over the ring (accWindow) and `now` the newest poll's. */
function acceptTriple(c, showNow) {
const e = extAt["accept"];
const ring = accPool[c];
@@ -1594,26 +1644,20 @@ function acceptTriple(c, showNow) {
return out;
}
/* WINDOWED ACCEPTANCE. The engine's figure is cumulative and exact -- tot_accepted_/tot_drafted_
* over the life of the process -- so a best/recent/now line built on it would print the same
* number three times and call it a trend. The per-position counters the acceptance chart already
* reads are cumulative too, and the DIFFERENCE between two polls is exact acceptance over that
* interval, which is the only figure a detail line can move on. Each sample is one poll's delta
* (~500 ms, and only when it drafted); `recent` POOLS the last RECENT such deltas AT THAT
* CONCURRENCY and `now` is the newest one -- different windows, free to disagree.
* The counters go backwards when the engine restarts; that poll resets the window rather than
* reporting a negative draft. */
/* Acceptance over a window. The engine's draft_accept is accepted / drafted over the life of
* the process, so it barely moves on a long-running server. The per-position counters are
* cumulative too, and their difference between two polls is the exact conditional acceptance
* (accepted / reached) over that interval. Each ring entry is one poll that drafted; the ring is
* kept per concurrency and pooled as sum(accepted) / sum(reached), because polls carry unequal
* draft counts and a mean of their ratios would weigh a quiet poll like a busy one. */
const accPool = {}; /* per concurrency: ring of {dr, da} for the pooled tile window */
let accPrev = null, accUp = -1;
function accWindow(s) {
let reach = 0, hit = 0;
for (const p of (s.draft_positions || [])) { reach += p.reached || 0; hit += p.accepted || 0; }
/* RESTART DETECTION (2026-10-20, Turnstone audit). Counters going BACKWARDS catches a restart
* the page was watching. uptime_s going backwards catches the one it missed: a backgrounded
* tab whose accPrev froze while a new process drafted past the old process's lifetime total,
* where the delta is positive and the first guard never fires. Either clears every pooled
* ring -- a pre-restart pair must not pool with a post-restart one -- and yields no delta,
* so the headline reads the idle 0 rather than a dead process's ratio. */
/* A server restart: the counters go backwards, or, for a hidden tab that stopped polling while
* a new process drafted past the old totals, uptime_s does. Either clears every ring, so counts
* from two processes never pool, and yields no delta for this poll. */
const up = s.uptime_s;
const restart = accPrev !== null && (reach < accPrev.r || hit < accPrev.a ||
(typeof up === "number" && up < accUp));
@@ -1674,13 +1718,9 @@ function kvPanel(host, keys) {
return out;
}
const totals = kvPanel($("totals"), ["Requests", "Steps"]);
/* "Accepted of drafted" is the LIFETIME MARGINAL ratio -- the engine's figure, unchanged, and
* the one this panel used to carry as its headline. A bullet now rather than the big number:
* see the note at the accept tile. It divides by every token DRAFTED, so it is not comparable
* with the live figure above it, which divides by the positions actually REACHED; the two bases
* are worked through in README.md, section "Draft acceptance", and both are derivable from the
* log. Each label names its own denominator, which is the whole distinction -- so neither needs
* a tooltip, and a tooltip would be invisible on the phone anyway. */
/* "Accepted of drafted" is the engine's lifetime draft_accept, accepted / drafted. The panel's
* big figure divides by the positions reached instead, so the two are not comparable; each label
* names its denominator (docs/GUIDE.md, section 6.1). */
const spec = kvPanel($("spec"), ["Drafter", "Depth", "Accepted of drafted"]);
/* ---------------------------------------------------------------- meters */
@@ -1915,7 +1955,7 @@ function renderRequests(list, poolTokens) {
/* ---------------------------------------------------------------- update */
let prev = null, prevAt = 0, bars = [], devs = [], layerBars = [];
let lastStepMs = null; /* lastTps retired with the per-step freeze (slice 26) */
let lastStepMs = null;
/* The single-stream floor and the engine's most recent window, shown as two numbers with no
* verdict. The engine records the fastest single-sequence decode window it has measured
@@ -1937,13 +1977,9 @@ function update(s, dt) {
* mixed load the answer is the mean of two populations. `step_ns_decode / steps_decode` is
* neither -- it is what a decode step cost.
*
* A window with no decode steps in it reads 0, not the last reading (operator ruling
* 2026-10-20, second pass): every other live figure on this page shows 0 when the lane is idle
* -- tps() renders 0 as "0" and the engine publishes 0 rates -- so 0 IS the idle signal here,
* and the dash stays reserved for a quantity that has no value at all. A held value was the
* original sin (a stale number wearing a current name); a dash was an over-correction that
* broke the convention. The floor and the engine's recent window below are the engine's own
* figures and stay put. */
* A window with no decode steps reads 0, the page's idle figure for every live value; a dash
* is kept for a quantity that has no value at all, and a held value would present a stale
* reading as current. The engine's floor and recent window below keep their values. */
const dSteps = prev ? s.steps_decode - prev.steps_decode : 0;
const stepMs = dSteps > 0 ? (s.step_ns_decode - prev.step_ns_decode) / 1e6 / dSteps : null;
if (stepMs != null) lastStepMs = stepMs;
@@ -1967,10 +2003,8 @@ function update(s, dt) {
* ~500 ms poll mean and `best` a 32-step window mean, so a short fast stretch can beat the
* floor; the figure is capped at 99 and shown as ~99, "at the best", rather than claiming a
* record the window cannot confirm. */
/* Gated on this window HAVING decode steps, not on the lane being busy: during a
* prefill-only stretch the lane is busy, lastStepMs holds the last DECODE poll, and the
* headline correctly reads 0 -- printing "now X% of best" under it would put a stale
* value under the word "now", the exact defect the idle-0 ruling exists to kill. */
/* Only for a window with decode steps in it: during a prefill-only stretch the headline reads
* 0 and lastStepMs is an older poll's, which `now` must not show. */
if (stepMs != null && s.running > 0) {
const k = s.running;
if (!(k in bestAt) || lastStepMs < bestAt[k]) bestAt[k] = lastStepMs;
@@ -2022,41 +2056,22 @@ function update(s, dt) {
const aw = accWindow(s);
const awR = aw ? aw.ratio : null;
if (awR != null) noteSample("accept", s.running > 0 ? s.running : lastActiveC, awR, null, false);
/* POOLED ACCEPTANCE WINDOW (2026-10-20, math audit before the production roll).
* triple()'s `recent` averages the per-poll RATIOS; polls carry unequal draft counts, so a
* quiet poll and a 500-draft poll would weigh the same -- a mean of ratios, not a ratio of
* sums. Measured on a live c8 burst: avg-of-ratios 65.7% vs pooled 54.7%, a 11-point skew
* that grows with burstiness. The honest window figure is sum(accepted)/sum(reached) over
* the same span, so the tile keeps its own ring of delta pairs per concurrency. */
/* The pooled ring (see accWindow), per concurrency. */
if (aw != null && aw.dr > 0) {
const c = s.running > 0 ? s.running : lastActiveC;
const ring = accPool[c] || (accPool[c] = []);
ring.push(aw); if (ring.length > RECENT) ring.shift();
}
/* THE HEADLINE IS THE LIVE WINDOW, not the cumulative ratio. The engine's figure is exact but
* cumulative, so on a process that has been up for hours it cannot move: 559 fresh drafts moved
* it one point against a 33,000-draft denominator, and it froze outright the moment the lane
* went quiet. Every other tile's big number is the current value, and feeding the cumulative one
* here also fed the sparkline a quantity that is flat by construction.
* Polls with no new drafts read 0 (operator ruling 2026-10-20, second pass): the page's
* convention is that a live figure shows 0 when the lane is doing nothing, and the dash is for
* quantities with no value at all. The original freeze was the real defect -- a held value
* reads as a live measurement of a lane that drafted nothing. The lifetime ratio stays on
* /stats and /metrics; what the tile answers is "what is it accepting now", and now, idle,
* it is accepting nothing.
* THE SPARKLINE'S SCALE IS THE SAME as the other tiles -- 120 samples at the 500 ms poll, 60 s
* -- because setMetric samples every poll, idle polls included (0 is a value; see above). The
* one difference is the dash case: with no draft head there is no value to push, so those polls
* leave a gap and the line stretches over more wall-clock than 60 s. (Judge slice 4C: this
* comment claimed a 10 s window, then a drafting-only window; neither sampling scheme exists.) */
/* The headline is this poll's conditional acceptance, as every other tile's big number is the
* current value; the lifetime ratio stays in the Speculation panel, on /stats and on /metrics.
* A poll that drafted nothing reads 0, the page's idle figure, and the dash means there is no
* draft head. The sparkline takes a sample every poll, idle ones included, like the other
* tiles; without a draft head it takes none. */
if (!(s.draft_positions && s.draft_positions.length)) setMetric("accept", null, DASH);
else if (awR != null) setMetric("accept", 100 * awR, pctn(awR, 0));
else setMetric("accept", 0, pctn(0, 0)); /* drafted nothing this poll -> 0, the idle figure */
/* `now` is shown only when THIS poll drafted. The guard inside acceptTriple (last.dr > 0)
* cannot ever be false -- the ring only stores deltas with dr > 0 -- so the freshness test
* belongs here, where the poll's own delta is known. Otherwise a busy lane that drafted
* nothing this poll shows 0 in the headline and "now Z% of highest" one line below it,
* computed from the last drafted delta. highest/recent are session statistics and stay. */
/* `now` only when this poll drafted: the ring holds only polls that did, so its newest entry
* may be older than this poll, whose headline then reads 0. */
$("m-acceptdet").textContent = acceptTriple(cNow, busy && awR != null);
M.flight.u.textContent = "/ " + s.queue_cap;
@@ -2084,11 +2099,9 @@ function update(s, dt) {
const kvLive = Math.max(0, (s.kv_tokens_used || 0) - kvCached);
mKv.v.textContent = hbOf(s.kv_bytes_used, s.kv_bytes_total, " / ") + " · " + pct(kvFrac);
setSplit(mKv, kvLive, kvCached, s.kv_tokens_total || 0);
/* WHAT THE SEGMENTS ARE, IN THE WORDS OF WHAT THEY WOULD COST TO RECLAIM, because a dimmer bar
is not self-explanatory and the phrase this line used to carry -- "in flight" against "held
for the next turn" -- named neither thing it was measuring. The split is by who references
the blocks: the first part is context a request on the card is reading and cannot be taken
from it, the second is context nothing is reading and the next eviction frees. */
/* The segments named by what reclaiming them would cost, since a dimmer bar is not
self-explanatory. The split is by who references the blocks: the first part is context a
request on the card is reading, the second context nothing reads and the next eviction frees. */
mKvSub.textContent = s.kv_tokens_used > 0
? cnt3(kvLive) + " tok read by running requests · " + cnt3(kvCached) + " kept for reuse"
: "";
@@ -2141,34 +2154,17 @@ function update(s, dt) {
* gives tokens a step for the whole batch -- which grows with concurrency and says nothing
* about the drafter. What speculation buys is tokens a step for ONE sequence. */
const perStep = sps > 0 && s.decode_tps > 0 ? s.decode_tps / sps / seqs : null;
/* Reads 0 when this window took no decode steps -- the page's idle figure, same law as
* the step tile above it, which this figure is derived from. It used to hold the last
* value, so a lane that stopped decoding kept reporting what its steps used to cost.
* (Extension of the operator's idle-0 ruling by one figure: same defect, one line down,
* flagged by judge slice 26 as "pre-existing, now more visible".) */
/* 0 for a window with no decode steps, as on the step tile it derives from. */
$("tps_n").firstChild.nodeValue = perStep == null ? "0" : sig3(perStep);
/* ACCEPTED IS THE LIVE FIGURE, matching the tile above it. `aw` is the same pooled drafting
* window the tile's headline reads, computed earlier in this function -- one derivation, two
* readers, so the panel and the tile cannot disagree.
* DESIGN DECISION, 10-19, at the Operator's direction: this section shows the REAL-TIME
* accepted percentage and the lifetime average sits in the bullets below it. The reasoning is
* on the tile; the short form is that a cumulative ratio on a process that has been up for
* hours is a number that cannot move, and a headline that cannot move reads as a dead page.
* PINNED, NOT PRICED: the Operator may prefer the average back in the big seat, and the swap
* is these two lines. What must not happen is the average returning as the headline with no
* bullet left behind, because then the live figure is the thing nobody can see.
* Nothing drafted this poll reads 0 -- the page's idle figure, same law as the accept tile
* (op ruling 2026-10-20, second pass). The defect being fixed is the FREEZE: a held value
* reads as a live measurement of a lane that drafted nothing. */
/* The same per-poll conditional acceptance as the accept tile's headline (accWindow), so the
* two cannot disagree; 0 when this poll drafted nothing. The lifetime ratio is the
* "Accepted of drafted" bullet below. */
if (awR != null) $("acc_n").firstChild.nodeValue = pctn(awR, 0);
else $("acc_n").firstChild.nodeValue = pctn(0, 0); /* idle: 0, the page's idle figure */
$("specaside").textContent = "depth " + dp.length;
spec["Drafter"].textContent = drafterName;
spec["Depth"].textContent = dp.length;
/* The lifetime marginal, always shown. Judge 22: guarding on >0 conflated "no drafts yet"
* with "drafts made, all rejected" -- a drafter that accepts nothing is exactly the case a
* reader needs to see, and a dash hid it. 0 is the honest figure for both, and the README's
* "Draft acceptance" section says which question this bullet answers. */
/* Always shown: 0% is also what a drafter that accepts nothing reads, which a dash would hide. */
spec["Accepted of drafted"].textContent = pct(s.draft_accept, 0);
}
@@ -3312,32 +3308,24 @@ async function identify() {
} catch (err) { /* the header simply keeps its placeholder */ }
}
/* THE CONTROL VECTOR, asked when the Model view opens. It is not a polled value: it changes only
* when this page (or an admin call) flips it, and a control that silently reverted under the
* reader would be worse than one that is a second old. A deployment without a control vector
* answers 404 and the panel stays hidden. */
/* The control vector, read when the Model view opens rather than polled: only this page or an
* admin call changes it. 404 means the deployment has none and hides the panel; any other failure
* keeps the panel and says why, so a page without the API key does not look like a build without
* the feature. */
async function loadControlVector() {
/* THREE OUTCOMES, and only one of them hides the panel:
* 404 this deployment has no control vector -- there is no such control, so it is omitted;
* 200 the vector is loaded -- show the switch and its state;
* anything else (most often 401, the page has no API key yet) -- the feature may well be
* there, so SAY that instead of hiding the control. A control that silently disappears
* because the page has not signed in reads exactly like a build without the feature. */
try {
const r = await api("admin/control-vector");
if (r.status === 404) { $("cvpanel").hidden = true; return; }
if (!r.ok) throw new Error(String(r.status));
if (!r.ok) { const err = new Error(String(r.status)); err.status = r.status; throw err; }
const p = await r.json();
$("cvpanel").hidden = false;
$("cvbox").disabled = false;
$("cvbox").checked = !!p.default;
/* The family leads: it is the one term that says whether this file belongs to the model on the
* card at all, and it is the loader's own answer, not a label the page invents. */
/* The family the loader validated the file against, then its range and scale. */
$("cvsum").textContent = (p.arch ? p.arch + " \u00b7 " : "") + "layers " + p.first +
"\u2013" + p.last + " \u00b7 " + p.mode + " \u00b7 scale " + p.scale;
/* New requests only, because a running request keeps the choice it was admitted with; and a
* session whose context already holds a refusal can repeat it, since the refusal is in the
* prompt the next turn reads. */
/* A running request keeps the choice it was admitted with, and a refusal already in a
* session's context is in the prompt the next turn reads. */
$("cvnote").textContent = "New requests only. A session with a refusal already in its " +
"context may repeat it.";
} catch (e) {
@@ -3345,9 +3333,10 @@ async function loadControlVector() {
$("cvbox").disabled = true;
$("cvbox").checked = false;
$("cvsum").textContent = "";
$("cvnote").textContent =
"Sign in with the API key (the field in the header) to read or change this: the vector " +
"is present on this deployment, but its state needs the key.";
$("cvnote").textContent = e.status === 401
? "Sign in with the API key (the field in the header) to read or change this: the vector " +
"is present on this deployment, but its state needs the key."
: "The server did not report the control vector's state (" + (e.status || e.message) + ").";
}
}
$("cvbox").addEventListener("change", async (e) => {
@@ -3360,11 +3349,17 @@ $("cvbox").addEventListener("change", async (e) => {
apiKey ? { Authorization: "Bearer " + apiKey } : {}),
body: JSON.stringify({ enabled: want }),
});
if (!r.ok) throw new Error(String(r.status));
if (!r.ok) {
let msg = String(r.status);
try { const j = await r.json(); if (j && j.error && j.error.message) msg = j.error.message; }
catch (_) { /* the status alone */ }
throw new Error(msg);
}
const p = await r.json();
$("cvbox").checked = !!p.default;
} catch (err) {
e.target.checked = !want; // the server kept the old value
$("cvnote").textContent = "Not changed: " + err.message;
} finally {
e.target.disabled = false;
}
+1 -1
View File
@@ -506,7 +506,7 @@ int HttpTransport::serve(const Router& router, const TransportOptions& o) {
* anthropic-version and anthropic-beta headers of Anthropic's clients, which nothing reads. */
static const char* const kCorsHeaders =
"Content-Type, Authorization, X-Api-Key, anthropic-version, anthropic-beta";
static const char* const kCorsMethods = "GET, POST, OPTIONS";
static const char* const kCorsMethods = "GET, POST, DELETE, OPTIONS";
/* Whether a request carries the API key: `Authorization: Bearer` (OpenAI; the scheme is
* case-insensitive, RFC 9110) or `X-Api-Key` (Anthropic, also accepted by llama-server). */
+40
View File
@@ -78,6 +78,7 @@ struct SchedMetrics {
int64_t prefix_restore_cuts = 0;
/* Removed by --prefix-cache-ttl, cumulative. Not evictions: nothing wanted the memory. */
int64_t prefix_expired = 0, prefix_ckpt_expired = 0;
int64_t prefix_released = 0, prefix_ckpt_released = 0;
/* Decoupled prefix caching (spec §7.3). `prefix_hit_rate` is the attention hit rate, as in
* vLLM. The linear side hits at a different granularity (whole checkpoints, not blocks), so
* it is reported separately, with token counts and checkpoints written. */
@@ -168,6 +169,17 @@ struct SessionOccupancy {
int64_t host_cap_bytes = 0;
};
/* What a release took out of the store and what it left (PrefixCache::release_session). The
* kept counts are apart on purpose: `shared` blocks belong to another stored conversation too,
* `live` ones to a request still reading them. */
struct SessionReleased {
int64_t sessions = 0;
int64_t entries = 0, tokens = 0;
int64_t device_bytes = 0, host_bytes = 0;
int64_t snapshots = 0;
int64_t kept_tokens = 0, kept_shared = 0, kept_live = 0;
};
/* One in-flight request, for the live request table: shows which request is stuck, e.g. one
* waiting on a prompt that will never fit, which no aggregate metric reveals. */
struct RequestStat {
@@ -225,6 +237,15 @@ public:
* allocated), but it takes the scheduler's lock because a step may be inserting into the map. */
virtual int64_t reset_prefix_cache() { return RAD_E_UNSUPPORTED; }
/* Forgets one stored conversation (DELETE /sessions): every row carrying `label`, or with
* `id` nonzero the row of that engine id; `keep_tokens` leaves the chain's start standing.
* RAD_E_NOTFOUND when nothing matches (404), RAD_E_STATE while a request of that
* conversation is queued or running (409), RAD_E_UNSUPPORTED without a prefix cache (501). */
virtual int release_session(const std::string& /*label*/, uint64_t /*id*/,
int64_t /*keep_tokens*/, SessionReleased* /*out*/) {
return RAD_E_UNSUPPORTED;
}
/* The live request table, oldest first; returns the count. Default: none kept. */
virtual int requests(std::vector<RequestStat>* /*out*/) const { return 0; }
@@ -527,6 +548,14 @@ struct MediaOpts {
/* A picture over this many pixels is first scaled down to that area (PIL's bicubic, sides
* truncated), as a model's own pipeline may do before its processor; 0 leaves it as sent. */
int64_t max_pixels = 0;
/* Which of the checkpoint's picture modes, for one that has two (Unlimited-OCR): 0 is the
* processor's choice (mm::ImageMode::Default), 1 gundam, 2 base. */
int32_t image_mode = 0;
/* The mode's sizes, when the request states them; 0 keeps the mode's own. */
int32_t image_base_size = 0, image_size = 0;
/* The request carries more than one picture (mm::ImageMode::several): a processor with a
* multi-page mode uses it for a picture whose mode the request did not name. */
bool several_pictures = false;
};
class IMultimodal {
@@ -660,6 +689,8 @@ struct ImageGenInfo {
/* The prompt in windows (RadGeneratorDecl::chunk_tokens): tokens a window, its markers and
* its padding token; 0 for a prompt read whole. */
int32_t chunk_tokens = 0, chunk_bos = 0, chunk_eos = 0, chunk_pad = 0;
/* The conditioning options a request may ask for (RadGeneratorDecl::cond_opts, RAD_GEN_COND_*). */
uint32_t cond_opts = 0;
};
class IImageGen {
@@ -694,6 +725,15 @@ struct AudioGenInfo {
int64_t sample_rate = 0, channels = 0;
int64_t default_steps = 0, max_lanes = 1; /* default_steps 0: no denoiser */
double default_cfg = 1.0;
/* RadAudioGenDecl::branches (1: no guidance) and ::input_special (the {input} slot is
* tokenised with special tokens). */
int32_t branches = 2;
bool input_special = false;
/* RadAudioGenDecl's references: the prompt with them and one reference ("" when the model
* takes none), the clips' rate and frame, and the most of them and their samples. */
std::string tmpl_ref, ref_item;
int64_t ref_rate = 0, ref_hop = 0, ref_max_samples = 0;
int32_t ref_max = 0;
};
class IAudioGen {
+5 -2
View File
@@ -397,12 +397,15 @@ HttpResponse Server::handle_images(const HttpRequest& req, bool edit) {
r.seed = (uint64_t)body["seed"].get<int64_t>();
r.seed_given = body["seed"].is_number_unsigned() || body["seed"].get<int64_t>() != -1;
}
/* Krea 2's fixed tap gains (ConditioningKrea2Rebalance's defaults, arch/krea2); other models
* ignore it. */
/* The conditioning at the plugin's fixed rebalance gains (Krea 2: its text taps at
* ConditioningKrea2Rebalance's defaults). `false` is accepted everywhere. */
if (body.contains("rebalance") && !body["rebalance"].is_null()) {
if (!body["rebalance"].is_boolean())
return error_response(err_bad("rebalance", "expected true or false"), req.peer);
r.rebalance = body["rebalance"].get<bool>();
if (r.rebalance && !(info.cond_opts & RAD_GEN_COND_REBALANCE))
return error_response(err_unsupported("rebalance", "this model has no rebalance"),
req.peer);
}
if (str("negative_prompt", &r.negative) < 0)
return error_response(err_bad("negative_prompt", "expected a string"), req.peer);
+20 -19
View File
@@ -140,8 +140,7 @@ void Metrics::sample(const SchedMetrics& m) {
g_prefill_tps_.set(m.prefill_tps);
g_decode_tps_.set(m.decode_tps);
g_draft_accept_.set(m.draft_acceptance);
/* Nanoseconds in the scheduler, seconds on the wire: the base unit Prometheus expects, and
* what radiance:engine_step_seconds_* already use. */
/* Nanoseconds in the scheduler, seconds on the wire, as engine_step_seconds_* use. */
g_step_best_.set((double)m.step_ns_decode_best / 1e9);
g_step_recent_.set((double)m.step_ns_decode_recent / 1e9);
const int seen = std::max(0, std::min(m.draft_depth_seen, (int)MAX_DRAFT_POS));
@@ -190,6 +189,8 @@ void Metrics::sample(const SchedMetrics& m) {
c_prefix_ckpt_evict_.advance_to(m.prefix_ckpt_evictions);
c_prefix_expired_.advance_to(m.prefix_expired);
c_prefix_ckpt_expired_.advance_to(m.prefix_ckpt_expired);
c_prefix_released_.advance_to(m.prefix_released);
c_prefix_ckpt_released_.advance_to(m.prefix_ckpt_released);
c_ckpt_retired_.advance_to(m.prefix_ckpt_retired);
c_ckpt_lru_.advance_to(m.prefix_ckpt_lru);
c_ckpt_refused_.advance_to(m.prefix_ckpt_refused);
@@ -330,25 +331,17 @@ std::string Metrics::render() const {
"Prefill throughput over the scheduler's recent window.", L, g_prefill_tps_.get());
w.gauge("radiance:decode_tokens_per_second",
"Decode throughput over the scheduler's recent window.", L, g_decode_tps_.get());
/* THE DECODE FLOOR, the two figures the dashboard's Decode Step tile shows. They were on
* /stats only, and /stats is documented as not a stable API -- so the one figure worth
* comparing across restarts was reachable only from the surface automation is told not to
* use. Omitted until measured: a floor of 0 seconds is not an unmeasured floor, it is an
* infinitely fast one, and a scrape would plot it as a record. Both reset on restart, so a
* freshly started server simply has no floor to report yet. */
/* The decode floor the dashboard's step tile shows. Each series is omitted until its window
* has been measured, because a 0-second step would plot as the fastest ever. */
if (g_step_best_.get() > 0)
w.gauge("radiance:decode_step_seconds_best",
"Fastest single-sequence decode step window this process has run, in seconds "
"PER STEP. A mean over 32 consecutive single-stream steps, not a stopwatch "
"reading. Not seconds per token: with speculation a step can emit several "
"tokens, so per-token time is this divided by (1 + accepted per step), "
"not by the accepted figure alone. Resets on restart.", L, g_step_best_.get());
"Fastest single-sequence decode window this process has run, in seconds per "
"step: the mean of 32 consecutive single-stream steps. With speculation a step "
"emits 1 + accepted tokens. Resets on restart.", L, g_step_best_.get());
if (g_step_recent_.get() > 0)
w.gauge("radiance:decode_step_seconds_recent",
"Most recent single-sequence decode step window, in seconds PER STEP (see "
"_best: not a token rate). The gap "
"to _best tracks what else the machine is doing, not wear; see docs/GUIDE.md. "
"Freezes while the lane is idle, because no window is completing.",
"Most recent single-sequence decode window, in seconds per step (see _best). "
"Holds its value while no single-stream window completes.",
L, g_step_recent_.get());
w.counter("radiance:engine_steps_total",
"Scheduler steps executed. One forward pass of the model, plus whatever draft "
@@ -447,6 +440,13 @@ std::string Metrics::render() const {
c_ckpt_retired_.get());
labelled("radiance:prefix_cache_ckpt_evictions_by_reason_total", "reason", "store_full",
c_ckpt_lru_.get());
w.help("radiance:prefix_cache_released_total",
"Prefix-cache entries and linear-state snapshots a client released on purpose "
"(DELETE /sessions).", "counter");
labelled("radiance:prefix_cache_released_total", "what", "entries",
c_prefix_released_.get());
labelled("radiance:prefix_cache_released_total", "what", "snapshots",
c_prefix_ckpt_released_.get());
w.counter("radiance:prefix_cache_ckpt_refused_total",
"Checkpoints not written because every snapshot slot was in use by a restore "
"in the same step.", L, c_ckpt_refused_.get());
@@ -463,8 +463,9 @@ std::string Metrics::render() const {
c_cut_resumed_below_.get());
w.counter("radiance:prefix_restore_cuts_total",
"Restores from the host tier the pool could not hold whole, even after giving "
"up the VRAM copies of other stored conversations; each came back to a "
"snapshot short of its end.", L, c_restore_cuts_.get());
"up the VRAM copies of other stored conversations; each came back only in "
"part, on a model with recurrent state up to the deepest snapshot the room "
"reaches.", L, c_restore_cuts_.get());
w.counter("radiance:prefix_hit_cut_tokens_total",
"Prompt tokens the attention cache held and admission computed again, because "
"the hit resumed at a snapshot below it or reused nothing.", L,
+3 -3
View File
@@ -113,9 +113,8 @@ private:
Gauge g_running_, g_waiting_, g_kv_util_, g_prefix_hit_;
Gauge g_kv_max_tokens_, g_kv_max_bytes_;
Gauge g_prefill_tps_, g_decode_tps_, g_draft_accept_, g_preempted_;
/* The decode floor, in seconds: the fastest single-sequence window this process has run,
* and the most recent one. Both stay 0 until a window of 32 single-stream steps completes,
* and both reset on restart -- the render omits them rather than expose an unmeasured 0. */
/* The decode floor in seconds: the fastest and the most recent single-sequence window. 0
* until a window completes, and render() omits a 0. */
Gauge g_step_best_, g_step_recent_;
Gauge queue_depth_;
/* Per-position conditional draft acceptance (see render() and core/sched/draft.h). */
@@ -152,6 +151,7 @@ private:
Counter c_attn_cached_, c_linear_cached_, c_checkpoints_;
Counter c_prefix_evict_, c_prefix_ckpt_evict_;
Counter c_prefix_expired_, c_prefix_ckpt_expired_;
Counter c_prefix_released_, c_prefix_ckpt_released_;
Counter c_ckpt_retired_, c_ckpt_lru_, c_ckpt_refused_;
Counter c_cut_no_snapshot_, c_cut_window_, c_cut_adopt_, c_cut_resumed_below_, c_cut_tokens_;
Counter c_restore_cuts_;
+129 -16
View File
@@ -240,7 +240,8 @@ const char* kAcceptedCommon[] = {
"dry_sequence_breakers", "samplers",
"grammar", "json_schema", "priority", "logprobs", "ignore_eos",
"timings_per_token", "return_progress", "session_id", "n_probs",
"control_vector", "experimental_speed_projection",
"control_vector",
"ngram_ban_n", "ngram_window", "ngram_whitelist", "no_repeat_ngram_whitelist",
};
const char* kAcceptedChat[] = {
@@ -250,6 +251,8 @@ const char* kAcceptedChat[] = {
"thinking_token_budget", "thinking_budget", "thinking_budget_tokens",
"reasoning_budget_tokens", "reasoning_format", "continue_final_message",
"functions", "function_call",
/* Unlimited-OCR's picture modes: which of the checkpoint's two a request's pictures get. */
"images_config",
};
/* `preserved_tokens` is llama-server's: control tokens a raw completion's text keeps. On chat the
@@ -843,19 +846,12 @@ static int parse_sampling(const json& b, const OaiLimits& lim, OaiRequest* r, Ap
/* ignore_eos: generate to max_tokens whatever the model emits. See Request::ignore_eos. */
if (!get_bool(b, "ignore_eos", &r->ignore_eos, err)) return RAD_E_INVAL;
/* The control vector (core/cvec.h): an opt-in per request, and the only place an API client
* turns it on when the deployment's default is off. `control_vector` is the field's name;
* `experimental_speed_projection` is Strata's spelling of the same switch, kept as an alias so
* a client written against that reports what it means -- and read only when the request did not
* send the field itself, so the field wins when a body carries both. A JSON null is "not sent",
* as everywhere else in this parser. */
for (const char* key : { "control_vector", "experimental_speed_projection" }) {
const auto it = b.find(key);
if (it == b.end() || it->is_null()) continue;
/* The control vector (core/cvec.h), per request: absent or null takes the deployment's
* default. */
if (const auto it = b.find("control_vector"); it != b.end() && !it->is_null()) {
bool on = false;
if (!get_bool(b, key, &on, err)) return RAD_E_INVAL;
if (!get_bool(b, "control_vector", &on, err)) return RAD_E_INVAL;
r->control_vector = on ? 1 : 0;
break;
}
/* stop: a string or an array of strings. Bounded in count and length because every stop
@@ -907,6 +903,95 @@ static int parse_sampling(const json& b, const OaiLimits& lim, OaiRequest* r, Ap
auto sid = b.find("session_id");
if (sid != b.end() && sid->is_string()) r->session_label = session_label_of(sid->get<std::string>());
/* The windowed no-repeat-ngram ban (core/sample/sampler.h): `ngram_ban_n` is the banned
* n-gram's length and `ngram_window` how far back it looks; the checkpoint's own generation
* config asks for 35 and 128 (Unlimited-OCR). The reference spells them
* no_repeat_ngram_size and no_repeat_ngram_window_size; both are taken. */
i64 = r->sp.ngram_ban_n;
if (!get_any(b, { "ngram_ban_n", "no_repeat_ngram_size" }, &i64, nullptr, err))
return RAD_E_INVAL;
if (i64 < 0 || i64 > 256) {
*err = err_bad("ngram_ban_n", "must be in [0, 256]");
return RAD_E_INVAL;
}
r->sp.ngram_ban_n = (int)i64;
i64 = r->sp.ngram_window;
if (!get_any(b, { "ngram_window", "no_repeat_ngram_window_size" }, &i64, nullptr, err))
return RAD_E_INVAL;
if (i64 < 0 || i64 > 131072) {
/* The reference's negative window spelling belongs to generation_config, where it is
* normalized to 0; a request states the whole-sequence form as 0, matching the sampler's
* admission check (check_request refuses a negative window). */
*err = err_bad("ngram_window", "must be 0 (search the whole sequence) or a count of at "
"most 131072 history tokens");
return RAD_E_INVAL;
}
r->sp.ngram_window = (int)i64;
/* The ban's whitelist (the reference's `whitelist_token_ids`, which is removed from the
* banned set before the -inf writes): token ids the ban must never touch. An array of
* non-negative integers; absent, empty or null is off, the reference's empty whitelist and
* the form the model's generation_config ships. */
auto nwl = b.find("ngram_whitelist");
if (nwl == b.end()) nwl = b.find("no_repeat_ngram_whitelist");
if (nwl != b.end() && !nwl->is_null()) {
if (!nwl->is_array()) {
*err = err_bad("ngram_whitelist", "expected an array of integer token ids");
return RAD_E_INVAL;
}
std::vector<int32_t> wl;
for (const auto& v : *nwl) {
int32_t id = 0;
if (!token_id(v, &id)) {
*err = err_bad("ngram_whitelist",
"expected token ids in [0, " + std::to_string(INT32_MAX) + "]");
return RAD_E_INVAL;
}
if (wl.size() >= (size_t)1 << 20) {
*err = err_bad("ngram_whitelist", "at most 1048576 ids");
return RAD_E_INVAL;
}
wl.push_back(id);
}
r->sp.ngram_whitelist = std::move(wl);
}
/* `images_config`: Unlimited-OCR's two picture modes. A string names one ("gundam" for a
* single picture -- the global view plus crops --, "base" for a page of a multi-page
* document); an object carries the reference runner's own dict. */
auto ic = b.find("images_config");
if (ic != b.end() && !ic->is_null()) {
if (ic->is_string()) {
const std::string m = ic->get<std::string>();
if (m == "gundam") r->image_mode = 1;
else if (m == "base") r->image_mode = 2;
else if (!m.empty()) {
*err = err_bad("images_config", "expected \"gundam\" or \"base\", got \"" + m +
"\"");
return RAD_E_INVAL;
}
} else if (ic->is_object()) {
const json& o = *ic;
int64_t bs = 0, is = 0;
if (!get_int(o, "base_size", &bs, err)) return RAD_E_INVAL;
if (!get_int(o, "image_size", &is, err)) return RAD_E_INVAL;
bool crop = true;
if (!get_bool(o, "crop_mode", &crop, err)) return RAD_E_INVAL;
if (bs < 0 || bs > 65536 || is < 0 || is > 65536) {
*err = err_bad("images_config", "base_size and image_size must be in [0, 65536]");
return RAD_E_INVAL;
}
r->image_mode = crop ? 1 : 2;
r->image_base_size = (int32_t)bs;
r->image_size = (int32_t)is;
} else {
*err = err_bad("images_config",
"expected \"gundam\", \"base\", or an object with base_size, "
"image_size and crop_mode");
return RAD_E_INVAL;
}
}
RAD_TRY(apply_sampler_order(b, &r->sp, err));
auto so = b.find("stream_options");
@@ -1488,6 +1573,15 @@ int tokenize_with_media(const std::string& rendered, const OaiDeps& d,
out->text = rendered;
auto pm = std::make_shared<mm::PromptMedia>();
const std::string marker = RAD_MEDIA_MARKER;
/* Whether the request carries several pictures: a processor with a multi-page mode picks it
* for a picture whose mode the request did not name (mm::ImageMode::several). */
size_t n_images = 0;
for (const auto& m : media) n_images += m.first == MediaKind::Image ? 1 : 0;
auto opts_for = [&](MediaKind k) {
MediaOpts mo = opts;
if (k == MediaKind::Image) mo.several_pictures = n_images > 1;
return mo;
};
size_t pos = 0, mi = 0;
for (;;) {
size_t at = rendered.find(marker, pos);
@@ -1507,7 +1601,8 @@ int tokenize_with_media(const std::string& rendered, const OaiDeps& d,
}
std::shared_ptr<mm::Item> item;
std::string why;
const int s = d.mm->prepare(media[mi].first, media[mi].second, opts, &item, &why);
const int s = d.mm->prepare(media[mi].first, media[mi].second, opts_for(media[mi].first),
&item, &why);
if (s < 0 || !item) {
*err = err_bad("messages[].content[]", "the media could not be used: " +
(why.empty() ? std::string(rad_strerror(s))
@@ -2069,12 +2164,30 @@ int parse_chat_request(const std::string& body, const OaiDeps& d, const OaiLimit
PromptInput p;
if (media.empty()) {
/* add_special is false: the template renders the model's special tokens, BOS included;
* another would shift every position. */
/* add_special is false: the template renders the model's special tokens; BOS is placed
* below. */
p.tokens = d.tok->encode(rendered, false, /*parse_special=*/true);
p.text = rendered;
} else {
RAD_TRY(tokenize_with_media(rendered, d, media, MediaOpts{}, &p, err));
MediaOpts mo;
mo.image_mode = out->image_mode;
mo.image_base_size = out->image_base_size;
mo.image_size = out->image_size;
RAD_TRY(tokenize_with_media(rendered, d, media, mo, &p, err));
}
/* A tokenizer that states add_bos gets exactly one BOS in front. The render drops a BOS the
* template writes when add_bos is set (ChatTemplate, as llama.cpp's chat does, which leaves it
* to the tokenizer), and some templates never write one, so it is added here unless the
* prompt already starts with it. A media run's placeholders shift by one with it. */
{
const ITokenizer::VocabInfo vi = d.tok->vocab_info();
if (vi.add_bos && vi.bos >= 0 && (p.tokens.empty() || p.tokens.front() != vi.bos)) {
p.tokens.insert(p.tokens.begin(), vi.bos);
if (p.media) {
for (auto& pl : p.media->items) pl.tok += 1;
p.media->layout();
}
}
}
if (p.tokens.empty()) {
*err = err_bad("messages", "the rendered prompt tokenised to nothing");
+7 -4
View File
@@ -94,10 +94,8 @@ struct OaiRequest {
int n = 1;
SamplingParams sp;
/* The control vector, tri-state: -1 the request named no choice (the deployment's
* runtime default applies), 0 it asked for the stock model, 1 for the loaded control vector.
* Parsed from `control_vector` (or Strata's `experimental_speed_projection`); a deployment
* with no vector refuses 1 rather than silently serving the stock model. */
/* `control_vector`, tri-state: -1 not sent (the deployment's runtime default applies), 0 the
* stock model, 1 the loaded control vector. A deployment with no vector refuses 1. */
int control_vector = -1;
int32_t max_tokens = 0;
std::vector<std::string> stop;
@@ -163,6 +161,11 @@ struct OaiRequest {
/* /v1/embeddings: a soft-token budget for the request's images, 0 the server's. */
int32_t image_tokens = 0;
/* `images_config`: which of the checkpoint's picture modes a request's pictures get, and the
* sizes it states (Unlimited-OCR's gundam and base modes). 0 keeps the processor's choice
* (mm::ImageMode::Default). */
int32_t image_mode = 0, image_base_size = 0, image_size = 0;
int n_choices() const { return (int)prompts.size() * n; }
};
+3 -7
View File
@@ -98,10 +98,6 @@ int unsettled_for(const std::string& delay) {
return 6; /* medium */
}
bool starts_with(const std::string& s, const std::string& p) {
return s.size() >= p.size() && s.compare(0, p.size(), p) == 0;
}
std::string rtrim(std::string s) {
while (!s.empty() && std::isspace((unsigned char)s.back())) s.pop_back();
return s;
@@ -858,7 +854,7 @@ bool Server::realtime_loop(RealtimeSession& s, WsConn& ws) {
const std::string text = detok(ids, /*flush=*/true);
const size_t at = speech_transcript_start(f, text, forced, /*closed=*/true);
const std::string transcript = rtrim(text.substr(std::min(at, text.size())));
if (starts_with(transcript, t->sent)) delta(*t, transcript.substr(t->sent.size()));
if (transcript.starts_with(t->sent)) delta(*t, transcript.substr(t->sent.size()));
ojson o = event("conversation.item.input_audio_transcription.completed");
o["item_id"] = t->id;
o["content_index"] = 0;
@@ -886,13 +882,13 @@ bool Server::realtime_loop(RealtimeSession& s, WsConn& ws) {
const size_t a = speech_transcript_start(f, settled_text, forced, /*closed=*/false);
const std::string settled = a == std::string::npos ? std::string()
: rtrim(settled_text.substr(a));
if (settled.size() > t->sent.size() && starts_with(settled, t->sent))
if (settled.size() > t->sent.size() && settled.starts_with(t->sent))
delta(*t, settled.substr(t->sent.size()));
const std::string all_text = detok(ids, /*flush=*/false);
const size_t b = speech_transcript_start(f, all_text, forced, /*closed=*/false);
const std::string all = b == std::string::npos ? std::string()
: rtrim(all_text.substr(b));
const std::string tentative = starts_with(all, t->sent) ? all.substr(t->sent.size())
const std::string tentative = all.starts_with(t->sent) ? all.substr(t->sent.size())
: std::string();
if (tentative != t->tentative) {
ojson o = event("radiance.input_audio_transcription.tentative");
+9 -5
View File
@@ -210,6 +210,12 @@ void Server::register_routes() {
[this](const HttpRequest& q) { return handle_control_vector(q); });
router_.post("/admin/control-vector",
[this](const HttpRequest& q) { return handle_control_vector(q); });
/* Forget one stored conversation: by its client label in the path (or `?label=`, for a
* label the path cannot carry), or by engine id with `?id=`. */
router_.add ("DELETE", "/sessions/:label",
[this](const HttpRequest& q) { return handle_session_release(q); });
router_.add ("DELETE", "/sessions",
[this](const HttpRequest& q) { return handle_session_release(q); });
}
/* Workers beyond the admission ceiling. A generation holds its connection's worker for its whole
@@ -297,8 +303,8 @@ std::vector<std::string> Server::probe_reasoning_efforts() {
if (text == plain) same.push_back(w);
}
/* The level a request naming none gets: the one level whose render is the same. A template may
* spend it in a system prompt the client never sees (#113: Qwen3.8's is xhigh). Several, or
* none, say nothing. */
* spend it in a system prompt the client never sees (Qwen3.8's is xhigh). Several, or none,
* say nothing. */
if (same.size() == 1) template_default_effort_ = same[0];
lim_.reasoning_efforts = set;
return set;
@@ -467,9 +473,7 @@ int Server::submit_all(const OaiRequest& r, std::vector<Generation>* gens, ApiEr
}
/* The control vector: the request's own choice, else the deployment's runtime default. A
* deployment with no vector refuses the on state by name -- serving the stock model while the
* client believes it asked for the vector would be a silent lie about what produced the text.
* (Naming: `control_vector` is the field, `experimental_speed_projection` its alias.) */
* deployment with no vector refuses the on state by name rather than serve the stock model. */
bool projection_on = false;
{
const bool named = r.control_vector >= 0;
+3 -1
View File
@@ -331,8 +331,10 @@ private:
HttpResponse handle_sessions(const HttpRequest& req);
/* The control vector's runtime switch (dashboard.cpp): GET reports the state, POST
* {"enabled": bool} sets the default for requests that name no choice. Guarded by the API key
* like every other route but the health probes and the page. */
* like every other route but the health probes and the page; without a key, POST answers
* loopback clients only. */
HttpResponse handle_control_vector(const HttpRequest& req);
HttpResponse handle_session_release(const HttpRequest& req);
HttpResponse error_response(const ApiError& e, const std::string& peer,
ApiShape shape = ApiShape::OpenAI);
+1 -1
View File
@@ -214,7 +214,7 @@ bool Server::speech_stream_loop(SpeechSession& s, WsConn& ws) {
static const char* kFields[] = {
"type", "model", "instructions", "voice", "response_format", "speed", "seed",
"max_new_tokens", "duration", "num_inference_steps", "guidance_scale", "user",
"stream_audio", "split_granularity", "text_input_mode",
"references", "stream_audio", "split_granularity", "text_input_mode",
};
json fields = json::object();
for (auto it = j.begin(); it != j.end(); ++it) {