Skip to content

Commit 0ca0399

Browse files
ggerganovMinh141120
authored andcommitted
kv-cache : add LLAMA_KV_CACHE_DEBUG environment variable (ggml-org#14121)
1 parent cc88e69 commit 0ca0399

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/llama-kv-cache-unified.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ llama_kv_cache_unified::llama_kv_cache_unified(
156156

157157
const char * LLAMA_KV_CACHE_DEBUG = getenv("LLAMA_KV_CACHE_DEBUG");
158158
debug = LLAMA_KV_CACHE_DEBUG ? atoi(LLAMA_KV_CACHE_DEBUG) : 0;
159+
160+
const char * LLAMA_KV_CACHE_DEBUG = getenv("LLAMA_KV_CACHE_DEBUG");
161+
debug = LLAMA_KV_CACHE_DEBUG ? atoi(LLAMA_KV_CACHE_DEBUG) : 0;
159162
}
160163

161164
void llama_kv_cache_unified::clear(bool data) {
@@ -556,8 +559,11 @@ int32_t llama_kv_cache_unified::find_slot(const llama_ubatch & ubatch) const {
556559
}
557560

558561
if (debug > 0) {
562+
LLAMA_LOG_CONT("\n");
559563
LLAMA_LOG_DEBUG("%s: n = %5d, used = %5d, head = %5d, size = %5d, n_swa = %5d\n", __func__, cells.used_max_p1(), cells.get_used(), head, get_size(), n_swa);
560564

565+
if ((debug == 2 && n_swa > 0) || debug > 2) {
566+
std::string ss;
561567
if ((debug == 2 && n_swa > 0) || debug > 2) {
562568
std::string ss;
563569
for (uint32_t i = 0; i < cells.size(); ++i) {
@@ -604,14 +610,17 @@ int32_t llama_kv_cache_unified::find_slot(const llama_ubatch & ubatch) const {
604610
LLAMA_LOG_DEBUG("\n%s\n", ss.c_str());
605611
}
606612

607-
for (int s = 0; s < LLAMA_MAX_SEQ; ++s) {
613+
for (int s = 0; s < LLAMA_MAX_PARALLEL_SEQUENCES; ++s) {
608614
if (cells.seq_pos_min(s) < 0) {
609615
continue;
610616
}
611617

612618
LLAMA_LOG_DEBUG("%s: min[%d] = %5d, max[%d] = %5d\n", __func__, s, cells.seq_pos_min(s), s, cells.seq_pos_max(s));
613619
}
614620
}
621+
LLAMA_LOG_DEBUG("%s: min[%d] = %5d, max[%d] = %5d\n", __func__, s, cells.seq_pos_min(s), s, cells.seq_pos_max(s));
622+
}
623+
}
615624

616625
uint32_t n_tested = 0;
617626

0 commit comments

Comments
 (0)