[PR #1250] [MERGED] refactor layer creation #21065

Closed
opened 2026-04-19 15:25:20 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/1250
Author: @mxyng
Created: 11/22/2023
Status: Merged
Merged: 12/5/2023
Merged by: @mxyng

Base: mainHead: mxyng/create-layer


📝 Commits (4)

  • b2816bc unnecessary ReadSeeker for DecodeGGML
  • 70a9305 refactor layer creation
  • a3737cb use NewLayer for CreateBlobHandler
  • 7232f1f go mod tidy

📊 Changes

7 files changed (+197 additions, -223 deletions)

View changed files

📝 go.mod (+4 -3)
📝 go.sum (+0 -2)
📝 llm/ggml.go (+1 -1)
📝 server/images.go (+45 -193)
server/layers.go (+109 -0)
server/manifests.go (+34 -0)
📝 server/routes.go (+4 -24)

📄 Description

refactor layer creation

previous layer creation was not ideal because:

  1. it required reading the input file multiple times, once to calculate the sha256 checksum, another to write it to disk, and potentially one more to decode the underlying gguf
  2. used io.ReadSeeker which is prone to user error. if the file isn't reset correctly or in the right place, it could end up reading an empty file

there are also some brittleness when reading existing layers else
writing the inherited layers will error reading an already closed file

this commit aims to fix these issues by restructuring layer creation.

  1. it will now write the layer to a temporary file as well as the hash function and move it to the final location on Commit
  2. layers are read once when copied to the destination. exception is raw model files which still requires a second read to decode the model metadata

🔄 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/1250 **Author:** [@mxyng](https://github.com/mxyng) **Created:** 11/22/2023 **Status:** ✅ Merged **Merged:** 12/5/2023 **Merged by:** [@mxyng](https://github.com/mxyng) **Base:** `main` ← **Head:** `mxyng/create-layer` --- ### 📝 Commits (4) - [`b2816bc`](https://github.com/ollama/ollama/commit/b2816bca67ae5e47f1c285c5ee72929769932585) unnecessary ReadSeeker for DecodeGGML - [`70a9305`](https://github.com/ollama/ollama/commit/70a93057cdfcc660684db556d2044c9497651778) refactor layer creation - [`a3737cb`](https://github.com/ollama/ollama/commit/a3737cbd33a11a83e41f38c4dcd6713f76f58c87) use NewLayer for CreateBlobHandler - [`7232f1f`](https://github.com/ollama/ollama/commit/7232f1fa4192246c0021066b14392f594333ad57) go mod tidy ### 📊 Changes **7 files changed** (+197 additions, -223 deletions) <details> <summary>View changed files</summary> 📝 `go.mod` (+4 -3) 📝 `go.sum` (+0 -2) 📝 `llm/ggml.go` (+1 -1) 📝 `server/images.go` (+45 -193) ➕ `server/layers.go` (+109 -0) ➕ `server/manifests.go` (+34 -0) 📝 `server/routes.go` (+4 -24) </details> ### 📄 Description refactor layer creation previous layer creation was not ideal because: 1. it required reading the input file multiple times, once to calculate the sha256 checksum, another to write it to disk, and potentially one more to decode the underlying gguf 2. used io.ReadSeeker which is prone to user error. if the file isn't reset correctly or in the right place, it could end up reading an empty file there are also some brittleness when reading existing layers else writing the inherited layers will error reading an already closed file this commit aims to fix these issues by restructuring layer creation. 1. it will now write the layer to a temporary file as well as the hash function and move it to the final location on Commit 2. layers are read once when copied to the destination. exception is raw model files which still requires a second read to decode the model metadata --- <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-19 15:25:20 -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#21065