[PR #13539] [CLOSED] server: stream hash verification during download, improve stall detection #14261

Closed
opened 2026-04-13 00:49:33 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13539
Author: @jmorganca
Created: 12/21/2025
Status: Closed

Base: mainHead: jmorganca/download-stream-hash


📝 Commits (4)

📊 Changes

4 files changed (+577 additions, -111 deletions)

View changed files

📝 server/download.go (+255 -62)
server/download_test.go (+320 -0)
📝 server/images.go (+2 -48)
📝 server/routes.go (+0 -1)

📄 Description

Hash blob data while downloading (by trying to using page cache as much as possible) instead of after, improving download speeds. Add configurable download concurrency (default 32) and part size (default 64MB) for faster downloads on high-bandwidth connections.

This PR also improves the stall detection to compare against the median part download rate. In many cases for larger blob downloads, a single part would stall to <10% of the download speed of other parts, slowing down the entire download and verification process. Now these parts will be re-downloaded up to 3 times if slow

Lastly, this PR matches the download part size and concurrency to mirror previous "client2" work which would result in downloading much smaller parts. This both reduced risk of a big part taking a long time but also accelerates how fast we can hash the final blob data while parts are downloaded (since small parts finish faster than bigger parts).

A last change that didn't make it into this PR: parallel layer downloads. Many layers are tiny (<1MB) and should be downloaded in paralle.

Comparison on a 10gbps connection with a standard server SSD:

Before:

time ollama pull llama3.1:70b
pulling manifest 
pulling de20d2cf2dc4: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  42 GB                         
pulling 948af2743fc7: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 1.5 KB                         
pulling 0ba8f0e314b4: 100% ▕███████���██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  12 KB                         
pulling 56bb8bd477a5: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏   96 B                         
pulling 4bde18c49e43: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  488 B                         
verifying sha256 digest 
writing manifest 
success 

real	1m36.602s
user	0m0.340s
sys	0m0.394s

After (note the verifying sha256 digest step is skipped altogether)

time ollama pull llama3.1:70b
pulling manifest 
pulling de20d2cf2dc4: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  42 GB                         
pulling 948af2743fc7: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 1.5 KB                         
pulling 0ba8f0e314b4: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  12 KB                         
pulling 56bb8bd477a5: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏   96 B                         
pulling 4bde18c49e43: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  488 B                         
writing manifest 
success 

real	0m54.255s
user	0m0.190s
sys	0m0.132s

🔄 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/13539 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 12/21/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `jmorganca/download-stream-hash` --- ### 📝 Commits (4) - [`2aee6c1`](https://github.com/ollama/ollama/commit/2aee6c172b019bfe3f3b5a54b4feaa84bcf89dd6) server: stream hash verification during download - [`9a8c2a4`](https://github.com/ollama/ollama/commit/9a8c2a46354eed7657715797d39ed17f92d0cc03) revert unwanted changes - [`bdb9ea4`](https://github.com/ollama/ollama/commit/bdb9ea4772b40141b2a3eab88edbc7c861c61a48) cleanup - [`bf63d18`](https://github.com/ollama/ollama/commit/bf63d18b11cb6262e1228b30a94bcc19176e8c37) linter ### 📊 Changes **4 files changed** (+577 additions, -111 deletions) <details> <summary>View changed files</summary> 📝 `server/download.go` (+255 -62) ➕ `server/download_test.go` (+320 -0) 📝 `server/images.go` (+2 -48) 📝 `server/routes.go` (+0 -1) </details> ### 📄 Description Hash blob data while downloading (by trying to using page cache as much as possible) instead of after, improving download speeds. Add configurable download concurrency (default 32) and part size (default 64MB) for faster downloads on high-bandwidth connections. This PR also improves the stall detection to compare against the median part download rate. In many cases for larger blob downloads, a single part would stall to <10% of the download speed of other parts, slowing down the entire download and verification process. Now these parts will be re-downloaded up to 3 times if slow Lastly, this PR matches the download part size and concurrency to mirror previous "client2" work which would result in downloading much smaller parts. This both reduced risk of a big part taking a long time but also accelerates how fast we can hash the final blob data while parts are downloaded (since small parts finish faster than bigger parts). A last change that didn't make it into this PR: parallel layer downloads. Many layers are tiny (<1MB) and should be downloaded in paralle. Comparison on a 10gbps connection with a standard server SSD: Before: ``` time ollama pull llama3.1:70b pulling manifest pulling de20d2cf2dc4: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 42 GB pulling 948af2743fc7: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 1.5 KB pulling 0ba8f0e314b4: 100% ▕███████���██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 12 KB pulling 56bb8bd477a5: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 96 B pulling 4bde18c49e43: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 488 B verifying sha256 digest writing manifest success real 1m36.602s user 0m0.340s sys 0m0.394s ``` After (note the `verifying sha256 digest` step is skipped altogether) ``` time ollama pull llama3.1:70b pulling manifest pulling de20d2cf2dc4: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 42 GB pulling 948af2743fc7: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 1.5 KB pulling 0ba8f0e314b4: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 12 KB pulling 56bb8bd477a5: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 96 B pulling 4bde18c49e43: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 488 B writing manifest success real 0m54.255s user 0m0.190s sys 0m0.132s ``` --- <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-13 00:49:33 -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#14261