Overview

This guide documents the process of cleaning up the model library on the Gigabyte Gaming A16 laptop, moving everything into a single llama-server router with a preset file, and measuring how much context each model can hold in VRAM. The laptop runs a different configuration than the OptiPlex CPU-only box—do not mix numbers between the two.

The final preset file is public: presets.ini


Hardware and Software

ItemDetail
MachineGigabyte GAMING A16 laptop, CachyOS
CPUIntel Core i7-13620H (6 P-cores + 4 E-cores)
GPUNVIDIA RTX 5060 Laptop, about 7.7 GB usable VRAM
Display GPUIntel iGPU (so the RTX is mostly free of desktop use)
RAMabout 31 GB
llama.cppArch/CachyOS prebuilt package, 0.9.0-dev (build 12110, commit cd959bae99), GCC 16.2.1

The package is a prebuilt binary, not a self-compiled one, and it reports an asserts-enabled warning (explained in the earlier laptop log: the Arch package is built with CMAKE_BUILD_TYPE=None). All numbers below came from this same binary, so comparisons between runs are valid; treat absolute speeds as a floor rather than a ceiling.

Original server command:

llama-server --host 127.0.0.1,10.10.0.11 --port 9931 --no-ui --models-max 1 \
  --sleep-idle-seconds 180 --models-dir %h/Projects/LLMs/models \
  --models-preset %h/Projects/LLMs/presets.ini --api-key ""

Target command after this work: --models-max 2 and no --models-dir, so only deliberately defined presets show up in /v1/models.


Model Cleanup

Kept Models

ModelRole
Qwen3.5-9B Q4_K_M (+ mmproj)Main general model, wiki jobs
Qwen3.5-9B Uncensored, HauhauCS Aggressive Q4_K_MUncensored general model
Qwen3.5-4B Q4_K_M (+ mmproj)Smaller general model, LightRAG logic role
Gemma 4 E4B (plain, + mmproj)Characters and general chat
Gemma 4 E4B Uncensored, TrevorJS Q4_K_MUncensored characters
Gemma 3 1BOpen WebUI background tasks (titles, tags, follow-ups)
Qwen2.5-VL-3B-Instruct (+ mmproj)LightRAG vision role
Qwen3-Embedding-0.6B f16LightRAG embeddings

Removed Models and Reasons

ModelReason
Mistral-7B-Instruct v0.3Old and outclassed by the Qwen3.5 and Gemma 4 models
Gemma 3 12BFailed to load fully onto the GPU with -ngl 999; it had only been kept to test how context-heavy the Hermes agent was
Qwen3-14BSame failure to fit on the GPU
Qwen3-Embedding 4B and 8BDifferent embedding dimension from the existing LightRAG index (1024), so unusable without re-indexing
Phi-4-mini-reasoning, DeepSeek-R1-Distill-Llama-8BNever used; Qwen3.5 with thinking on covers the same ground
Gemma 3 4BKept originally because Gemma 4 E4B was a thinking model; once thinking could be turned off per preset it was redundant
Qwen3-8B abliterated, Qwen3.5-4B Uncensored (HauhauCS)Replaced by the Qwen3.5-9B Uncensored and Gemma 4 E4B Uncensored
Llama 3.1 8B, Ministral-3 8BUnused and overlapping with the Qwen3.5 / Gemma 4 models. Llama 3.1 8B’s benchmark numbers remain in the OptiPlex log
Underdog-Saluki 27B IQ2-mixToo large for the GPU at 2-bit, so it would run mostly on CPU with heavy quality loss

Uncensored Models

Newer uncensored releases were searched for. The decision was to replace the old Qwen3.5-4B uncensored model with the 9B version from the same author, and to add a Gemma 4 E4B uncensored model for character use.

  • HauhauCS Qwen3.5-9B Aggressive: Hugging Face. A third-party comparison reported little capability loss relative to the base model.
  • TrevorJS Gemma 4 E4B uncensored: Hugging Face, with the method described in gemma-4-abliteration. It reported a very low refusal rate with small drift from the original.

Neither was compared head-to-head against the base models on this hardware.


Router Mode, Presets, and GPU Offload

Router Mode with a Preset File Only

Without --models-dir, every model needs an explicit model = path, and vision models need an explicit mmproj = path. This fixes two problems seen earlier: projector files showing up as bogus models, and Open WebUI listing every GGUF in the folder.

Preset section names are the model names that appear in GET /v1/models and in Open WebUI. A preset can contain any server flag, written without the leading dashes.

n-gpu-layers is Not Set

