Skip to content

Commit 67b2b7f

Browse files
authored
logs : reduce (ggml-org#23021)
* logs : reduce * args : fix envs * server : fix build * common : print verbosity level at start * server : clean-up logs * server : print prompt processing timings + sampling params * minor : whitespaces
1 parent 81b0d88 commit 67b2b7f

17 files changed

Lines changed: 206 additions & 146 deletions

common/arg.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,14 @@ static bool common_params_handle_remote_preset(common_params & params, llama_exa
308308
common_download_opts opts;
309309
opts.bearer_token = params.hf_token;
310310
opts.offline = params.offline;
311+
312+
LOG_TRC("%s: looking for remote preset at %s\n", __func__, preset_url.c_str());
311313
const int status = common_download_file_single(preset_url, preset_path, opts);
312314
const bool has_preset = status >= 200 && status < 400;
313315

314316
// remote preset is optional, so we don't error out if not found
315317
if (has_preset) {
316-
LOG_INF("applying remote preset from %s\n", preset_url.c_str());
318+
LOG_TRC("%s: applying remote preset from %s\n", __func__, preset_url.c_str());
317319
common_preset_context ctx(ex, /* only_remote_allowed */ true);
318320
common_preset global;
319321
auto remote_presets = ctx.load_from_ini(preset_path, global);
@@ -326,7 +328,7 @@ static bool common_params_handle_remote_preset(common_params & params, llama_exa
326328
throw std::runtime_error("Remote preset.ini does not contain [" + std::string(hf_tag) + "] section");
327329
}
328330
} else {
329-
LOG_INF("%s", "no remote preset found, skipping\n");
331+
LOG_TRC("%s: no remote preset found, skipping\n", __func__);
330332
}
331333

332334
return has_preset;
@@ -3301,18 +3303,20 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
33013303
).set_env("LLAMA_LOG_VERBOSITY"));
33023304
add_opt(common_arg(
33033305
{"--log-prefix"},
3306+
{"--no-log-prefix"},
33043307
"Enable prefix in log messages",
3305-
[](common_params &) {
3306-
common_log_set_prefix(common_log_main(), true);
3308+
[](common_params &, bool value) {
3309+
common_log_set_prefix(common_log_main(), value);
33073310
}
3308-
).set_env("LLAMA_LOG_PREFIX"));
3311+
).set_env("LLAMA_ARG_LOG_PREFIX"));
33093312
add_opt(common_arg(
33103313
{"--log-timestamps"},
3314+
{"--no-log-timestamps"},
33113315
"Enable timestamps in log messages",
3312-
[](common_params &) {
3313-
common_log_set_timestamps(common_log_main(), true);
3316+
[](common_params &, bool value) {
3317+
common_log_set_timestamps(common_log_main(), value);
33143318
}
3315-
).set_env("LLAMA_LOG_TIMESTAMPS"));
3319+
).set_env("LLAMA_ARG_LOG_TIMESTAMPS"));
33163320

33173321
//
33183322
// speculative parameters

common/common.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,29 @@ void common_init() {
366366
SetConsoleCP(CP_UTF8);
367367
#endif
368368

369+
common_log_set_prefix(common_log_main(), true);
370+
common_log_set_timestamps(common_log_main(), true);
371+
369372
llama_log_set(common_log_default_callback, NULL);
373+
}
370374

375+
void common_params_print_info(const common_params & params) {
371376
#ifdef NDEBUG
372377
const char * build_type = "";
373378
#else
374379
const char * build_type = " (debug)";
375380
#endif
381+
LOG_TRC("%s: build %d (%s) with %s for %s%s\n", __func__, llama_build_number(), llama_commit(), llama_compiler(), llama_build_target(), build_type);
376382

377-
LOG_DBG("build: %d (%s) with %s for %s%s\n", llama_build_number(), llama_commit(), llama_compiler(), llama_build_target(), build_type);
383+
LOG_INF("log_info: verbosity = %d (adjust with the `-lv N` CLI arg)\n", common_log_get_verbosity_thold());
384+
LOG_INF("device_info:\n");
385+
for (size_t i = 0; i < ggml_backend_dev_count(); ++i) {
386+
auto * dev = ggml_backend_dev_get(i);
387+
size_t free, total;
388+
ggml_backend_dev_memory(dev, &free, &total);
389+
LOG_INF(" - %-8s: %s (%zu MiB, %zu MiB free)\n", ggml_backend_dev_name(dev), ggml_backend_dev_description(dev), total / 1024 / 1024, free / 1024 / 1024);
390+
}
391+
LOG_INF("%s\n", common_params_get_system_info(params).c_str());
378392
}
379393

