Skip to content

Commit ed73e34

Browse files
committed
update debug statements
1 parent ca988db commit ed73e34

File tree

4 files changed

+4
-28
lines changed

4 files changed

+4
-28
lines changed

src/main/cpp/jllama.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ JNIEXPORT void JNICALL Java_de_kherud_llama_LlamaModel_loadModel(JNIEnv *env, jo
358358

359359
auto *ctx_server = new server_context();
360360

361+
std::cout << "New model: " << ctx_server << std::endl;
362+
361363
std::string c_params = parse_jstring(env, jparams);
362364
json json_params = json::parse(c_params);
363365
server_params_parse(json_params, params);
@@ -476,15 +478,12 @@ JNIEXPORT jint JNICALL Java_de_kherud_llama_LlamaModel_requestCompletion(JNIEnv
476478
{
477479
jlong server_handle = env->GetLongField(obj, f_model_pointer);
478480
auto *ctx_server = reinterpret_cast<server_context *>(server_handle); // NOLINT(*-no-int-to-ptr)
479-
480-
std::cout << "DEBUG " << 1 << std::endl;
481+
std::cout << "Request completion: " << ctx_server << std::endl;
481482

482483
std::string c_params = parse_jstring(env, jparams);
483484
json json_params = json::parse(c_params);
484485
const bool infill = json_params.contains("input_prefix") || json_params.contains("input_suffix");
485486

486-
std::cout << "DEBUG " << 2 << std::endl;
487-
488487
if (json_params.value("use_chat_template", false))
489488
{
490489
json chat;
@@ -493,12 +492,8 @@ JNIEXPORT jint JNICALL Java_de_kherud_llama_LlamaModel_requestCompletion(JNIEnv
493492
json_params["prompt"] = format_chat(ctx_server->model, ctx_server->params.chat_template, chat);
494493
}
495494

496-
std::cout << "DEBUG " << 3 << std::endl;
497-
498495
const int id_task = ctx_server->queue_tasks.get_new_id();
499-
std::cout << "DEBUG " << 4 << std::endl;
500496
ctx_server->queue_results.add_waiting_task_id(id_task);
501-
std::cout << "DEBUG " << 5 << std::endl;
502497
ctx_server->request_completion(id_task, -1, json_params, infill, false);
503498

504499
return id_task;
@@ -509,7 +504,6 @@ JNIEXPORT jobject JNICALL Java_de_kherud_llama_LlamaModel_receiveCompletion(JNIE
509504
jlong server_handle = env->GetLongField(obj, f_model_pointer);
510505
auto *ctx_server = reinterpret_cast<server_context *>(server_handle); // NOLINT(*-no-int-to-ptr)
511506

512-
std::cout << "DEBUG " << 8 << std::endl;
513507
server_task_result result = ctx_server->queue_results.recv(id_task);
514508

515509
if (result.error)
@@ -519,14 +513,12 @@ JNIEXPORT jobject JNICALL Java_de_kherud_llama_LlamaModel_receiveCompletion(JNIE
519513
env->ThrowNew(c_llama_error, response.c_str());
520514
return nullptr;
521515
}
522-
std::cout << "DEBUG " << 9 << std::endl;
523516

524517
std::string response = result.data["content"].get<std::string>();
525518
if (result.stop)
526519
{
527520
ctx_server->queue_results.remove_waiting_task_id(id_task);
528521
}
529-
std::cout << "DEBUG " << 10 << std::endl;
530522

531523
jobject o_probabilities = env->NewObject(c_hash_map, cc_hash_map);
532524
if (result.data.contains("completion_probabilities"))
@@ -547,7 +539,6 @@ JNIEXPORT jobject JNICALL Java_de_kherud_llama_LlamaModel_receiveCompletion(JNIE
547539
}
548540
}
549541
}
550-
std::cout << "DEBUG " << 11 << std::endl;
551542

552543
jbyteArray jbytes = parse_jbytes(env, response);
553544
return env->NewObject(c_output, cc_output, jbytes, o_probabilities, result.stop);

src/main/cpp/server.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,8 +1661,6 @@ struct server_context
16611661
task.embedding = embedding;
16621662
task.type = SERVER_TASK_TYPE_COMPLETION;
16631663

1664-
std::cout << "DEBUG " << 6 << std::endl;
1665-
16661664
// when a completion task's prompt array is not a singleton, we split it into multiple requests
16671665
// otherwise, it's a single-prompt task, we actually queue it
16681666
// if there's numbers in the prompt array it will be treated as an array of tokens
@@ -1696,8 +1694,6 @@ struct server_context
16961694
{
16971695
queue_tasks.post(task);
16981696
}
1699-
1700-
std::cout << "DEBUG " << 7 << std::endl;
17011697
}
17021698

17031699
void request_cancel(int id_task)

src/main/cpp/utils.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ static const char *log_level_to_string(ggml_log_level level)
8989
static inline void server_log(ggml_log_level level, const char *function, int line, const char *message,
9090
const json &extra)
9191
{
92-
std::cout << "DEBUG LOG " << 1 << std::endl;
9392
std::stringstream ss_tid;
9493
ss_tid << std::this_thread::get_id();
9594

@@ -120,43 +119,32 @@ static inline void server_log(ggml_log_level level, const char *function, int li
120119
}
121120
else
122121
{
123-
std::cout << "DEBUG LOG " << 2 << std::endl;
124122
std::stringstream ss;
125123
ss << message;
126124

127-
std::cout << "DEBUG LOG " << 3 << std::endl;
128125
if (!extra.empty())
129126
{
130-
std::cout << "DEBUG LOG " << 4 << std::endl;
131127
for (const auto &el : extra.items())
132128
{
133129
const std::string value = el.value().dump(-1, ' ', false, json::error_handler_t::replace);
134130
ss << " " << el.key() << "=" << value;
135131
}
136-
std::cout << "DEBUG LOG " << 5 << std::endl;
137132
}
138133

139-
std::cout << "DEBUG LOG " << 6 << std::endl;
140134
#if SERVER_VERBOSE
141135
ss << " | ts " << time(nullptr) << " | tid " << ss_tid.str() << " | " << function << " line " << line;
142136
#endif
143137

144-
std::cout << "DEBUG LOG " << 7 << std::endl;
145138
const std::string str = ss.str();
146139
if (log_callback == nullptr)
147140
{
148-
std::cout << "DEBUG LOG " << 8 << std::endl;
149141
printf("[%4s] %.*s\n", log_level_to_string(level), (int)str.size(), str.data());
150-
std::cout << "DEBUG LOG " << 9 << std::endl;
151142
}
152143
else
153144
{
154-
std::cout << "DEBUG LOG " << 10 << std::endl;
155145
log_callback(level, str.c_str(), nullptr);
156-
std::cout << "DEBUG LOG " << 11 << std::endl;
157146
}
158147
}
159-
std::cout << "DEBUG LOG " << 12 << std::endl;
160148
fflush(stdout);
161149
}
162150

src/main/java/de/kherud/llama/LlamaModel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class LlamaModel implements AutoCloseable {
4242
*/
4343
public LlamaModel(ModelParameters parameters) {
4444
loadModel(parameters.toString());
45+
System.out.println(ctx);
4546
}
4647

4748
/**

0 commit comments

Comments
 (0)