Earlier, a global n-gpu-layers = 999 forced every layer onto the GPU, which is why the 12B and 14B models failed to load. The llama-server --help output on this build shows the relevant defaults:

  • -ngl defaults to auto.
  • --fit is on by default and adjusts unset arguments to fit in device memory.
  • --fit-target defaults to a 1024 MiB margin per device.
  • --fit-ctx defaults to a 4096-token minimum context.

Two consequences shaped the presets:

  1. Fit only adjusts values that are not set. Setting ctx-size explicitly on every entry means fit trims GPU layers to make room instead of shrinking the context.
  2. The margin was lowered to 512 MiB (fit-target = 512 in the [*] block) because the display runs on the iGPU. If CUDA out-of-memory errors appear mid-chat, remove that line.

threads = 6 is also in the defaults, matching the 6 P-cores. It only matters for layers that spill to the CPU.

Two Models Loaded at Once

--models-max 2 lets two models stay loaded. Each model is its own process and fit checks free VRAM when it loads, so a second model fits itself into what the first left behind. A router flag, --models-memory-margin N, unloads least-recently-used models until a new one fits; it is available in this build but is optional and was not required for the tests below.


Thinking versus Non-Thinking

Goal: avoid having two copies of every model.

What was tested in Open WebUI:

  • A per-request reasoning-budget of 0 in the advanced parameters disabled thinking on Gemma 4 E4B.
  • The same setting did not disable thinking on the Qwen3.5-4B thinking preset. The apparent earlier success on the non-thinking Qwen entry was explained by the preset already setting thinking off on the server side.
  • Adding enable_thinking: false as a custom parameter also failed for Qwen3.5.

Decision: control thinking in the preset, not per request. Each thinking-capable model has two entries pointing at the same file:

  • Non-thinking: reasoning = off and reasoning-budget = 0.
  • Thinking: neither key is set, so the template default (thinking on) applies.

Gemma 4 E4B was later split the same way. Loading both variants of the same file at once loads the weights twice, but in practice only one is used at a time.


Vision Projectors

A vision model needs a separate mmproj file that matches it. With a preset file, the projector is named explicitly.

ModelProjector
Qwen3.5-9BQwen3.5-9B-mmproj-Bf16.gguf
Qwen3.5-9B UncensoredReuses the 9B projector
Qwen3.5-4BQwen3.5-4B-mmproj-BF16.gguf
Gemma 4 E4Bgemma-4-E4B-it-mmproj-BF16.gguf
Gemma 4 E4B UncensoredReuses the plain E4B projector (the TrevorJS repo ships none)
Qwen2.5-VL-3BQwen2.5-VL-3B-Instruct-mmproj-Q8_0.gguf
Gemma 3 1B, Qwen3-EmbeddingNone (not vision models)

Notes:

  • The uncensored variants reusing the base projectors is an assumption: abliteration edits the language weights, not the vision encoder. Everything loaded and ran, but image-answer quality on the two uncensored models was not separately evaluated.
  • Each projector costs VRAM (about 0.65 GB for the Qwen3.5-4B, about 0.9 GB for the 9B and Gemma). The Qwen3.5-9B with vision loaded used about 7.2 GB of the card, which is why its context ceiling is the lowest of the set.
  • Files were renamed to <model>-mmproj-<quant>.gguf so each projector sits next to its model.

Per-Model Tuning Flags

Flags were chosen from the llama-server --help output of this build.

SettingApplied toReason
flash-attn = on, cache-type-k/v = q8_0Qwen3.5 modelsRoughly halves KV memory; quantized V cache needs flash attention
KV cache left at f16, flash-attn autoGemma 4Not verified that Gemma 4’s attention layout supports quantized KV on this build
lazy-mode = onGemma 4Reads the large per-layer-embedding tensors from disk on demand instead of keeping them resident (requires mmap)
ubatch-size = 1024Qwen3.5-4B, Gemma 4Faster prompt processing where there is VRAM to spare
Default ubatch-size (512)Qwen3.5-9BCompute buffers compete with the weights for VRAM
image-max-tokens = 2048, temp = 0.1Qwen2.5-VL (LightRAG vision)Bounds time and context per image; low temperature makes descriptions more repeatable between runs

Sampler defaults come from the model authors: Qwen3.5 uses its official thinking set (temp 0.6, top-p 0.95, top-k 20, min-p 0) and non-thinking set (temp 0.7, top-p 0.8, top-k 20, min-p 0); Gemma 4 uses temp 1.0, top-p 0.95, top-k 64. The Qwen values are the 9B card’s and were applied to the 4B as well, which is an assumption. The low-temperature sampler lines for Gemma 3 1B (background tasks) are present but commented out.

