[PR #9833] [MERGED] ollamarunner: Check for minBatch of context space when shifting #18339

Closed
opened 2026-04-16 06:32:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/9833
Author: @jessegross
Created: 3/17/2025
Status: Merged
Merged: 3/17/2025
Merged by: @jessegross

Base: mainHead: jessegross/shift_image


📝 Commits (1)

  • 626997a ollamarunner: Check for minBatch of context space when shifting

📊 Changes

1 file changed (+17 additions, -11 deletions)

View changed files

📝 runner/ollamarunner/runner.go (+17 -11)

📄 Description

Models can specify that a group of inputs need to be handled a single batch. However, context shifting didn't respect this and could trigger a break anyways. In this case, we should instead trigger a context shift earlier so that it occurs before the grouped batch.

Note that there still some corner cases:

  • A long prompt that exceeds the context window can get truncated in the middle of an image. With the current models, this will result in the model not recognizing the image at all, which is pretty much the expected result with truncation.
  • The context window is set less than the minimum batch size. The only solution to this is to refuse to load the model with these settings. However, this can never occur with current models and default settings.

Since users are unlikely to run into these scenarios, fixing them is left as a follow up.


🔄 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/9833 **Author:** [@jessegross](https://github.com/jessegross) **Created:** 3/17/2025 **Status:** ✅ Merged **Merged:** 3/17/2025 **Merged by:** [@jessegross](https://github.com/jessegross) **Base:** `main` ← **Head:** `jessegross/shift_image` --- ### 📝 Commits (1) - [`626997a`](https://github.com/ollama/ollama/commit/626997a788d3db895acbf8851f7a8173163639b5) ollamarunner: Check for minBatch of context space when shifting ### 📊 Changes **1 file changed** (+17 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `runner/ollamarunner/runner.go` (+17 -11) </details> ### 📄 Description Models can specify that a group of inputs need to be handled a single batch. However, context shifting didn't respect this and could trigger a break anyways. In this case, we should instead trigger a context shift earlier so that it occurs before the grouped batch. Note that there still some corner cases: - A long prompt that exceeds the context window can get truncated in the middle of an image. With the current models, this will result in the model not recognizing the image at all, which is pretty much the expected result with truncation. - The context window is set less than the minimum batch size. The only solution to this is to refuse to load the model with these settings. However, this can never occur with current models and default settings. Since users are unlikely to run into these scenarios, fixing them is left as a follow up. --- <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-16 06:32:21 -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#18339