Repository navigation
[WIP] openvino: add GGML_OPENVINO_EVICT_ON_UPLOAD to drop host weights as t… - #488
Draft
cavusmustafa wants to merge 1 commit into
Draft
cavusmustafa wants to merge 1 commit into
cavusmustafa wants to merge 1 commit into
Conversation
ravi9
force-pushed
the
dev_backend_openvino
branch
2 times, most recently
from
December 4, 2026 16:14
5b4342a to
a274a39
Compare
ravi9
force-pushed
the
ov_evict_on_upload
branch
from
December 4, 2026 16:32
3cd0433 to
69a4b8a
Compare
cavusmustafa
force-pushed
the
ov_evict_on_upload
branch
from
December 4, 2026 19:06
69a4b8a to
89e8c37
Compare
…he GPU plugin uploads them Assisted-by: Claude Opus 5.5
cavusmustafa
force-pushed
the
ov_evict_on_upload
branch
from
December 5, 2026 01:37
89e8c37 to
a9f950a
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.
Evict tensors while compiling to reduce peak memory [WIP]
Overview
Adds
GGML_OPENVINO_EVICT_ON_UPLOAD=1(GPU), which drops the host pages of each weight as soon as the GPU plugin has uploaded it, instead of keeping the whole converted copy untilcompile_modelreturns. This lowers the peak of host plus GPU memory during compilation by about a third, with identical output.The GPU plugin already calls
ov::wsh::Extension::hint_evict()on each constant after its upload, which is why OpenVINO GenAI (mmap'd IR) has no such peak. Our Constants are built from anov::Tensorand have no buffer descriptor, so the hint was ignored. With the option set, each weight Constant becomes a view of the weight buffer that has a descriptor and answers the hint withmadvise(MADV_DONTNEED)on its own pages. The buffer is then marked released, so the existing restore path writes it again from the model file before any later compile, as withGGML_OPENVINO_RELEASE_WEIGHTS.Additional information
The build does not change: same OpenVINO package, same
cmake -DGGML_OPENVINO=ON, C++17.ov::AlignedBufferis not in OpenVINO's public headers, so its declaration is mirrored inopenvino/aligned_buffer.hpp, like the internal ops inopenvino/op/. There are two layouts: OpenVINO 2026.5, and 2027.0 after openvinotoolkit/openvino#40120.Because the backend derives from that class, the mirror must match the library. At configure time CMake links a small class derived from the mirror against the OpenVINO found, and defines
GGML_OPENVINO_HAS_EVICT_ON_UPLOADonly if that works. A mismatch therefore compiles the feature out instead of breaking the backend; for example the 2027.0 nightly of 2026-11-30 still has the 2026.5 layout and is rejected. The Linux release tarball and the Docker image, both built with OpenVINO 2026.5.0, get the feature without CI changes. Where it is not available, or on a device other than the GPU, setting the variable prints a warning and is ignored.Windows: the release and restore of host weights is Linux-only today; #482 adds it for Windows, and this feature can use it with a small follow-up (one
VirtualFree(MEM_DECOMMIT)per range and the link test on MSVC).Measurements and regression checks
Arc B390 iGPU (Core Ultra X7 358H, 62 GB), Linux, OpenVINO 2026.5.0 release package. "RAM used" = peak of private memory (RssAnon + RssShmem) plus GPU buffers (xe
drm-resident-gtt), both system RAM on an iGPU.llama-completion -ngl 99 --temp 0.Flag off vs on (this PR):
Default behavior (flag off) vs the base
a274a3948: identical output and peak memory on Qwen2.5-7B (10.38 vs 10.40 GiB) and gemma-4-12B (16.98 vs 16.98 GiB);llama-benchQwen2.5-7B tg128 24.52 vs 24.53 t/s.Other paths with the flag on: compiled-model cache export and import (identical output to no cache),
GGML_OPENVINO_MEMORY_OPTIMIZE=1(identical), every graph recompiled withGGML_OPENVINO_DISABLE_CACHE=1(weights written back from the GGUF, identical text),llama-bench -p 128,512(3 compiles, 2 restores), CPU device (warning, ignored). OpenVINO masterdcc454f51d(2027.0 layout): link test passes, Qwen 10.49 -> 6.98 GiB, identical output.CI script, as the self-hosted job runs it (
GG_BUILD_OPENVINO=1 GGML_OPENVINO_DEVICE=GPU GG_BUILD_LOW_PERF=1 ci/run.sh, OpenVINO 2026.5.0, where the link test enables the feature): Debug ctest 20/20, Release ctest 20/20,test-backend-opson the GPU 10735/10735, exit 0.What stays resident: Q/K/V weights that the GPU plugin's
FullyConnectedHorizontalFusionmerges into a new constant are never uploaded themselves, so they get no hint (426 MB on Qwen). The companion OpenVINO change https://github.com/cavusmustafa/openvino/tree/gpu-fc-fusion-evict-sources hints them in that pass.Limitations: OpenVINO does not ask for evicted data back before reading it, so correctness relies on the restore before each compile (the same mechanism as
GGML_OPENVINO_RELEASE_WEIGHTS). A public OpenVINO API to mark Constant data as releasable would remove the mirror.Requirements
Written with Claude Opus 5.5