Repository navigation
ggml : write host-buffer tensor data directly in gguf writer - #31144
Merged
Merged
Conversation
ggerganov
marked this pull request as ready for review
October 25, 2026 11:21
ggerganov
force-pushed
the
gg/opt-gguf-write
branch
2 times, most recently
from
October 29, 2026 09:08
b61c510 to
942e594
Compare
The gguf writer staged each tensor into a temporary vector before writing it. For host-buffer tensors the data pointer is directly writable, so skip the staging copy and write it straight to the file. This avoids the per-tensor allocation, zero-init and memcpy. Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4-Flash-Vision-Exp-GGUF (Mac Studio, M2 Ultra, 192GB)
ggerganov
force-pushed
the
gg/opt-gguf-write
branch
from
November 3, 2026 15:28
942e594 to
8e8d6c6
Compare
1 task
edwardyoon
pushed a commit
to edwardyoon/focus-llama
that referenced
this pull request
Nov 6, 2026
…g#31144) The gguf writer staged each tensor into a temporary vector before writing it. For host-buffer tensors the data pointer is directly writable, so skip the staging copy and write it straight to the file. This avoids the per-tensor allocation, zero-init and memcpy. Assisted-by: dsh:llama.cpp/ggml-org/DeepSeek-V4-Flash-Vision-Exp-GGUF (Mac Studio, M2 Ultra, 192GB) (cherry picked from commit 960b1d5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The gguf writer staged every tensor into a temporary vector before writing it, which added a per-tensor allocation, zero-init and memcpy. For host-buffer tensors the data pointer is directly writable, so write it straight to the file and skip the staging copy.
Sample performance improvement for
test-llama-archs -o <dir>(Debug build): ~35s -> ~25s real, ~27s -> ~20s user.Requirements
dsh:llama.cppMac Studio, M2 Ultra, 192GB◷ 2.7h · ⚙ 38.1m · ↑ 206k · ↓ 218k · ⇈ 114.2 tok/s · ⇊ 25.8 tok/s · ≡ 625 · ⌨ 42