[PR #14430] [MERGED] mlxrunner: Fix panic on full KV cache hit #25212

Closed
opened 2026-04-19 18:04:44 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/14430
Author: @jessegross
Created: 2/26/2026
Status: Merged
Merged: 2/27/2026
Merged by: @jessegross

Base: mainHead: jessegross/mlx-fullcache


📝 Commits (1)

  • 7b82e60 mlxrunner: Fix panic on full KV cache hit

📊 Changes

2 files changed (+10 additions, -2 deletions)

View changed files

📝 x/mlxrunner/cache.go (+6 -0)
📝 x/mlxrunner/pipeline.go (+4 -2)

📄 Description

When the entire prompt was already cached (e.g. repeated prompt), findRemaining returned an empty slice, causing FromValues to panic on an index-out-of-range accessing a zero-length byte slice.

Fix by always keeping at least one token to re-evaluate so the pipeline can seed token generation. Also reject empty prompts early rather than panicking.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/14430 **Author:** [@jessegross](https://github.com/jessegross) **Created:** 2/26/2026 **Status:** ✅ Merged **Merged:** 2/27/2026 **Merged by:** [@jessegross](https://github.com/jessegross) **Base:** `main` ← **Head:** `jessegross/mlx-fullcache` --- ### 📝 Commits (1) - [`7b82e60`](https://github.com/ollama/ollama/commit/7b82e602541359423e649e0960e44952a9bded8b) mlxrunner: Fix panic on full KV cache hit ### 📊 Changes **2 files changed** (+10 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `x/mlxrunner/cache.go` (+6 -0) 📝 `x/mlxrunner/pipeline.go` (+4 -2) </details> ### 📄 Description When the entire prompt was already cached (e.g. repeated prompt), findRemaining returned an empty slice, causing FromValues to panic on an index-out-of-range accessing a zero-length byte slice. Fix by always keeping at least one token to re-evaluate so the pipeline can seed token generation. Also reject empty prompts early rather than panicking. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 18:04:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25212