[PR #7844] [CLOSED] Handle padding bytes in GGUF files. #23075

Closed
opened 2026-04-19 16:45:07 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/7844
Author: @rick-github
Created: 11/26/2024
Status: Closed

Base: mainHead: magic


📝 Commits (1)

  • d935ee4 Handle padding bytes in GGUF files.

📊 Changes

3 files changed (+20 additions, -1 deletions)

View changed files

📝 llm/ggml.go (+7 -0)
📝 llm/gguf.go (+8 -0)
📝 server/model.go (+5 -1)

📄 Description

GGUF files are padded to an alignment value, by default 32 bytes. parseFromFile() doesn't handle this, which causes an invalid file magic for some imports since it tries to read multiple GGML structures from a single file and stumbles over the padding bytes when the last tensor didn't end on the alignment mark.

The doc is not as clear on adapters and projectors, but the fine-tuning code in llama.cpp uses an alignment of 32 and all the projectors I checked were aligned to 32 bytes.

Fixes: https://github.com/ollama/ollama/issues/5939
Fixes: https://github.com/ollama/ollama/issues/6272


🔄 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/7844 **Author:** [@rick-github](https://github.com/rick-github) **Created:** 11/26/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `magic` --- ### 📝 Commits (1) - [`d935ee4`](https://github.com/ollama/ollama/commit/d935ee46d97d3d4cd7ed033b64fe19c6aedb5889) Handle padding bytes in GGUF files. ### 📊 Changes **3 files changed** (+20 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `llm/ggml.go` (+7 -0) 📝 `llm/gguf.go` (+8 -0) 📝 `server/model.go` (+5 -1) </details> ### 📄 Description GGUF files are [padded](https://github.com/ggerganov/ggml/blob/master/docs/gguf.md#file-structure:~:text=Where%20required%2C%20the%20file%20is%20padded%20with%200x00%20bytes%20to%20the%20next%20multiple%20of%20general.alignment) to an alignment value, by default 32 bytes. `parseFromFile()` doesn't handle this, which causes an `invalid file magic` for some imports since it tries to read multiple GGML structures from a single file and stumbles over the padding bytes when the last tensor didn't end on the alignment mark. The doc is not as clear on adapters and projectors, but the fine-tuning code in llama.cpp uses an alignment of 32 and all the projectors I checked were aligned to 32 bytes. Fixes: https://github.com/ollama/ollama/issues/5939 Fixes: https://github.com/ollama/ollama/issues/6272 --- <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 16:45:07 -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#23075