Skip to content

Commit 9e59105

Browse files
committed
Using -1 for start/end positions in Conversation. This eliminate the possibility of KV cache leaks due to bugs with _end getting out of sync.
1 parent ce8eeb4 commit 9e59105

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

LLama/Batched/Conversation.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void Dispose()
8484
_disposed = true;
8585

8686
// Remove this conversation from the KV cache
87-
Executor.Context.NativeHandle.KvCacheRemove(ConversationId, 0, _end);
87+
Executor.Context.NativeHandle.KvCacheRemove(ConversationId, -1, -1);
8888

8989
// Prevent finalizer from running
9090
GC.SuppressFinalize(this);
@@ -419,8 +419,7 @@ public void Remove(LLamaPos start, int count)
419419
if (count <= 0)
420420
return;
421421

422-
var end = start.Value + count;
423-
_conversation.Executor.Context.NativeHandle.KvCacheRemove(_conversation.ConversationId, start, end);
422+
_conversation.Executor.Context.NativeHandle.KvCacheRemove(_conversation.ConversationId, start, -1);
424423
}
425424
#endregion
426425

0 commit comments

Comments
 (0)