[PR #5447] [MERGED] Only set default keep_alive on initial model load #74079

Closed
opened 2026-05-05 06:03:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/5447
Author: @dhiltgen
Created: 7/2/2024
Status: Merged
Merged: 7/3/2024
Merged by: @dhiltgen

Base: mainHead: fix_keepalive


📝 Commits (1)

  • 955f2a4 Only set default keep_alive on initial model load

📊 Changes

5 files changed (+70 additions, -71 deletions)

View changed files

📝 envconfig/config.go (+29 -2)
📝 envconfig/config_test.go (+17 -0)
📝 server/routes.go (+3 -54)
📝 server/sched.go (+10 -4)
📝 server/sched_test.go (+11 -11)

📄 Description

This change fixes the handling of keep_alive so that if client request omits the setting, we only set this on initial load. Once the model is loaded, if new requests leave this unset, we'll keep whatever keep_alive was there.

Fixes #5272

% ollama run llama3 --keepalive 1h hello
Hello! It's nice to meet you. Is there something I can help you with, or would you like to chat?

% ollama ps
NAME         	ID          	SIZE  	PROCESSOR	UNTIL
llama3:latest	365c0bd3c000	6.7 GB	100% GPU 	59 minutes from now
% curl http://localhost:11434/api/generate -d '{
  "model": "llama3",
  "prompt": "hi",
  "stream": false
}' > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   594  100   534  100    60    797     89 --:--:-- --:--:-- --:--:--   886
% ollama ps
NAME         	ID          	SIZE  	PROCESSOR	UNTIL
llama3:latest	365c0bd3c000	6.7 GB	100% GPU 	59 minutes from now

Compare against https://github.com/ollama/ollama/issues/5272#issuecomment-2204491896 showing the incorrect behavior before.


🔄 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/5447 **Author:** [@dhiltgen](https://github.com/dhiltgen) **Created:** 7/2/2024 **Status:** ✅ Merged **Merged:** 7/3/2024 **Merged by:** [@dhiltgen](https://github.com/dhiltgen) **Base:** `main` ← **Head:** `fix_keepalive` --- ### 📝 Commits (1) - [`955f2a4`](https://github.com/ollama/ollama/commit/955f2a4e035044866277e26abe74343117250f1a) Only set default keep_alive on initial model load ### 📊 Changes **5 files changed** (+70 additions, -71 deletions) <details> <summary>View changed files</summary> 📝 `envconfig/config.go` (+29 -2) 📝 `envconfig/config_test.go` (+17 -0) 📝 `server/routes.go` (+3 -54) 📝 `server/sched.go` (+10 -4) 📝 `server/sched_test.go` (+11 -11) </details> ### 📄 Description This change fixes the handling of keep_alive so that if client request omits the setting, we only set this on initial load. Once the model is loaded, if new requests leave this unset, we'll keep whatever keep_alive was there. Fixes #5272 ``` % ollama run llama3 --keepalive 1h hello Hello! It's nice to meet you. Is there something I can help you with, or would you like to chat? % ollama ps NAME ID SIZE PROCESSOR UNTIL llama3:latest 365c0bd3c000 6.7 GB 100% GPU 59 minutes from now % curl http://localhost:11434/api/generate -d '{ "model": "llama3", "prompt": "hi", "stream": false }' > /dev/null % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 594 100 534 100 60 797 89 --:--:-- --:--:-- --:--:-- 886 % ollama ps NAME ID SIZE PROCESSOR UNTIL llama3:latest 365c0bd3c000 6.7 GB 100% GPU 59 minutes from now ``` Compare against https://github.com/ollama/ollama/issues/5272#issuecomment-2204491896 showing the incorrect behavior before. --- <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-05-05 06:03:00 -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#74079