1. 19 Apr, 2025 1 commit
    • Blake Mizerany's avatar
      server/internal/registry: make pull send errors with Error field (#10326) · 4e535e61
      Blake Mizerany authored
      Previously, the pull handler would send an error message in the Status
      field, this prevented the client from using the message as a signal to
      stop. In the case of the "run" command, it would follow the pull with a
      "show" which would print a nearly identical "not found" message for
      unresolved models.
      
      Fixes #10307
      4e535e61
  2. 17 Apr, 2025 1 commit
  3. 16 Apr, 2025 2 commits
    • Blake Mizerany's avatar
      server/internal/registry: remove superfluous progress bar flush (#10303) · 369de832
      Blake Mizerany authored
      This removes the extra flushProgress() at the end of handlePull. It is
      unnecessary because final progress updates are flushed in all cases of
      the main select loop.
      369de832
    • Blake Mizerany's avatar
      cmd: add retry/backoff (#10069) · 1e7f62cb
      Blake Mizerany authored
      This commit adds retry/backoff to the registry client for pull requests.
      
      Also, revert progress indication to match original client's until we can
      "get it right."
      
      Also, make WithTrace wrap existing traces instead of clobbering them.
      This allows clients to compose traces.
      1e7f62cb
  4. 21 Mar, 2025 1 commit
  5. 14 Mar, 2025 1 commit
    • Blake Mizerany's avatar
      server/internal/client: use chunksums for concurrent blob verification (#9746) · eb2b22b0
      Blake Mizerany authored
      Replace large-chunk blob downloads with parallel small-chunk
      verification to solve timeout and performance issues. Registry users
      experienced progressively slowing download speeds as large-chunk
      transfers aged, often timing out completely.
      
      The previous approach downloaded blobs in a few large chunks but
      required a separate, single-threaded pass to read the entire blob back
      from disk for verification after download completion.
      
      This change uses the new chunksums API to fetch many smaller
      chunk+digest pairs, allowing concurrent downloads and immediate
      verification as each chunk arrives. Chunks are written directly to their
      final positions, eliminating the entire separate verification pass.
      
      The result is more reliable downloads that maintain speed throughout the
      transfer process and significantly faster overall completion, especially
      over unstable connections or with large blobs.
      eb2b22b0
  6. 05 Mar, 2025 1 commit
    • Blake Mizerany's avatar
      server/internal/registry: take over pulls from server package (#9485) · e2252d0f
      Blake Mizerany authored
      This commit replaces the old pull implementation in the server package
      with the new, faster, more robust pull implementation in the registry
      package.
      
      The new endpoint, and now the remove endpoint too, are behind the
      feature gate "client2" enabled only by setting the OLLAMA_EXPERIMENT
      environment variable include "client2".
      
      Currently, the progress indication is wired to perform the same as the
      previous implementation to avoid making changes to the CLI, and because
      the status reports happen at the start of the download, and the end of
      the write to disk, the progress indication is not as smooth as it could
      be. This is a known issue and will be addressed in a future change.
      
      This implementation may be ~0.5-1.0% slower in rare cases, depending on
      network and disk speed, but is generally MUCH faster and more robust
      than the its predecessor in all other cases.
      e2252d0f
  7. 04 Mar, 2025 1 commit
    • Blake Mizerany's avatar
      server/internal/registry: reintroduce pruning on model deletion (#9489) · 7a01ad76
      Blake Mizerany authored
      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.
      7a01ad76
  8. 03 Mar, 2025 1 commit
    • Blake Mizerany's avatar
      server/internal/client/ollama: hold DiskCache on Registry (#9463) · 3519dd1c
      Blake Mizerany authored
      Previously, using a Registry required a DiskCache to be passed in for
      use in various methods. This was a bit cumbersome, as the DiskCache is
      required for most operations, and the DefaultCache is used in most of
      those cases. This change makes the DiskCache an optional field on the
      Registry struct.
      
      This also changes DefaultCache to initialize on first use. This is to
      not burden clients with the cost of creating a new cache per use, or
      having to hold onto a cache for the lifetime of the Registry.
      
      Also, slip in some minor docs updates for Trace.
      3519dd1c
  9. 01 Mar, 2025 1 commit
    • Blake Mizerany's avatar
      server/internal/internal/names: validate names (#9400) · cda6f5c6
      Blake Mizerany authored
      This commit is a step towards a goal to make names less ceremonial
      outside of the registry client. Clients of the registry package can
      treat names as opaque strings, and the registry package will handle
      parsing, validating, and normalizing names.
      
      Ideally we end up with the names package tucked away in an internal
      package for good. We'll see how things go.
      
      Also, this package name is not permanent. This another step in the
      on-going process of refactoring the server code, and at some point it
      will most likely be renamed/moved.
      cda6f5c6
  10. 27 Feb, 2025 2 commits
    • Blake Mizerany's avatar
      server/internal/registry: implement CloseNotify and Flush (for now) (#9402) · 41dc2804
      Blake Mizerany authored
      This fixes panics introduced in 2412adf4
      when Gin ungracefully assumes that the http.ResponseWriter implements
      http.CloseNotifier and http.Flusher, which our new statusCodeRecorder
      does not. This is a temporary fix until we can pour the rest of the Gin
      out.
      41dc2804
    • Blake Mizerany's avatar
      server/internal: replace model delete API with new registry handler. (#9347) · 2412adf4
      Blake Mizerany authored
      This commit introduces a new API implementation for handling
      interactions with the registry and the local model cache. The new API is
      located in server/internal/registry. The package name is "registry" and
      should be considered temporary; it is hidden and not bleeding outside of
      the server package. As the commits roll in, we'll start consuming more
      of the API and then let reverse osmosis take effect, at which point it
      will surface closer to the root level packages as much as needed.
      2412adf4