Skip to content

Commit 290f6a9

Browse files
committed
server : fix server_tokens clear()
1 parent e7b7cbf commit 290f6a9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

tools/server/server.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3946,8 +3946,11 @@ struct server_context {
39463946

39473947
// truncate any tokens that are beyond n_past for this slot
39483948
const llama_pos p0 = slot.prompt.tokens.pos_next();
3949+
3950+
SLT_INF(slot, "n_tokens = %d, memory_seq_rm [%d, end)\n", slot.prompt.n_tokens(), p0);
3951+
39493952
if (!llama_memory_seq_rm(llama_get_memory(ctx), slot.id, p0, -1)) {
3950-
SLT_WRN(slot, "failed to truncate tokens with position >= %d\n", p0);
3953+
SLT_WRN(slot, "failed to truncate tokens with position >= %d - clearing the memory\n", p0);
39513954
llama_memory_seq_rm(llama_get_memory(ctx), slot.id, -1, -1);
39523955

39533956
// there is no common part left
@@ -3956,8 +3959,6 @@ struct server_context {
39563959
slot.prompt.tokens.clear();
39573960
}
39583961

3959-
SLT_INF(slot, "n_tokens = %d, memory_seq_rm [%d, end)\n", slot.prompt.n_tokens(), p0);
3960-
39613962
// check if we should process the image
39623963
if (slot.prompt.n_tokens() < slot.task->n_tokens() && input_tokens[slot.prompt.n_tokens()] == LLAMA_TOKEN_NULL) {
39633964
// process the image

tools/server/utils.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ struct server_tokens {
12121212
for (auto it = tokens.map_idx_to_media.begin(); it != tokens.map_idx_to_media.end(); ) {
12131213
auto * chunk = tokens.map_idx_to_media[it->first].get();
12141214
mtmd::input_chunk_ptr new_chunk(mtmd_input_chunk_copy(chunk));
1215-
map_idx_to_media[start_idx+it->first] = std::move(new_chunk);
1215+
map_idx_to_media[start_idx + it->first] = std::move(new_chunk);
12161216
}
12171217
}
12181218
}
@@ -1244,6 +1244,7 @@ struct server_tokens {
12441244
}
12451245

12461246
void clear() {
1247+
map_idx_to_media.clear();
12471248
tokens.clear();
12481249
}
12491250

0 commit comments

Comments
 (0)