How to Free Up 5.4 GB of VRAM in llama.cpp Without Losing Quality
Reducing the pass size for AI agent memory search models freed up 5.4 GB of VRAM. Quality on validation datasets remained nearly unchanged.

On a home PC with an RTX 4080 Super, two local Qwen3 models occupied almost all the VRAM, even though their weights were significantly reduced after quantization from Q8 to Q4_K_M. The bulk of the memory was consumed by service memory—context cache and a working buffer for text processing.
The author kept the context length unchanged but reduced the pass size in llama.cpp: for embeddings—from 8,192 to 1,024 tokens, and for the reranker—from 2,048 to 512. This approach preserved the ability to process long entries while reducing memory consumption. In total, about 5.4 GB was freed, and the volume of data transferred to RAM decreased to hundreds of megabytes.
Testing showed that short text produced the same vector, while for long texts, cosine similarity reached 0.999. The reranker assigned the same scores on control datasets. After modifying the pass, recalculating the stored memory was unnecessary.
To fully offload the GPU, the author prepared a separate llama.cpp configuration file. It uses the parameters device = none and n-gpu-layers = 0; models run on the CPU while retaining their original names, address, and port. Switching between modes is done by replacing the configuration file and restarting the server.





