Skip to content

Commit 40638f7

Browse files
committed
log : cleanup, comments, build flags
ggml-ci
1 parent 13226dc commit 40638f7

File tree

7 files changed

+30
-34
lines changed

7 files changed

+30
-34
lines changed

Makefile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ GGML_NO_METAL := 1
149149
DEPRECATE_WARNING := 1
150150
endif
151151

152+
ifdef LLAMA_DISABLE_LOGS
153+
REMOVE_WARNING := 1
154+
endif
155+
156+
ifdef LLAMA_SERVER_VERBOSE
157+
REMOVE_WARNING := 1
158+
endif
159+
152160
ifndef UNAME_S
153161
UNAME_S := $(shell uname -s)
154162
endif
@@ -352,19 +360,11 @@ ifdef LLAMA_SANITIZE_UNDEFINED
352360
MK_LDFLAGS += -fsanitize=undefined -g
353361
endif
354362

355-
ifdef LLAMA_SERVER_VERBOSE
356-
MK_CPPFLAGS += -DSERVER_VERBOSE=$(LLAMA_SERVER_VERBOSE)
357-
endif
358-
359363
ifdef LLAMA_SERVER_SSL
360364
MK_CPPFLAGS += -DCPPHTTPLIB_OPENSSL_SUPPORT
361365
MK_LDFLAGS += -lssl -lcrypto
362366
endif
363367

364-
ifdef LLAMA_DISABLE_LOGS
365-
MK_CPPFLAGS += -DLOG_DISABLE_LOGS
366-
endif # LLAMA_DISABLE_LOGS
367-
368368
# warnings
369369
WARN_FLAGS = \
370370
-Wall \
@@ -1029,6 +1029,14 @@ $(info - LLAMA_NO_CCACHE)
10291029
$(info )
10301030
endif
10311031

