From d5b584a4c1388c8977b88421f11db88f93779196 Mon Sep 17 00:00:00 2001 From: baKon Date: Wed, 7 Oct 2026 13:54:11 -0500 Subject: [PATCH] serve: the model entry names the file behind the served name as root A served name is chosen for clients and says nothing about which container is behind it. Report what --model named as `root`, the field vLLM fills with the path it loaded; left out when the server has none. --- core/engine.cpp | 1 + core/server/oai.cpp | 1 + core/server/oai.h | 2 ++ core/server/server.cpp | 1 + core/server/server.h | 4 ++++ docs/GUIDE.md | 2 +- tests/server_test.cpp | 7 +++++-- tests/wire_test.cpp | 7 +++++++ 8 files changed, 22 insertions(+), 3 deletions(-) diff --git a/core/engine.cpp b/core/engine.cpp index b98d4fb8..67293bb1 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -2264,6 +2264,7 @@ int Engine::run_server() { * more choices a request; the floor keeps a small batch from refusing what it would queue. */ o.max_n = cfg_.max_n > 0 ? (int)cfg_.max_n : (int)std::max(o.max_n, cfg_.max_seqs); o.max_ctx = cfg_.max_ctx ? cfg_.max_ctx : meta_.n_ctx_train; + o.model_path = cfg_.model; o.default_reasoning_effort = cfg_.reasoning_effort; o.reasoning_effort_map = cfg_.reasoning_effort_map; o.default_thinking_budget = cfg_.thinking_token_budget; diff --git a/core/server/oai.cpp b/core/server/oai.cpp index 75a26e04..5c6f6662 100644 --- a/core/server/oai.cpp +++ b/core/server/oai.cpp @@ -2212,6 +2212,7 @@ static json model_card(const ModelCard& c) { m["created"] = c.created; m["owned_by"] = "radiance"; if (c.max_model_len > 0) m["max_model_len"] = c.max_model_len; + if (!c.root.empty()) m["root"] = c.root; return m; } diff --git a/core/server/oai.h b/core/server/oai.h index 0dc2694e..334661a6 100644 --- a/core/server/oai.h +++ b/core/server/oai.h @@ -329,6 +329,8 @@ struct ModelCard { * its own length. 0 leaves the field out rather than reporting a length the server does not * know. */ int64_t max_model_len = 0; + /* What the server loaded (ServerOptions::model_path), vLLM's `root`. Empty leaves it out. */ + std::string root; }; /* The list, for GET /v1/models. */ std::string models_body(const ModelCard& m); diff --git a/core/server/server.cpp b/core/server/server.cpp index 07ebb993..d76e2ed3 100644 --- a/core/server/server.cpp +++ b/core/server/server.cpp @@ -1157,6 +1157,7 @@ HttpResponse Server::handle_models(const HttpRequest& req) { c.id = opt_.model_id; c.created = started_at_; c.max_model_len = opt_.max_ctx; + c.root = opt_.model_path; metrics_.observe_http(200); return HttpResponse::json_body(200, id.empty() ? models_body(c) : model_body(c)); } diff --git a/core/server/server.h b/core/server/server.h index e6c49485..cc45ed42 100644 --- a/core/server/server.h +++ b/core/server/server.h @@ -57,6 +57,10 @@ struct ServerOptions { * /v1/completions answer 501 naming /v1/embeddings, rather than queueing a request the engine * would finish after one step with no text. */ bool embedding_model = false; + /* What --model named, reported as the model entry's `root` the way vLLM reports the path it + * loaded: a served name chosen for clients says nothing about which file is behind it. Empty + * leaves the field out. */ + std::string model_path; std::string host = "0.0.0.0"; int port = 8000; int n_threads = 0; diff --git a/docs/GUIDE.md b/docs/GUIDE.md index 9065b49c..cf25947f 100644 --- a/docs/GUIDE.md +++ b/docs/GUIDE.md @@ -1132,7 +1132,7 @@ for a model that takes no images or video. | `POST /v1/chat/completions` | chat, with tools, reasoning and streaming | | `POST /v1/completions` | raw text completion | | `POST /v1/embeddings` | needs a model with an embedding head, else 501 | -| `GET /v1/models`, `/v1/models/:id` | what is loaded, with `max_model_len` (the context it serves, as vLLM reports it); `:id` answers the entry itself, as OpenAI's retrieve does | +| `GET /v1/models`, `/v1/models/:id` | what is loaded, with `max_model_len` (the context it serves) and `root` (the `--model` path), as vLLM reports them; `:id` answers the entry itself, as OpenAI's retrieve does | | `GET /health`, `/ping`, `POST /ping` | liveness | | `GET /load` | current load | | `GET /version` | server version | diff --git a/tests/server_test.cpp b/tests/server_test.cpp index 622c8a9d..8f36f041 100644 --- a/tests/server_test.cpp +++ b/tests/server_test.cpp @@ -343,7 +343,7 @@ struct Fixture { FakeGrammar gram; std::unique_ptr srv; - explicit Fixture(bool with_tools = true, int64_t max_ctx = 0) { + explicit Fixture(bool with_tools = true, int64_t max_ctx = 0, const char* model_path = "") { Deps d; d.sched = &sched; d.tok = &tok; @@ -357,6 +357,7 @@ struct Fixture { o.default_max_tokens = 32; o.max_seqs = 4; o.max_ctx = max_ctx; + o.model_path = model_path; srv.reset(new Server(d, o)); } @@ -2528,7 +2529,9 @@ TEST(models_and_health_answer) { TEST(the_model_entry_carries_the_context_length_the_server_was_started_with) { /* Both routes a client sizes its window from: the list, and the entry it fetches by id. */ - Fixture f(true, 262144); + Fixture f(true, 262144, "/models/m.rad"); + CHECK_EQ(json::parse(f.get("/v1/models/test-model").body).value("root", std::string()), + std::string("/models/m.rad")); HttpResponse list = f.get("/v1/models"); CHECK_EQ(list.status, 200); CHECK_EQ(json::parse(list.body)["data"][0].value("max_model_len", (int64_t)0), (int64_t)262144); diff --git a/tests/wire_test.cpp b/tests/wire_test.cpp index 68e91fe7..c314afde 100644 --- a/tests/wire_test.cpp +++ b/tests/wire_test.cpp @@ -425,6 +425,13 @@ TEST(the_model_list_is_a_list_of_one_with_the_fields_clients_read) { /* No length known, none reported: a client falls back to its own default rather than * trusting a made-up one. */ CHECK(!o["data"][0].contains("max_model_len")); + CHECK(!o["data"][0].contains("root")); +} + +TEST(the_model_entry_names_the_file_behind_the_served_name) { + ModelCard c = card("q38-flashnext", 1700000000); + c.root = "/models/qwen3.8-next-flash-fp8-iq4r-moe.rad"; + CHECK_EQ(parsed(model_body(c)).value("root", std::string()), c.root); } TEST(the_model_list_reports_the_context_the_server_runs_with) {