380394
std::string common_params_get_system_info(const common_params & params) {
@@ -1147,7 +1161,8 @@ common_init_result::common_init_result(common_params & params) :
11471161
auto cparams = common_context_params_to_llama(params);
11481162

11491163
if (params.fit_params) {
1150-
LOG_INF("%s: fitting params to device memory, for bugs during this step try to reproduce them with -fit off, or provide --verbose logs if the bug only occurs with -fit on\n", __func__);
1164+
LOG_INF("%s: fitting params to device memory ...\n", __func__);
1165+
LOG_INF("%s: (for bugs during this step try to reproduce them with -fit off, or provide --verbose logs if the bug only occurs with -fit on)\n", __func__);
11511166
common_fit_params(params.model.path.c_str(), &mparams, &cparams,
11521167
params.tensor_split,
11531168
params.tensor_buft_overrides.data(),
@@ -1196,7 +1211,7 @@ common_init_result::common_init_result(common_params & params) :
11961211
// initialize once
11971212
for (llama_token i = 0; i < llama_vocab_n_tokens(vocab); i++) {
11981213
if (llama_vocab_is_eog(vocab, i)) {
1199-
LOG_INF("%s: added %s logit bias = %f\n", __func__, common_token_to_piece(vocab, i).c_str(), -INFINITY);
1214+
LOG_TRC("%s: added %s logit bias = %f\n", __func__, common_token_to_piece(vocab, i).c_str(), -INFINITY);
12001215
params.sampling.logit_bias_eog.push_back({i, -INFINITY});
12011216
}
12021217
}
@@ -1209,12 +1224,12 @@ common_init_result::common_init_result(common_params & params) :
12091224
}
12101225

12111226
//if (params.sampling.penalty_last_n == -1) {
1212-
// LOG_INF("%s: setting penalty_last_n to ctx_size = %d\n", __func__, llama_n_ctx(lctx));
1227+
// LOG_TRC("%s: setting penalty_last_n to ctx_size = %d\n", __func__, llama_n_ctx(lctx));
12131228
// params.sampling.penalty_last_n = llama_n_ctx(lctx);
12141229
//}
12151230

12161231
//if (params.sampling.dry_penalty_last_n == -1) {
1217-
// LOG_INF("%s: setting dry_penalty_last_n to ctx_size = %d\n", __func__, llama_n_ctx(lctx));
1232+
// LOG_TRC("%s: setting dry_penalty_last_n to ctx_size = %d\n", __func__, llama_n_ctx(lctx));
12181233
// params.sampling.dry_penalty_last_n = llama_n_ctx(lctx);
12191234
//}
12201235

@@ -1422,7 +1437,7 @@ common_context_seq_rm_type common_context_can_seq_rm(llama_context * ctx) {
14221437

14231438
// try to remove the last tokens
14241439
if (!llama_memory_seq_rm(mem, 0, 1, -1)) {
1425-
LOG_WRN("%s: the context does not support partial sequence removal\n", __func__);
1440+
LOG_TRC("%s: the context does not support partial sequence removal\n", __func__);
14261441
res = COMMON_CONTEXT_SEQ_RM_TYPE_FULL;
14271442
goto done;
14281443
}

common/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ struct common_params {
686686
// initializes the logging system and prints info about the build
687687
void common_init();
688688

689+
void common_params_print_info(const common_params & params);
689690
std::string common_params_get_system_info(const common_params & params);
690691

691692
bool parse_cpu_range(const std::string & range, bool(&boolmask)[GGML_MAX_N_THREADS]);

common/download.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ static int common_download_file_single_online(const std::string & url,
320320

321321
auto head = cli.Head(parts.path);
322322
if (!head || head->status < 200 || head->status >= 300) {
323-
LOG_WRN("%s: HEAD failed, status: %d\n", __func__, head ? head->status : -1);
323+
LOG_TRC("%s: HEAD failed, status: %d\n", __func__, head ? head->status : -1);
324324
if (file_exists) {
325-
LOG_INF("%s: using cached file (HEAD failed): %s\n", __func__, path.c_str());
325+
LOG_TRC("%s: using cached file (HEAD failed): %s\n", __func__, path.c_str());
326326
return 304; // 304 Not Modified - fake cached response
327327
}
328328
return head ? head->status : -1;

0 commit comments

Comments
 (0)