Skip to content

Commit

Permalink
fixup! lookup: evaluation tools, use corpus/previous gens
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesGaessler committed Mar 22, 2024
1 parent 3106005 commit acb5375
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
9 changes: 8 additions & 1 deletion common/ngram-cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ void llama_ngram_cache_update(llama_ngram_cache & ngram_cache, int ngram_min, in
const long eta_min = eta_ms / (60*1000);
const long eta_s = (eta_ms - 60*1000*eta_min) / 1000;

fprintf(stderr, "%s: %ld/%ld done, ETA: %02ld:%02ld\n", __func__, n_done, n_todo, eta_min, eta_s);
// %02ld doesn't compile on Arm64 MacOS:
std::string eta_string;
eta_string += eta_min < 10 ? "0" : "";
eta_string += std::to_string(eta_min);
eta_string += ":";
eta_string += eta_s < 10 ? "0" : "";
eta_string += std::to_string(eta_s);
fprintf(stderr, "%s: %ld/%ld done, ETA: %s\n", __func__, n_done, n_todo, eta_string.c_str());
}
}
}
Expand Down
21 changes: 14 additions & 7 deletions examples/lookup/lookup-stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int main(int argc, char ** argv){
int n_drafted = 0;
int n_accept = 0;

const int64_t t_start_ms = ggml_time_ms();
const long t_start_ms = ggml_time_ms();

// Iterate over input tokens in chunks of size n_ctx.
// Each chunk is treated as if a sequential generation but with pre-determined tokens to ensure reproducibility.
Expand Down Expand Up @@ -127,12 +127,19 @@ int main(int argc, char ** argv){

}
if (i_start > 0 && i_start / 100000 != (i_start - n_ctx) / 100000) {
const int64_t t_now_ms = ggml_time_ms();
const int64_t eta_ms = (n_input - i_start) * (t_now_ms - t_start_ms) / i_start;
const int64_t eta_min = eta_ms / (60*1000);
const int64_t eta_s = (eta_ms - 60*1000*eta_min) / 1000;

LOG_TEE("%d/%d done, ETA: %02ld:%02ld\n", i_start, n_input, eta_min, eta_s);
const long t_now_ms = ggml_time_ms();
const long eta_ms = (n_input - i_start) * (t_now_ms - t_start_ms) / i_start;
const long eta_min = eta_ms / (60*1000);
const long eta_s = (eta_ms - 60*1000*eta_min) / 1000;

// %02ld doesn't compile on Arm64 MacOS:
std::string eta_string;
eta_string += eta_min < 10 ? "0" : "";
eta_string += std::to_string(eta_min);
eta_string += ":";
eta_string += eta_s < 10 ? "0" : "";
eta_string += std::to_string(eta_s);
LOG_TEE("lookup-stats: %d/%d done, ETA: %s\n", i_start, n_input, eta_string.c_str());
}

// After each chunk, update the dynamic ngram cache with the context ngram cache:
Expand Down

0 comments on commit acb5375

Please sign in to comment.