Skip to content

Commit b5ce8df

Browse files
committed
cont : handle failures to restore the old state
1 parent 08a3c4a commit b5ce8df

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tools/llama-bench/llama-bench.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,10 +2144,18 @@ int main(int argc, char ** argv) {
21442144
llama_memory_clear(llama_get_memory(ctx), false);
21452145

21462146
if (t.n_depth > 0) {
2147+
bool reprocess = true;
2148+
21472149
if (t.n_depth == cstate.depth) {
21482150
// if previously we have computed at this depth, just restore the state
2149-
llama_state_seq_set_data(ctx, cstate.buf.data(), cstate.buf.size(), 0);
2150-
} else {
2151+
const size_t ret = llama_state_seq_set_data(ctx, cstate.buf.data(), cstate.buf.size(), 0);
2152+
if (ret > 0) {
2153+
// if the old state is incompatible with the current context - reprocess from scratch
2154+
reprocess = false;
2155+
}
2156+
}
2157+
2158+
if (reprocess) {
21512159
if (params.progress) {
21522160
fprintf(stderr, "llama-bench: benchmark %d/%zu: depth run %d/%d\n", params_idx, params_count,
21532161
i + 1, params.reps);

0 commit comments

Comments
 (0)