Skip to content

Commit

Permalink
fix(cpp): progress_callback patch (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 authored Dec 20, 2024
1 parent 5328e6b commit b8d0f20
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
6 changes: 4 additions & 2 deletions cpp/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,8 +1001,10 @@ struct llama_model_params common_model_params_to_llama(const common_params & par
mparams.kv_overrides = params.kv_overrides.data();
}

mparams.progress_callback = params.progress_callback;
mparams.progress_callback_user_data = params.progress_callback_user_data;
if (params.progress_callback != nullptr) {
mparams.progress_callback = params.progress_callback;
mparams.progress_callback_user_data = params.progress_callback_user_data;
}

return mparams;
}
Expand Down
4 changes: 2 additions & 2 deletions cpp/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ struct common_params {
bool warmup = true; // warmup run
bool check_tensors = false; // validate tensor data

llama_progress_callback progress_callback;
void * progress_callback_user_data;
llama_progress_callback progress_callback = nullptr;
void * progress_callback_user_data = nullptr;

std::string cache_type_k = "f16"; // KV cache data type for the K
std::string cache_type_v = "f16"; // KV cache data type for the V
Expand Down
19 changes: 11 additions & 8 deletions scripts/common.cpp.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- common.cpp.orig 2024-11-21 11:03:19
+++ common.cpp 2024-11-21 11:03:20
--- common.cpp.orig 2024-12-20 13:06:22
+++ common.cpp 2024-12-20 13:05:42
@@ -4,10 +4,6 @@

#include "common.h"
Expand Down Expand Up @@ -42,20 +42,23 @@
mparams.rpc_servers = params.rpc_servers.c_str();
mparams.main_gpu = params.main_gpu;
mparams.split_mode = params.split_mode;
@@ -999,6 +1001,9 @@
@@ -999,6 +1001,11 @@
mparams.kv_overrides = params.kv_overrides.data();
}

+ mparams.progress_callback = params.progress_callback;
+ mparams.progress_callback_user_data = params.progress_callback_user_data;
+ if (params.progress_callback != nullptr) {
+ mparams.progress_callback = params.progress_callback;
+ mparams.progress_callback_user_data = params.progress_callback_user_data;
+ }
+
return mparams;
}

@@ -1124,220 +1129,6 @@
@@ -1123,221 +1130,7 @@

return false;
}

-
-static bool common_download_file(const std::string & url, const std::string & path, const std::string & hf_token) {
-
- // Initialize libcurl
Expand Down Expand Up @@ -95,7 +98,7 @@
- nlohmann::json metadata;
- std::string etag;
- std::string last_modified;
-

- if (file_exists) {
- // Try and read the JSON metadata file (note: stream autoclosed upon exiting this block).
- std::ifstream metadata_in(metadata_path);
Expand Down
8 changes: 4 additions & 4 deletions scripts/common.h.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- common.h.orig 2024-11-21 10:21:53
+++ common.h 2024-11-21 10:23:00
--- common.h.orig 2024-12-20 13:06:22
+++ common.h 2024-12-20 13:05:53
@@ -41,6 +41,17 @@

struct common_control_vector_load_info;
Expand Down Expand Up @@ -30,8 +30,8 @@
bool warmup = true; // warmup run
bool check_tensors = false; // validate tensor data

+ llama_progress_callback progress_callback;
+ void * progress_callback_user_data;
+ llama_progress_callback progress_callback = nullptr;
+ void * progress_callback_user_data = nullptr;
+
std::string cache_type_k = "f16"; // KV cache data type for the K
std::string cache_type_v = "f16"; // KV cache data type for the V
Expand Down

0 comments on commit b8d0f20

Please sign in to comment.