[PR #9489] [MERGED] server/internal/registry: reintroduce pruning on model deletion #59684

Closed
opened 2026-04-29 14:37:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/9489
Author: @bmizerany
Created: 3/4/2025
Status: Merged
Merged: 3/4/2025
Merged by: @bmizerany

Base: mainHead: bmizerany/pruneonrmagain


📝 Commits (1)

  • f1dc37a server/internal/registry: reintroduce pruning on model deletion

📊 Changes

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

View changed files

📝 server/internal/registry/server.go (+8 -1)
📝 server/routes.go (+2 -0)

📄 Description

This reintroduces aggressive pruning on model deletion as a temporary
measure until a more controlled garbage collection (GC) mechanism is
implemented.

Issues with the current approach:

  1. Users may accidentally delete a model (ollama rm llama3.3 instead
    of ollama rm llama3.2), requiring a full re-download unless another
    model references the same blobs.

  2. Users may assume a deleted model is still referenced elsewhere, but
    due to prior updates or deletions, the references no longer exist,
    leading to unnecessary re-downloads.

Soon, we should implement a structured GC mechanism to retain
unreferenced blobs for a configurable period before removal, which will
run on "ollama rm" and other commands we deem appropriate.

Users that want to immediately remove unreferenced blobs can use a new
prune command that will allow them to specify the age and class of blobs
to remove.

Example usage:

# Run basic blob GC
$ ollama prune

# Remove unreferenced blobs older than 7 days
$ ollama prune --age 7d

# Remove all blobs, referenced or not, older than 7 days (and their manifests?)
$ ollama prune --age 7d --all

# Remove all unreferenced blobs immediately
$ ollama prune --age 0 --all

# Remove all blobs
$ ollama prune --age 0 --all

This should provide a safer and more predictable cleanup process.


🔄 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/9489 **Author:** [@bmizerany](https://github.com/bmizerany) **Created:** 3/4/2025 **Status:** ✅ Merged **Merged:** 3/4/2025 **Merged by:** [@bmizerany](https://github.com/bmizerany) **Base:** `main` ← **Head:** `bmizerany/pruneonrmagain` --- ### 📝 Commits (1) - [`f1dc37a`](https://github.com/ollama/ollama/commit/f1dc37a015e60a40705aafca845193fb50b75593) server/internal/registry: reintroduce pruning on model deletion ### 📊 Changes **2 files changed** (+10 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `server/internal/registry/server.go` (+8 -1) 📝 `server/routes.go` (+2 -0) </details> ### 📄 Description This reintroduces aggressive pruning on model deletion as a temporary measure until a more controlled garbage collection (GC) mechanism is implemented. Issues with the current approach: 1. Users may accidentally delete a model (`ollama rm llama3.3` instead of `ollama rm llama3.2`), requiring a full re-download unless another model references the same blobs. 2. Users may assume a deleted model is still referenced elsewhere, but due to prior updates or deletions, the references no longer exist, leading to unnecessary re-downloads. Soon, we should implement a structured GC mechanism to retain unreferenced blobs for a configurable period before removal, which will run on "ollama rm" and other commands we deem appropriate. Users that want to immediately remove unreferenced blobs can use a new prune command that will allow them to specify the age and class of blobs to remove. Example usage: # Run basic blob GC $ ollama prune # Remove unreferenced blobs older than 7 days $ ollama prune --age 7d # Remove all blobs, referenced or not, older than 7 days (and their manifests?) $ ollama prune --age 7d --all # Remove all unreferenced blobs immediately $ ollama prune --age 0 --all # Remove all blobs $ ollama prune --age 0 --all This should provide a safer and more predictable cleanup process. --- <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-29 14:37:17 -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#59684