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.
This commit is contained in:
baKon authored and StillDeadcode committed 2026-10-08 15:57:51 +02:00
1 parent 3a3345951f
commit d5b584a4c1
8 files changed
+22 -3

No files matched your search

+1
View File
@@ -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<int64_t>(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;
+1
View File
@@ -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;
}
+2
View File
@@ -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);
+1
View File
@@ -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));
}
+4
View File
@@ -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;
+1 -1
View File
@@ -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 |
+5 -2
View File
@@ -343,7 +343,7 @@ struct Fixture {
FakeGrammar gram;
std::unique_ptr<Server> 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);
+7
View File
@@ -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) {