[PR #840] [MERGED] do not reload the running llm when runtime params change #15625

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

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/840
Author: @BruceMacD
Created: 10/18/2023
Status: Merged
Merged: 10/19/2023
Merged by: @BruceMacD

Base: mainHead: brucemacd/no-reload-same-model


📝 Commits (1)

  • 7554a5c do not reload the running llm when runtime params change

📊 Changes

3 files changed (+66 additions, -86 deletions)

View changed files

📝 api/types.go (+27 -25)
📝 server/images.go (+5 -7)
📝 server/routes.go (+34 -54)

📄 Description

  • only reload the running llm if the model has changed, or the options for loading the running model have changed
  • rename loaded llm to runner to differentiate from loaded model image
  • remove logic which keeps the first system prompt in the generation context

Say I have 2 models, both are based on llama2, but they have different prompts and runtime parameters.

FROM llama2
TEMPLATE """
you are a dog
"""
PARAMETER stop "human:"

and

FROM llama2
TEMPLATE """
you are a cat
"""
PARAMETER stop "bob:"

If I am building something that swaps requests between these models a lot our current logic will re-load the models every time, even though the only thing changing is the prompt template or runtime option is changing.

This change compares only model fields which require the model to be re-loaded before swapping the loaded model.

Resolves #337


🔄 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/840 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 10/18/2023 **Status:** ✅ Merged **Merged:** 10/19/2023 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `brucemacd/no-reload-same-model` --- ### 📝 Commits (1) - [`7554a5c`](https://github.com/ollama/ollama/commit/7554a5c2ba8fc41424553f830db785228667fcbc) do not reload the running llm when runtime params change ### 📊 Changes **3 files changed** (+66 additions, -86 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+27 -25) 📝 `server/images.go` (+5 -7) 📝 `server/routes.go` (+34 -54) </details> ### 📄 Description - only reload the running llm if the model has changed, or the options for loading the running model have changed - rename loaded llm to runner to differentiate from loaded model image - remove logic which keeps the first system prompt in the generation context Say I have 2 models, both are based on llama2, but they have different prompts and runtime parameters. ``` FROM llama2 TEMPLATE """ you are a dog """ PARAMETER stop "human:" ``` and ``` FROM llama2 TEMPLATE """ you are a cat """ PARAMETER stop "bob:" ``` If I am building something that swaps requests between these models a lot our current logic will re-load the models every time, even though the only thing changing is the prompt template or runtime option is changing. This change compares only model fields which require the model to be re-loaded before swapping the loaded model. Resolves #337 --- <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 05:03:32 -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#15625