Skip to content

Commit

Permalink
formatting: break overly long LOG lines
Browse files Browse the repository at this point in the history
  • Loading branch information
staviq committed Sep 17, 2023
1 parent 28cdd8c commit 06e5c19
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
32 changes: 24 additions & 8 deletions examples/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,22 @@ int main(int argc, char ** argv) {
} else if (n_matching_session_tokens >= embd_inp.size()) {
LOG_TEE("%s: session file has exact match for prompt!\n", __func__);
} else if (n_matching_session_tokens < (embd_inp.size() / 2)) {
LOG_TEE("%s: warning: session file has low similarity to prompt (%zu / %zu tokens); will mostly be reevaluated\n",
__func__, n_matching_session_tokens, embd_inp.size());
LOG_TEE(
"%s: warning: session file has low similarity to prompt (%zu / %zu tokens);"
" will mostly be reevaluated\n",
__func__, n_matching_session_tokens, embd_inp.size()
);
} else {
LOG_TEE("%s: session file matches %zu / %zu tokens of prompt\n",
__func__, n_matching_session_tokens, embd_inp.size());
}
}

LOGLN(
"recalculate the cached logits (check): embd_inp.empty() %s, n_matching_session_tokens %zu, embd_inp.size() %zu, session_tokens.size() %zu, embd_inp.size() %zu",
log_tostr(embd_inp.empty()), n_matching_session_tokens, embd_inp.size(), session_tokens.size(), embd_inp.size());
"recalculate the cached logits (check): embd_inp.empty() %s, n_matching_session_tokens %zu,"
" embd_inp.size() %zu, session_tokens.size() %zu, embd_inp.size() %zu",
log_tostr(embd_inp.empty()), n_matching_session_tokens, embd_inp.size(), session_tokens.size(), embd_inp.size()
);

// if we will use the cache for the full prompt without reaching the end of the cache, force
// reevaluation of the last token token to recalculate the cached logits
Expand Down Expand Up @@ -402,9 +407,17 @@ int main(int argc, char ** argv) {
LOG_TEE("Input suffix: '%s'\n", params.input_suffix.c_str());
}
}
LOG_TEE("sampling: repeat_last_n = %d, repeat_penalty = %f, presence_penalty = %f, frequency_penalty = %f, top_k = %d, tfs_z = %f, top_p = %f, typical_p = %f, temp = %f, mirostat = %d, mirostat_lr = %f, mirostat_ent = %f\n",
params.repeat_last_n, params.repeat_penalty, params.presence_penalty, params.frequency_penalty, params.top_k, params.tfs_z, params.top_p, params.typical_p, params.temp, params.mirostat, params.mirostat_eta, params.mirostat_tau);
LOG_TEE("generate: n_ctx = %d, n_batch = %d, n_predict = %d, n_keep = %d\n", n_ctx, params.n_batch, params.n_predict, params.n_keep);
LOG_TEE(
"sampling: repeat_last_n = %d, repeat_penalty = %f, presence_penalty = %f,"
" frequency_penalty = %f, top_k = %d, tfs_z = %f, top_p = %f, typical_p = %f,"
" temp = %f, mirostat = %d, mirostat_lr = %f, mirostat_ent = %f\n",
params.repeat_last_n, params.repeat_penalty, params.presence_penalty,
params.frequency_penalty, params.top_k, params.tfs_z, params.top_p, params.typical_p,
params.temp, params.mirostat, params.mirostat_eta, params.mirostat_tau
);
LOG_TEE(
"generate: n_ctx = %d, n_batch = %d, n_predict = %d, n_keep = %d\n",
n_ctx, params.n_batch, params.n_predict, params.n_keep);
LOG_TEE("\n\n");

struct llama_grammar * grammar = NULL;
Expand Down Expand Up @@ -509,7 +522,10 @@ int main(int argc, char ** argv) {
}

const int n_left = n_past - params.n_keep;
LOG("context full, swapping: n_past = %d, n_left = %d, n_ctx = %d, n_keep = %d\n", n_past, n_left, n_ctx, params.n_keep);
LOG(
"context full, swapping: n_past = %d, n_left = %d, n_ctx = %d, n_keep = %d\n",
n_past, n_left, n_ctx, params.n_keep
);

// always keep the first token - BOS
n_past = std::max(1, params.n_keep);
Expand Down
26 changes: 20 additions & 6 deletions examples/speculative/speculative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ int main(int argc, char ** argv) {

// check if the draft matches the target
if (i_dft < (int) drafted.size() && id == drafted[i_dft]) {
LOG("the sampled target token matches the %dth drafted token (%d, '%s') - accepted\n", i_dft, id, token_str.c_str());
LOG(
"the sampled target token matches the %dth drafted token (%d, '%s') - accepted\n",
i_dft, id, token_str.c_str()
);
++n_accept;
++n_past_tgt;
++n_past_dft;
Expand All @@ -166,8 +169,10 @@ int main(int argc, char ** argv) {
// the drafted token was rejected or we are out of drafted tokens

if (i_dft < (int) drafted.size()) {
LOG("the %dth drafted token (%d, '%s') does not match the sampled target token (%d, '%s') - rejected\n",
i_dft, drafted[i_dft], llama_token_to_piece(ctx_dft, drafted[i_dft]).c_str(), id, token_str.c_str());
LOG(
"the %dth drafted token (%d, '%s') does not match the sampled target token (%d, '%s') - rejected\n",
i_dft, drafted[i_dft], llama_token_to_piece(ctx_dft, drafted[i_dft]).c_str(), id, token_str.c_str()
);
} else {
LOG("out of drafted tokens\n");
}
Expand Down Expand Up @@ -235,7 +240,10 @@ int main(int argc, char ** argv) {
llama_sample_softmax(ctx_dft, &cur_p);

for (int i = 0; i < 3; ++i) {
LOG(" - draft candidate %3d: %6d (%8.3f) '%s'\n", i, cur_p.data[i].id, cur_p.data[i].p, llama_token_to_piece(ctx_dft, cur_p.data[i].id).c_str());
LOG(
" - draft candidate %3d: %6d (%8.3f) '%s'\n",
i, cur_p.data[i].id, cur_p.data[i].p, llama_token_to_piece(ctx_dft, cur_p.data[i].id).c_str()
);
}

// TODO: better logic?
Expand Down Expand Up @@ -276,8 +284,14 @@ int main(int argc, char ** argv) {

LOG_TEE("\n\n");

LOG_TEE("encoded %4d tokens in %8.3f seconds, speed: %8.3f t/s\n", n_input, (t_enc_end - t_enc_start) / 1e6f, inp.size() / ((t_enc_end - t_enc_start) / 1e6f));
LOG_TEE("decoded %4d tokens in %8.3f seconds, speed: %8.3f t/s\n", n_predict, (t_dec_end - t_dec_start) / 1e6f, n_predict / ((t_dec_end - t_dec_start) / 1e6f));
LOG_TEE(
"encoded %4d tokens in %8.3f seconds, speed: %8.3f t/s\n",
n_input, (t_enc_end - t_enc_start) / 1e6f, inp.size() / ((t_enc_end - t_enc_start) / 1e6f)
);
LOG_TEE(
"decoded %4d tokens in %8.3f seconds, speed: %8.3f t/s\n",
n_predict, (t_dec_end - t_dec_start) / 1e6f, n_predict / ((t_dec_end - t_dec_start) / 1e6f)
);

// TODO: make sure these numbers are computed correctly
LOG_TEE("\n");
Expand Down

0 comments on commit 06e5c19

Please sign in to comment.