Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

runner: discard compute results if sequence replaced mid-batch (#14072)

Jeffrey Morganf7102ba8262a
diff --git a/runner/ollamarunner/runner.go b/runner/ollamarunner/runner.go
index 2aa892080..048facde8 100644
--- a/runner/ollamarunner/runner.go
+++ b/runner/ollamarunner/runner.go
@@ -740,7 +740,11 @@ func (s *Server) computeBatch(activeBatch batchState) {
if seq == nil || nextBatchTokens[i] == nil {
continue
}
-
+ // If the sequence was replaced while this batch was computing, discard results.
+ if activeBatch.seqs[i] != seq {
+ logutil.Trace("computeBatch: sequence replaced, discarding its results", "batchID", activeBatch.id, "seqIdx", i)
+ continue
+ }
seq.lastUpdatedAt = t
if seq.numPredicted == 1 {
seq.processingDuration = seq.lastUpdatedAt.Sub(seq.startedAt)