Skip to content

ggml : write host-buffer tensor data directly in gguf writer - #31144

Merged
ggerganov merged 1 commit into
masterfrom
gg/opt-gguf-write
Nov 4, 2026
Merged

ggerganov merged 1 commit into
masterfrom
gg/opt-gguf-write

Conversation

@ggerganov

@ggerganov ggerganov commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

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

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES
    • Harness: dsh:llama.cpp
    • Hardware: Mac Studio, M2 Ultra, 192GB
    • Model: ggml-org/DeepSeek-V4-Flash-Vision-Exp-GGUF
    • Stats: ◷ 2.7h · ⚙ 38.1m · ↑ 206k · ↓ 218k · ⇈ 114.2 tok/s · ⇊ 25.8 tok/s · ≡ 625 · ⌨ 42

@ggerganov
ggerganov marked this pull request as ready for review October 25, 2026 11:21
@github-actions github-actions Bot added the ggml changes relating to the ggml tensor library for machine learning label Oct 25, 2026
@ggerganov
ggerganov force-pushed the gg/opt-gguf-write branch 2 times, most recently from b61c510 to 942e594 Compare October 29, 2026 09:08
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
ggerganov merged commit 960b1d5 into master Nov 4, 2026
39 of 40 checks passed
@ggerganov
ggerganov deleted the gg/opt-gguf-write branch November 4, 2026 07:29
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant