MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / main

Function main

tools/server/server.cpp:74–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74int main(int argc, char ** argv) {
75 std::setlocale(LC_NUMERIC, "C");
76
77 // own arguments required by this example
78 common_params params;
79
80 common_init();
81
82 if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_SERVER)) {
83 return 1;
84 }
85
86 // validate batch size for embeddings
87 // embeddings require all tokens to be processed in a single ubatch
88 // see https://github.com/ggml-org/llama.cpp/issues/12836
89 if (params.embedding && params.n_batch > params.n_ubatch) {
90 LOG_WRN("%s: embeddings enabled with n_batch (%d) > n_ubatch (%d)\n", __func__, params.n_batch, params.n_ubatch);
91 LOG_WRN("%s: setting n_batch = n_ubatch = %d to avoid assertion failure\n", __func__, params.n_ubatch);
92 params.n_batch = params.n_ubatch;
93 }
94
95 if (params.n_parallel < 0) {
96 LOG_INF("%s: n_parallel is set to auto, using n_parallel = 4 and kv_unified = true\n", __func__);
97
98 params.n_parallel = 4;
99 params.kv_unified = true;
100 }
101
102 // for consistency between server router mode and single-model mode, we set the same model name as alias
103 if (params.model_alias.empty() && !params.model.name.empty()) {
104 params.model_alias.insert(params.model.name);
105 }
106
107 // struct that contains llama context and inference
108 server_context ctx_server;
109
110 llama_backend_init();
111 llama_numa_init(params.numa);
112
113 LOG_INF("build_info: %s\n", llama_build_info());
114 LOG_INF("%s\n", common_params_get_system_info(params).c_str());
115
116 server_http_context ctx_http;
117 if (!ctx_http.init(params)) {
118 LOG_ERR("%s: failed to initialize HTTP server\n", __func__);
119 return 1;
120 }
121
122 //
123 // Router
124 //
125
126 // register API routes
127 server_routes routes(params, ctx_server);
128 server_tools tools;
129
130 bool is_router_server = params.model.path.empty();
131 std::optional<server_models_routes> models_routes{};

Callers

nothing calls this directly

Calls 15

common_initFunction · 0.85
common_params_parseFunction · 0.85
llama_backend_initFunction · 0.85
llama_numa_initFunction · 0.85
ex_wrapperFunction · 0.85
llama_backend_freeFunction · 0.85
setupMethod · 0.80
unload_allMethod · 0.80
on_sleeping_changedMethod · 0.80
get_llama_contextMethod · 0.80

Tested by

no test coverage detected