diff --git a/common/common.cpp b/common/common.cpp index 27785e92b375c5..9ca9e2850a83e5 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -1120,6 +1120,15 @@ struct llama_context_params llama_context_params_from_gpt_params(const gpt_param } void llama_batch_clear(struct llama_batch & batch) { + for (int token = 0; token < batch.n_tokens; token++) { + batch.token[token] = 0; + batch.pos[token] = -1; + batch.logits[token] = false; + for (int seq_id = 0; seq_id < batch.n_seq_id[token]; seq_id++) { + batch.seq_id[token][seq_id] = 0; + } + batch.n_seq_id[token] = 0; + } batch.n_tokens = 0; } @@ -1621,7 +1630,7 @@ void dump_kv_cache_view(const llama_kv_cache_view & view, int row_size) { for (int j = 0; j < view.n_max_seq; j++) { if (cs_curr[j] >= 0) { seq_count++; } } - putchar(slot_chars[std::min(sizeof(slot_chars) - 2, size_t(seq_count))]); + printf("%4d ",c_curr->pos); } printf("\n=== Done dumping\n"); @@ -1642,7 +1651,7 @@ void dump_kv_cache_view_seqs(const llama_kv_cache_view & view, int row_size) { if (cs_curr[j] < 0) { continue; } if (seqs.find(cs_curr[j]) == seqs.end()) { if (seqs.size() + 1 >= sizeof(slot_chars)) { break; } - seqs[cs_curr[j]] = seqs.size(); + seqs[cs_curr[j]] = cs_curr[j]; } } if (seqs.size() + 1 >= sizeof(slot_chars)) { break; } @@ -1668,7 +1677,8 @@ void dump_kv_cache_view_seqs(const llama_kv_cache_view & view, int row_size) { putchar('.'); } } - putchar(' '); + printf(" (%d) ", c_curr->pos); + //putchar(' '); } printf("\n=== Done dumping\n");