Speculative decoding (--spec-type, which includes ngram-mod and draft-mtp in this build) was deliberately not enabled, because it is unknown whether it works with Qwen3.5’s hybrid layers. It is a candidate for a later experiment on rewrite-style jobs.


The KV Cache and VRAM

The KV cache is reserved at load time for the full configured ctx-size, whether or not a conversation fills it. By default it sits in VRAM next to the weights, so a large context competes with the model for the same memory.

When the cache does not fit:

  1. Fit on, explicit ctx-size: fit keeps the context and offloads fewer layers to the GPU. The remainder runs on the CPU and generation slows.
  2. No room even with zero GPU layers: the load fails.
  3. no-kv-offload = true: the cache goes in system RAM, all weights stay on the GPU, and every token pays a PCIe transfer to read the cache.

An earlier sweep on Llama 3.1 8B (RTX 5060, -nkvo on and off across context sizes) found generation with the cache in RAM stayed flat at roughly 27 t/s while the in-VRAM case collapsed from 37.5 to 10.5 t/s by 72K context. That result suggested RAM-resident cache was a cheap escape hatch. The benchmark in section 10 shows that this does not hold when the cache is actually full (see section 12).


Finding the Maximum Context per Model

Rather than guess context sizes, the largest context that stays fully in VRAM was measured per preset, using preset_ctx_max_fit.sh. Results: max-laptop-ctx-results.tsv.

The columns are the model, the context configured at the time, the maximum context that fit in VRAM, the recommended value, and the number of trials the script needed. The recommended value equalled the measured maximum for every model. The measurements depend on the settings active at the time (q8_0 KV for Qwen, f16 KV for Gemma, projector loaded, fit-target = 512); changing any of them invalidates the number.

ModelConfigured beforeMax context in VRAMTrials
Gemma 3 1B16,384262,14410
Qwen3.5-4B (and thinking)32,768 / 131,072180,22418
Qwen3.5-9B (and thinking)32,768 / 65,53674,75216
Qwen3.5-9B Uncensored (and thinking)32,768 / 65,53677,31216
Gemma 4 E4B65,536185,34418
Gemma 4 E4B Uncensored65,536185,85618

Capping at the Trained Context

Two models fit more context in VRAM than they were trained to handle:

  • Gemma 3 1B: measured 262,144 in VRAM, but the Gemma 3 model card lists 32K tokens for the 1B size.
  • Gemma 4 E4B (and its uncensored fine-tune): measured about 185K in VRAM, but the Gemma 4 model card lists 128K tokens for E2B and E4B.

Their Max tiers use the trained size (32,768 and 131,072), and the Small and Medium tiers were recalculated from that. The Qwen3.5 maxima (180,224 for the 4B, 74,752 and 77,312 for the 9B models) are below Qwen3.5’s native context, which is understood to be 262,144 but was not re-verified here. n_ctx_train in each model’s load log shows what llama.cpp itself reads from the file.

Context Tiers

Each tier is rounded down: Small = 1/3, Medium = 2/3, Max = the full usable value.

ModelBinding limitSmallMediumMax
Gemma 3 1BTrained context (32K)10,92221,84532,768
Qwen3.5-4B (both modes)VRAM60,074120,149180,224
Qwen3.5-9B (both modes)VRAM24,91749,83474,752
Qwen3.5-9B Uncensored (both modes)VRAM25,77051,54177,312
Gemma 4 E4B (both modes)Trained context (128K)43,69087,381131,072
Gemma 4 E4B Uncensored (both modes)Trained context (128K)43,69087,381131,072

The idea is that the Max tier is a good default for most use, and the smaller tiers exist for when VRAM is needed by a second model.


VRAM versus RAM Cache Benchmark

bench-max-ctx.sh ran each preset at its maximum context, once with the KV cache in VRAM (nkvo = 0) and once in RAM (nkvo = 1). The depth column in the results shows the cache was filled to within 640 tokens of the full context (the pp512 + tg128 test length), so these numbers reflect attention over a nearly full cache. Results: bench-laptop-results.tsv.

ModelContextGen, cache in VRAM (t/s)Gen, cache in RAM (t/s)Gen slowdownPrompt, VRAM (t/s)Prompt, RAM (t/s)Prompt slowdown
Gemma 3 1B262,144107.28.712x3,3271,9351.7x
Qwen3.5-4B180,22427.92.810x5844071.4x
Qwen3.5-4B thinking180,22428.02.910x5574231.3x
Qwen3.5-9B74,75234.85.66.2x9917041.4x
Qwen3.5-9B thinking74,75234.75.66.1x9977081.4x
Qwen3.5-9B Uncensored77,31234.85.46.4x9626541.5x
Qwen3.5-9B Uncensored thinking77,31233.45.46.2x9456881.4x
Gemma 4 E4B185,34433.71.918x1,0615192.0x
Gemma 4 E4B Uncensored185,85632.41.917x1,0844972.2x

