Repository navigation
openvino: add GGML_OPENVINO_COMPILE_MEM_SPILL with a RAM cap - #483
Merged
ravi9 merged 6 commits intoDec 4, 2026
Merged
Conversation
ravi9
force-pushed
the
dev_backend_openvino
branch
2 times, most recently
from
December 3, 2026 16:12
4b5fa3a to
6e03d0d
Compare
ravi9
force-pushed
the
ov_spill_resident_budget
branch
from
December 3, 2026 18:15
bc441ad to
409ccf8
Compare
… kept in RAM Assisted-by: Claude Opus 5.5
ravi9
force-pushed
the
ov_spill_resident_budget
branch
from
December 4, 2026 00:11
0acf71c to
234dabb
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
Adds
GGML_OPENVINO_COMPILE_MEM_SPILL, from 0 to 1, and renamesGGML_OPENVINO_SPILL_DIRtoGGML_OPENVINO_COMPILE_MEM_SPILL_DIR(/var/tmpby default).0: off, the default.GGML_OPENVINO_MEMORY_OPTIMIZE=1sets it to0.1, next toGGML_OPENVINO_REDUCE_COMPILE_MEM=1; each one can still be set on its own.1: back the host buffers of the backend with files, asGGML_OPENVINO_SPILL_DIRdid. The kernel drops these pages only when RAM runs out, so on a machine with free RAM the memory peak does not change.0.1: spill, and keep at most that part of the spilled weights in RAM while the model loads and compiles. This setting lowers the peak the most.A thread writes the spilled pages to the file and drops them (
msync+MADV_PAGEOUT) after every half budget of weight writes while the model loads, and whenever the resident part exceeds the budget whilecompile_modelreads the weights back or released weights are written again, and for 10 s after (the CPU plugin's first inference reads the weights too). Outside of these, the thread sleeps without measuring. A failedmsync,madviseormincorestops the limiter with one warning, so no page that is not on disk is dropped. The GGUF source pages are paged out too. The limiter applies only to the weight buffer, not to KV cache or compute buffers. The cap needs Linux 5.4 or later (MADV_PAGEOUT).The disk space of a spill file is reserved with
fallocatewhen the file is created, so a full disk no longer kills the process with SIGBUS. When the space is missing, or the directory is on tmpfs or cannot be used, the backend warns and uses RAM for that buffer. Each start writes the buffers to disk: the load takes longer, and decoding can be a little slower. NPU: off unless set. Windows: ignored, as before. Cache-only mode: off. An invalid value stops the backend at startup.Docs:
ggml/src/ggml-openvino/dev_doc/OpenVINO-ENV-VARS.md,dev_doc/COOKBOOK.mdanddev_doc/README.md.Additional information
With
0.1, process RSS drops from 5.5 to 1.7 GiB on Qwen2.5-7B Q4_0 and from 9.8 to 3.4 GiB on gemma-4-12B Q4_0 (Arc B390 iGPU). The generated text is identical, decode speed is unchanged, and the first token comes 0-4 s later, depending on disk write speed. One short spike (<0.5 s) remains: llama.cpp maps the GGUF withMAP_POPULATEbefore the backend allocates anything.Measurements
GPU, 1024-token prompt + 128 tokens,
-c 2048, page cache dropped before each run, mean of 2 runs. "First token" is counted from process start and includescompile_model.COMPILE_MEM_SPILL=1COMPILE_MEM_SPILL=0.1COMPILE_MEM_SPILL=1COMPILE_MEM_SPILL=0.1GGML_OPENVINO_DEVICE=GPU GGML_OPENVINO_COMPILE_MEM_SPILL=0.1
llama-completion -m -ngl 99 -f -n 128 --ignore-eos -c 2048 --temp 0
Requirements
Written with Claude Opus 5.5