]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama : update llama_timings.n_p_eval setting (#7160)
authorDaniel Bevenius <redacted>
Thu, 9 May 2024 11:03:29 +0000 (13:03 +0200)
committerGitHub <redacted>
Thu, 9 May 2024 11:03:29 +0000 (14:03 +0300)
This commit changes the value assigned to llama_timings.n_p_eval when
ctx->n_p_eval is 0 to be 1 instead of 1 which is the current value.

The motivation for this change is that if session caching is enabled,
for example using the `--prompt-cache main-session.txt` command line
argument for the main example, and if the same prompt is used then on
subsequent runs, the prompt tokens will not actually be passed to
llama_decode, and n_p_eval will not be updated by llama_synchoronize.

But the value of n_p_eval will be set 1 by llama_get_timings because
ctx->n_p_eval will be 0. This could be interpreted as 1 token was
evaluated for the prompt which could be misleading for applications
using this value.

Signed-off-by: Daniel Bevenius <redacted>
llama.cpp

index 9c72d118f2db2d35d6d247cc36f2a70813da3f84..806c2093262b1f5103911049124b286a1d2a21d2 100644 (file)
--- a/llama.cpp
+++ b/llama.cpp
@@ -17879,7 +17879,7 @@ struct llama_timings llama_get_timings(struct llama_context * ctx) {
         /*.t_eval_ms   =*/ 1e-3 * ctx->t_eval_us,
 
         /*.n_sample =*/ std::max(1, ctx->n_sample),
-        /*.n_p_eval =*/ std::max(1, ctx->n_p_eval),
+        /*.n_p_eval =*/ std::max(0, ctx->n_p_eval),
         /*.n_eval   =*/ std::max(1, ctx->n_eval),
     };