From 63b3776e1a337b63c2d16f052a2a7182489e00d2 Mon Sep 17 00:00:00 2001 From: KerfuffleV2 Date: Fri, 3 Nov 2023 15:02:47 -0600 Subject: [PATCH] Fix invalid seqnum in commands when seqnum ommitted in some cases. --- examples/simple-inference/simple-inference.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/simple-inference/simple-inference.cpp b/examples/simple-inference/simple-inference.cpp index 9aceb87de..857341719 100644 --- a/examples/simple-inference/simple-inference.cpp +++ b/examples/simple-inference/simple-inference.cpp @@ -415,6 +415,9 @@ bool gen_ctx::init_batches() { ctxs_seq.push_back(bs); // if (i > 0) llama_kv_cache_seq_cp(ctx, 0, i, 0, prompt_size); } + if (!ctxs_seq.empty()) { + focused_sequence = ctxs_seq.size() - 1; + } return true; } @@ -536,7 +539,7 @@ void gen_ctx::dump_batches(const size_t prompt_start) { #ifndef LLAMA_NO_SEQREP_SAMPLER printf(", rewind cnt/toks: %zu/%zu", sctx.rewind_count, sctx.rewind_tokens); #endif - puts("):"); + printf("%s):", sctx.state == SEQ_DONE ? ", DONE" : ""); dump_chunks(sctx.chunks, prompt_start); first = false; } @@ -785,7 +788,7 @@ static bool handle_commands(gen_ctx & gctx) { printf(" /[SEQ]addesc TEXT : Same as /add but handles escapes (\\n, \\x20, etc) and tokenizes without a leading space. Alias: /ae\n"); printf(" /[SEQ]addline TEXT : Same as /add but appends a newline. Alias: /al\n"); printf(" /help : Show this help. Alias: /h\n"); - printf(" /[SEQ]dump N : Dump the last N tokens of SEQ showing offsets from the end. Alias: /d\n"); + printf(" /[SEQ]dump [N] : Dump the last N tokens of SEQ showing offsets from the end. N defaults to 200 if not specified. Alias: /d\n"); printf(" /[SEQ]dumptokens N : Same as /dump but displays token IDs as well. Alias: /dt\n"); printf(" /[SEQ]kill : Stop sequence SEQ. Alias: /k\n"); printf(" /list : List sequences and their state. Alias: /l\n"); @@ -798,7 +801,7 @@ static bool handle_commands(gen_ctx & gctx) { if (command == "q" || command == "quit") return false; - llama_seq_id target = -1; + llama_seq_id target = gctx.focused_sequence; // Focus if (isdigit(command[0])) {