Repository navigation
ggml-openvino: release host weight buffers by default on GPU and restore them from the model file - #467
Open
osabnis wants to merge 1 commit into
Open
ggml-openvino: release host weight buffers by default on GPU and restore them from the model file#467osabnis wants to merge 1 commit into
osabnis wants to merge 1 commit into
Conversation
…ore them from the model file
osabnis
force-pushed
the
ov-release-host-weights
branch
from
November 28, 2026 23:37
9f1c304 to
81cf53e
Compare
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
On GPU, the OpenVINO plugin maintains its own device copy of each weight after compilation, but the corresponding host weight buffers remain resident in memory. This can consume 20–24 GB of host memory for 32–36B models, even after the weights have been transferred to the GPU.
Host weight buffer release already exists (
GGML_OPENVINO_RELEASE_WEIGHTS, orGGML_OPENVINO_MEMORY_OPTIMIZEon GPU), but it is off by default. Released buffers cannot be restored: a later compile would read zeroed pages, so it fails, and the compiled-model cache is kept alive across backend teardown to avoid recompiling.This change enables host weight buffer release by default on GPU and restores the contents from the model file when they are needed again.
Changes
GGML_OPENVINO_RELEASE_WEIGHTSis now enabled by default on GPU. WhenGGML_OPENVINO_MEMORY_OPTIMIZEis set, it still follows that value.madvise(MADV_DONTNEED)) only the buffers whose contents all come from the model file mapping. Buffers with data from other sources (-lm none,memset, copies) are never released.static_load_variants) or a weight is read on the host, write the released buffers again from the model file.dev_doc/OpenVINO-ENV-VARS.md.Results
Host memory usage
Steady-state host memory usage (median
RssAnonover each run). KLD remained unchanged in every case.-ngl 40(partial offload)-lm none-lm none, most buffers stay resident by design (their data does not come from a file mapping).-lm none. In llama-cli, the decode graph is compiled after the weight buffers have been released.Performance impact
Released weights must be restored from the model file before compiling each new graph. This adds overhead when benchmarks create a new context for each test.
In llama-bench, one timed repetition per test is affected:
pp2048 performance remained unchanged.
Requirements