The benchmark ran before the trained-context cap, so the Gemma 3 1B and Gemma 4 rows were measured at contexts (262,144 and about 185K) above what their final Max tiers use. The Qwen3.5 rows are unaffected. The capped Gemma entries hold a smaller cache, so the VRAM-versus-RAM gap should be smaller than shown, but that was not re-measured.

Findings:

  • With the cache in VRAM, every model stays usable at its maximum context (roughly 28 to 107 t/s generation).
  • Moving a full cache to RAM is expensive. Generation drops 6x to 18x, and prompt processing drops 1.3x to 2.2x. Gemma 4 suffers most and the 9B least. Likely contributors, not tested: Gemma’s cache is f16 while Qwen’s is q8_0, and Qwen3.5 has only a fraction of layers using full attention.
  • Thinking and non-thinking variants perform alike, as expected for the same weights.
  • The Max tiers should keep no-kv-offload off. That is how the presets are set.

Preset Layout

Naming: <Model>-<Mode>-<Tier>, for example Qwen3.5-9B-Thinking-Medium, Gemma-4-E4B-Uncensored-Max, gemma-3-1b-Small. Non-thinking is the default and has no mode word. The Gemma 3 1B entries have no thinking variant.

Job presets sit at the end of the file:

PresetModelContextNotes
LightRAG-EmbeddingQwen3-Embedding-0.6B f168,192embedding = true, batch and ubatch 4096 (embedding input must fit one physical batch), cache-ram = 0
LightRAG-LogicQwen3.5-4B, non-thinking24,576Extraction and answer role; q8_0 KV; projector loaded
LightRAG-VisionQwen2.5-VL-3B16,384image-max-tokens = 2048, temp = 0.1
Quartz-Wiki-RewriteQwen3.5-9B256,000no-kv-offload = true, thinking sampler set
Quartz-Wiki-New-ContentQwen3.5-9B74,752Matches the 9B Max tier, so the cache stays in VRAM

Corrections Made Along the Way

  • Default -ngl: the earlier glossary said it defaulted to 0 on GPU builds. The --help output for this build shows auto with fit on by default.
  • Expected no-kv-offload penalty: it was first estimated at roughly 10% to 25% from the Llama 8B sweep, then guessed to be smaller on Qwen3.5. The depth-filled benchmark shows 6x to 18x generation slowdowns at maximum context. The earlier sweep most likely measured an allocated-but-empty cache, which would explain its flat RAM-cache curve; this is an inference, since the sweep’s exact method was not re-checked.
  • Maximum context versus trained context: the first set of tiers was computed from what fits in VRAM alone, which put Gemma 3 1B and Gemma 4 E4B above their trained lengths. Both are now capped at the trained size and their Small and Medium tiers recalculated.
  • Per-request thinking control: assumed possible for all models; it works for Gemma 4 only in the tests run here.

Caveats and Open Items

  • Quartz-Wiki-Rewrite is slow by design. It needs to modify about 260 files in one pass, so the cache stays in RAM at 256,000 tokens. That is more than three times the depth of the 9B’s 74K result, which already ran at 5.6 t/s, so expect no better than that. Its speed and prompt-processing time at that depth were not measured, and optimizing it is deferred.
  • Fit at less than Max tiers. The context ceilings assume one model loaded. With --models-max 2, a second large preset will have fit trim its GPU layers.
  • LightRAG’s three models cannot all fit in VRAM at the same time (embedding, logic, vision). With --models-max 2, expect reloads or CPU spill when it alternates between them. This was not measured.
  • LightRAG-Logic loads a vision projector it may not need for text-only extraction, which costs about 0.65 GB of VRAM. Remove the mmproj line if headroom matters there.
  • Image quality on the uncensored models (shared projectors) was not evaluated.
  • Not yet tried: --spec-type speculative decoding, --models-memory-margin, and a CPU thread-count sweep for hybrid P/E cores.
  • Benchmark scripts are linked for reference; their exact search method is described in the scripts themselves and was not reviewed for this write-up.

Files

FileLink
Presetspresets.ini
Max-context resultsmax-laptop-ctx-results.tsv
VRAM vs RAM benchmark resultsbench-laptop-results.tsv
Max-context scriptpreset_ctx_max_fit.sh
Benchmark scriptbench-max-ctx.sh

Transclude of bench-laptop-results.tsv

VRAM versus RAM cache benchmark results showing generation slowdown when moving full KV cache to system RAM.