1032+
ifdef REMOVE_WARNING
1033+
$(info !!! REMOVAL WARNING !!!)
1034+
$(info The following LLAMA_ options have been removed and are no longer supported)
1035+
$(info - LLAMA_DISABLE_LOGS (https://github.com/ggerganov/llama.cpp/pull/9418))
1036+
$(info - LLAMA_SERVER_VERBOSE (https://github.com/ggerganov/llama.cpp/pull/9418))
1037+
$(info )
1038+
endif
1039+
10321040
#
10331041
# Build libraries
10341042
#

common/common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ struct gpt_params {
341341
bool batched_bench_output_jsonl = false;
342342
};
343343

344-
// call once at the start of a program using common
344+
// call once at the start of a program if it uses libcommon
345+
// initializes the logging system and prints info about the build
345346
void gpt_init();
346347

347348
std::string gpt_params_get_system_info(const gpt_params & params);

common/log.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ struct gpt_log_entry {
6969
void print(FILE * file = nullptr) const {
7070
FILE * fcur = file;
7171
if (!fcur) {
72-
// stderr displays DBG messages only when the verbosity is high
73-
// these messages can still be logged to a file
72+
// stderr displays DBG messages only when their verbosity level is not higher than the threshold
73+
// these messages will still be logged to a file
7474
if (level == GGML_LOG_LEVEL_DEBUG && gpt_log_verbosity_thold < LOG_DEFAULT_DEBUG) {
7575
return;
7676
}

common/log.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "ggml.h"
3+
#include "ggml.h" // for ggml_log_level
44

55
#ifndef __GNUC__
66
# define LOG_ATTRIBUTE_FORMAT(...)
@@ -48,7 +48,10 @@ void gpt_log_add(struct gpt_log * log, enum ggml_log_level level, const char * f
4848
// 0.00.090.578 I llm_load_tensors: offloading 32 repeating layers to GPU
4949
// 0.00.090.579 I llm_load_tensors: offloading non-repeating layers to GPU
5050
//
51-
// I - info, W - warning, E - error, D - debug
51+
// I - info (stdout, V = 0)
52+
// W - warning (stderr, V = 0)
53+
// E - error (stderr, V = 0)
54+
// D - debug (stderr, V = LOG_DEFAULT_DEBUG)
5255
//
5356

5457
void gpt_log_set_file (struct gpt_log * log, const char * file); // not thread-safe
@@ -57,13 +60,13 @@ void gpt_log_set_prefix (struct gpt_log * log, bool prefix); // w
5760
void gpt_log_set_timestamps(struct gpt_log * log, bool timestamps); // whether to output timestamps in the prefix
5861

5962
// helper macros for logging
60-
// use these to avoid computing log arguments if the verbosity is lower than the threshold
63+
// use these to avoid computing log arguments if the verbosity of the log is higher than the threshold
6164
//
6265
// for example:
6366
//
6467
// LOG_DBG("this is a debug message: %d\n", expensive_function());
6568
//
66-
// this will avoid calling expensive_function() if the verbosity is lower than LOG_DEFAULT_DEBUG
69+
// this will avoid calling expensive_function() if LOG_DEFAULT_DEBUG > gpt_log_verbosity_thold
6770
//
6871

6972
#define LOG_TMPL(level, verbosity, ...) \

examples/llava/clip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#define LOG_INF(...) do { fprintf(stdout, __VA_ARGS__); } while (0)
4343
#define LOG_WRN(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
4444
#define LOG_ERR(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
45-
#define LOG_DBG(...) do { fprintf(stdout, __VA_ARGS__); } while (0)
45+
#define LOG_DBG(...) do { fprintf(stderr, __VA_ARGS__); } while (0)
4646

4747
//#define CLIP_DEBUG_FUNCTIONS
4848

examples/server/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set(TARGET llama-server)
2-
option(LLAMA_SERVER_VERBOSE "Build verbose logging option for Server" ON)
3-
option(LLAMA_SERVER_SSL "Build SSL support for the server" OFF)
2+
3+
option(LLAMA_SERVER_SSL "Build SSL support for the server" OFF)
44

55
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
66

@@ -45,9 +45,6 @@ endforeach()
4545

4646
add_executable(${TARGET} ${TARGET_SRCS})
4747
install(TARGETS ${TARGET} RUNTIME)
48-
target_compile_definitions(${TARGET} PRIVATE
49-
SERVER_VERBOSE=$<BOOL:${LLAMA_SERVER_VERBOSE}>
50-
)
5148

5249
target_link_libraries(${TARGET} PRIVATE common ${CMAKE_THREAD_LIBS_INIT})
5350

examples/server/server.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,13 +2077,6 @@ struct server_context {
20772077
slot_npast++;
20782078
}
20792079

2080-
//LOG_VERBOSE("prompt processing progress", {
2081-
// {"id_slot", slot.id},
2082-
// {"n_past", slot.n_past},
2083-
// {"n_ctx", n_ctx},
2084-
// {"n_tokens", batch.n_tokens},
2085-
// {"progress", (float) slot.n_prompt_tokens_processed / slot.n_prompt_tokens},
2086-
//});
20872080
SLT_INF(slot, "prompt processing progress, n_past = %d, n_tokens = %d, progress = %f\n", slot.n_past, batch.n_tokens, (float) slot.n_prompt_tokens_processed / slot.n_prompt_tokens);
20882081

20892082
// entire prompt has been processed
@@ -2098,12 +2091,6 @@ struct server_context {
20982091
slot.n_decoded = 0;
20992092
slot.i_batch = batch.n_tokens - 1;
21002093

2101-
//LOG_VERBOSE("prompt done", {
2102-
// {"id_slot", slot.id},
2103-
// {"n_past", slot.n_past},
2104-
// {"n_ctx", n_ctx},
2105-
// {"n_tokens", batch.n_tokens},
2106-
//});
21072094
SLT_INF(slot, "prompt done, n_past = %d, n_tokens = %d\n", slot.n_past, batch.n_tokens);
21082095
}
21092096
}

0 commit comments

Comments
 (0)