From 5a441d227a6f4d7995d0489ed752b2ab53ceae86 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Wed, 14 Aug 2024 10:32:05 -0700 Subject: [PATCH] runner.go: Don't decode if nothing has been added to the batch If nothing has been added to a batch then decoding will fail if attempted. This can happen, for example, if the run loop is woken up but we realize that we have the generation limit. --- llama/runner/runner.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llama/runner/runner.go b/llama/runner/runner.go index c0bc8b6a..43a70f30 100644 --- a/llama/runner/runner.go +++ b/llama/runner/runner.go @@ -184,6 +184,10 @@ func (s *Server) run(ctx context.Context) { seq.iBatch = batch.NumTokens() - 1 } + if batch.NumTokens() == 0 { + continue + } + err := s.lc.Decode(batch) if err != nil { slog.Error("failed to decode batch", "error", err)