Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions tools/server/server-models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void server_presets::render_args(server_model_meta & meta) {
}
// 3. control args (from router)
// set control values
preset.options[control_args["LLAMA_ARG_HOST"]] = CHILD_ADDR;
preset.options[control_args["LLAMA_ARG_HOST"]] = meta.hostname;
preset.options[control_args["LLAMA_ARG_PORT"]] = std::to_string(meta.port);
preset.options[control_args["LLAMA_ARG_ALIAS"]] = meta.name;
if (meta.in_cache) {
Expand Down Expand Up @@ -308,7 +308,8 @@ void server_models::load_models() {
/* status */ SERVER_MODEL_STATUS_UNLOADED,
/* last_used */ 0,
/* args */ std::vector<std::string>(),
/* exit_code */ 0
/* exit_code */ 0,
/* host_name */ CHILD_ADDR
};
add_model(std::move(meta));
}
Expand All @@ -330,7 +331,8 @@ void server_models::load_models() {
/* status */ SERVER_MODEL_STATUS_UNLOADED,
/* last_used */ 0,
/* args */ std::vector<std::string>(),
/* exit_code */ 0
/* exit_code */ 0,
/* host_name */ CHILD_ADDR
};
add_model(std::move(meta));
}
Expand All @@ -348,7 +350,8 @@ void server_models::load_models() {
/* status */ SERVER_MODEL_STATUS_UNLOADED,
/* last_used */ 0,
/* args */ std::vector<std::string>(),
/* exit_code */ 0
/* exit_code */ 0,
/* host_name */ CHILD_ADDR
};
add_model(std::move(meta));
}
Expand Down Expand Up @@ -510,6 +513,7 @@ void server_models::load(const std::string & name) {
inst.meta.port = get_free_port();
inst.meta.status = SERVER_MODEL_STATUS_LOADING;
inst.meta.last_used = ggml_time_ms();
inst.meta.hostname = base_params.hostname; // Use router's cmdline value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.0.0.0 does not route to 127.0.0.1 on Windows like it does on Linux.

A quick fix may be to only change to 127.0.0.1 on --host 0.0.0.0, otherwise use the provided IP.

#17962 (comment)


if (inst.meta.port <= 0) {
throw std::runtime_error("failed to get a port number");
Expand Down Expand Up @@ -698,7 +702,7 @@ server_http_res_ptr server_models::proxy_request(const server_http_req & req, co
SRV_INF("proxying request to model %s on port %d\n", name.c_str(), meta->port);
auto proxy = std::make_unique<server_http_proxy>(
method,
CHILD_ADDR,
base_params.hostname,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here.

meta->port,
req.path,
req.headers,
Expand Down Expand Up @@ -726,7 +730,8 @@ std::thread server_models::setup_child_server(const common_params & base_params,
body["value"] = server_model_status_to_string(SERVER_MODEL_STATUS_LOADED);
req.body = body.dump();

SRV_INF("notifying router server (port=%d) that model %s is ready\n", router_port, name.c_str());
SRV_INF("notifying router server (%s:port=%d) that model %s is ready\n",
base_params.hostname.c_str(), router_port, name.c_str());
auto result = cli.send(std::move(req));
if (result.error() != httplib::Error::Success) {
auto err_str = httplib::to_string(result.error());
Expand Down
1 change: 1 addition & 0 deletions tools/server/server-models.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct server_model_meta {
int64_t last_used = 0; // for LRU unloading
std::vector<std::string> args; // args passed to the model instance, will be populated by render_args()
int exit_code = 0; // exit code of the model instance process (only valid if status == FAILED)
std::string hostname;

bool is_active() const {
return status == SERVER_MODEL_STATUS_LOADED || status == SERVER_MODEL_STATUS_LOADING;
Expand Down