Archived
serve: /props answers what llama-server clients read
Front-ends built against llama-server size their context from /props' default_generation_settings.n_ctx, decide whether to offer images from modalities, and read the defaults a request inherits; on Radiance that route was a 404. Answer it with what this server can fill honestly, under llama-server's names: n_ctx (the context one request may use, left out when unknown), total_slots, modalities, the sampler defaults and build_info. No chat template text or GGUF metadata -- the server has neither.
This commit is contained in:
1 parent
7d840861af
commit
7fd2cd7fa6
5 files changed
+89
No files matched your search
@@ -233,6 +233,53 @@ HttpResponse Server::handle_detokenize(const HttpRequest& req) {
|
||||
return HttpResponse::json_body(200, json_dump(o));
|
||||
}
|
||||
|
||||
/* ================================================================== /props */
|
||||
/* llama-server's /props, for the clients built against it: a front-end that sizes its context
|
||||
* from default_generation_settings.n_ctx, shows an image button when modalities.vision is set,
|
||||
* and reads what a request that sends no sampler fields inherits. /server_info says all of it and
|
||||
* more, but nothing written for llama-server knows to ask there.
|
||||
*
|
||||
* Only what this server can fill honestly, under llama-server's names: no chat template text
|
||||
* (the server holds a compiled template, not its source), no GGUF metadata, no per-slot state.
|
||||
* n_ctx is the context ONE request may use, which is what llama-server's per-slot n_ctx means to
|
||||
* the clients reading it; left out when the server does not know its length. */
|
||||
HttpResponse Server::handle_props(const HttpRequest&) {
|
||||
const SamplingParams& sp = opt_.default_sampling;
|
||||
json params;
|
||||
params["n_predict"] = opt_.default_max_tokens > 0 ? opt_.default_max_tokens : -1;
|
||||
params["temperature"] = sp.temp;
|
||||
params["top_k"] = sp.top_k;
|
||||
params["top_p"] = sp.top_p;
|
||||
params["min_p"] = sp.min_p;
|
||||
params["typical_p"] = sp.typical_p;
|
||||
params["repeat_last_n"] = sp.penalty_last_n;
|
||||
params["repeat_penalty"] = sp.rep_penalty;
|
||||
params["presence_penalty"] = sp.pres_penalty;
|
||||
params["frequency_penalty"] = sp.freq_penalty;
|
||||
params["dry_multiplier"] = sp.dry_multiplier;
|
||||
params["dry_base"] = sp.dry_base;
|
||||
params["dry_allowed_length"] = sp.dry_allowed_length;
|
||||
params["dry_penalty_last_n"] = sp.dry_penalty_last_n;
|
||||
params["xtc_probability"] = sp.xtc_probability;
|
||||
params["xtc_threshold"] = sp.xtc_threshold;
|
||||
|
||||
json gen;
|
||||
if (opt_.max_ctx > 0) gen["n_ctx"] = opt_.max_ctx;
|
||||
gen["params"] = std::move(params);
|
||||
|
||||
json modal;
|
||||
modal["vision"] = deps_.mm && deps_.mm->accepts(MediaKind::Image);
|
||||
modal["audio"] = deps_.mm && deps_.mm->accepts(MediaKind::Audio);
|
||||
|
||||
json o;
|
||||
o["default_generation_settings"] = std::move(gen);
|
||||
o["total_slots"] = opt_.max_seqs;
|
||||
o["modalities"] = std::move(modal);
|
||||
o["build_info"] = "radiance " + opt_.version;
|
||||
metrics_.observe_http(200);
|
||||
return HttpResponse::json_body(200, json_dump(o));
|
||||
}
|
||||
|
||||
/* ================================================================== /get_tokenizer_info */
|
||||
/* vLLM returns the HuggingFace tokenizer config verbatim, which this engine does not have: a .rad
|
||||
* container carries a normalised vocabulary and not the JSON it was built from. So this answers
|
||||
|
||||
@@ -139,6 +139,7 @@ void Server::register_routes() {
|
||||
router_.get ("/load", [this](const HttpRequest& q) { return handle_load(q); });
|
||||
router_.get ("/version", [this](const HttpRequest& q) { return handle_version(q); });
|
||||
router_.get ("/server_info", [this](const HttpRequest& q) { return handle_server_info(q); });
|
||||
router_.get ("/props", [this](const HttpRequest& q) { return handle_props(q); });
|
||||
|
||||
router_.post("/tokenize", [this](const HttpRequest& q) { return handle_tokenize(q); });
|
||||
router_.post("/detokenize", [this](const HttpRequest& q) { return handle_detokenize(q); });
|
||||
|
||||
@@ -191,6 +191,7 @@ private:
|
||||
HttpResponse handle_health(const HttpRequest& req);
|
||||
HttpResponse handle_ping(const HttpRequest& req);
|
||||
HttpResponse handle_version(const HttpRequest& req);
|
||||
HttpResponse handle_props(const HttpRequest& req);
|
||||
HttpResponse handle_load(const HttpRequest& req);
|
||||
HttpResponse handle_tokenize(const HttpRequest& req);
|
||||
HttpResponse handle_detokenize(const HttpRequest& req);
|
||||
|
||||
@@ -1136,6 +1136,7 @@ for a model that takes no images or video.
|
||||
| `GET /health`, `/ping`, `POST /ping` | liveness |
|
||||
| `GET /load` | current load |
|
||||
| `GET /version` | server version |
|
||||
| `GET /props` | llama-server's props for the clients built against it: `n_ctx`, `total_slots`, `modalities`, the request defaults |
|
||||
| `GET /server_info` | the whole configuration of the running engine |
|
||||
| `GET /metrics` | Prometheus |
|
||||
| `POST /tokenize`, `POST /detokenize` | |
|
||||
|
||||
@@ -2736,6 +2736,45 @@ TEST(server_info_lists_the_router_rather_than_a_copy_of_it) {
|
||||
for (const std::string& sig : f.srv->router().routes()) CHECK(has(r.body, sig));
|
||||
}
|
||||
|
||||
TEST(props_answers_what_a_llama_server_client_reads) {
|
||||
Fixture f;
|
||||
HttpResponse r = f.get("/props");
|
||||
CHECK_EQ(r.status, 200);
|
||||
const json p = json::parse(r.body);
|
||||
CHECK_EQ(p.value("total_slots", (int64_t)0), (int64_t)4);
|
||||
/* No media pipeline attached: no image button. */
|
||||
CHECK(!p["modalities"].value("vision", true));
|
||||
/* The fixture knows no context length, so none is invented. */
|
||||
CHECK(!p["default_generation_settings"].contains("n_ctx"));
|
||||
/* The same defaults /server_info reports, under llama-server's names. */
|
||||
const json defs = json::parse(f.get("/server_info").body)["request_defaults"];
|
||||
const json params = p["default_generation_settings"]["params"];
|
||||
CHECK_NEAR(params.value("temperature", -1.0), defs.value("temperature", -2.0), 1e-9);
|
||||
CHECK_NEAR(params.value("repeat_penalty", -1.0), defs.value("repetition_penalty", -2.0), 1e-9);
|
||||
CHECK_EQ(params.value("n_predict", (int64_t)0), (int64_t)32); /* the fixture's default */
|
||||
CHECK(has(p.value("build_info", std::string()), "radiance"));
|
||||
}
|
||||
|
||||
TEST(props_reports_the_context_one_request_may_use) {
|
||||
/* The fixture with a known length: build one rather than widen the shared Fixture. */
|
||||
FakeScheduler sched;
|
||||
FakeTokenizer tok;
|
||||
FakeChatTemplate tmpl;
|
||||
FakeGrammar gram;
|
||||
Deps d;
|
||||
d.sched = &sched;
|
||||
d.tok = &tok;
|
||||
d.chat = &tmpl;
|
||||
d.grammar = &gram;
|
||||
ServerOptions o;
|
||||
o.model_id = "test-model";
|
||||
o.max_ctx = 262144;
|
||||
Server srv(d, o);
|
||||
const json p = json::parse(srv.router().call("GET", "/props").body);
|
||||
CHECK_EQ(p["default_generation_settings"].value("n_ctx", (int64_t)0), (int64_t)262144);
|
||||
sched.join_all();
|
||||
}
|
||||
|
||||
TEST(server_info_drops_an_engine_blob_that_is_not_an_object) {
|
||||
/* A malformed blob must not corrupt the response: /server_info missing a section beats
|
||||
* /server_info being unparseable. */
|
||||
|
||||
Reference in new issue
Block a user