If the model only partly fits in GPU memory, use partial offload to keep some layers on the GPU and the rest on the CPU. Start with automatic placement, then compare it with a smaller model that fits fully on the GPU; the larger model earns its place only if better answers justify the extra wait.
Separate fitting from finishing
Partial offload is a capacity option. llama.cpp exposes the number of GPU layers through -ngl, also called --n-gpu-layers. The November 2026 CLI accepts an exact number, auto or all. Choosing an exact number requests that many GPU layers.
A useful comparison has three configurations: the larger model with automatic placement, that same artifact with an explicit split, and a smaller fully GPU-resident candidate. The first two compare placement with the artifact held fixed. The third tests whether the larger model's quality gain is worth retaining at all.
| Placement | What it answers | What to record |
|---|---|---|
| CPU baseline | Can the machine finish without GPU layers? | Complete request time and system-memory use |
| Partial GPU offload | Can a larger useful model meet the deadline? | Actual layer placement, prompt time and generation time |
| Full GPU placement | Does the chosen configuration fit on the accelerator? | Remaining memory at the longest context |
For an illustrative decision, suppose the larger model takes 45 seconds and the smaller one takes 15 seconds. The larger model adds 30 seconds per request, or 50 × 30 = 1,500 seconds across fifty sequential requests. That is 25 extra minutes. If it prevents errors that otherwise take an hour to correct, it may be worthwhile. If both produce equally useful answers, prefer the shorter wait.
Control layers directly in llama.cpp
With a compatible llama.cpp build and a downloaded GGUF, run the same prompt using automatic placement and a fixed layer count. These examples reserve 4,096 context tokens and cap generation at 256 tokens:
./build/bin/llama-cli -m model.gguf -ngl auto -c 4096 -n 256 --temp 0 --single-turn -f prompt.txt
./build/bin/llama-cli -m model.gguf -ngl 10 -c 4096 -n 256 --temp 0 --single-turn -f prompt.txt
Use ten layers as an initial experiment setting. Add --log-verbosity 3 to both commands, then record the loaded layer count and allocated buffers from startup output. Increase the count in small steps only while your longest input still fits. Measure allocated bytes as well as layer counts, especially across different architectures.
For a full-placement trial, use -ngl all only when the complete working set fits. For a CPU comparison, use --device none -ngl 0. Keep the context fixed across trials, so the experiment measures placement rather than a simultaneous reduction in the cache budget.
On macOS, use a Metal-capable build; llama.cpp enables Metal by default in its documented Mac source build. On an NVIDIA Linux machine, its CUDA build uses -DGGML_CUDA=ON. The runtime must actually support your accelerator for these requests to be meaningful.
Use Ollama's num_gpu and inspect the result
Ollama's request options include num_gpu. In its llama.cpp runner implementation checked on 2026-11-22, a positive value becomes -ngl, zero requests CPU-only layers, and the default negative value leaves placement automatic. This describes that runner path; confirm behavior on the backend your selected model uses.
With Ollama already running, replace the model name below with your local artifact. The option belongs inside the request's options object:
curl http://localhost:11434/api/generate -d '{
"model": "YOUR_LOCAL_MODEL",
"prompt": "Extract the quantity and exception: Order 12 boxes, but cancel 2 if delivery is after Friday.",
"stream": false,
"options": {"num_ctx": 4096, "num_gpu": 10}
}'
ollama ps
Run ollama ps in another terminal while inference is active. Its PROCESSOR column reports memory placement: 100% GPU, 100% CPU or a CPU/GPU split. Read the split as memory placement; measure GPU utilization and speed separately. Remove num_gpu to compare automatic selection.
The HTTP example works in macOS and Linux terminals. It avoids changing a server-wide setting merely to test one request. Keep the runner version, model name and placement observation with the response so a future upgrade does not silently invalidate your comparison.
Try it on your workload
Choose five prompts, including your longest document and a case where the larger model has a clear quality advantage. Define the expected answer before timing anything. Run automatic placement, a conservative fixed split and the smaller fully resident candidate.
Repeat each prompt three times after the model has loaded. Save prompt-processing time, generation time, generated token counts, total elapsed time, memory and accepted answers. The commands use --temp 0 for greedy sampling; compare token counts so a shorter answer does not masquerade as faster placement. Label initial loading separately. Compare cold runs with cold runs and warm runs with warm runs.
Then repeat at the concurrency your application needs. A configuration that barely fits one request may have insufficient room for the extra cache required by simultaneous work. Record whether workers execute together or wait. Record the whole task group's finish time alongside the fastest response.
How to decide
- Keep partial offload when the larger model's accuracy advantage survives repeated tests and the waiting time is acceptable.
- Use the smaller resident model when it meets the same quality threshold with less delay.
- Reduce context or concurrency before increasing offload if your longest requests exhaust memory.
Run five larger-model agents for about 11 cents
Five extraction agents working at once on meta-llama/llama-3.3-70b-instruct cost about 11 cents in tokens on TrustedRouter for this workload. Use the larger hosted model on approved tasks where your partial-offload trial found a useful quality advantage.
On 2026-11-22, the live catalog listed approximately $0.142 per million input tokens and $0.422 per million output tokens. Suppose each agent consumes 100,000 input and 20,000 output tokens across its requests. Input = 5 × 100,000 = 500,000; output = 5 × 20,000 = 100,000. Cost = 0.5 × $0.142 + 0.1 × $0.422 = $0.1132, about 11 cents.
On one local GPU, those agents share throughput, and requests beyond its parallel capacity wait in line; through a per-token API, they can run together for the same token bill as sequential work. Compare accepted answers with your local split and smaller-model baselines. Prices change; check current prices, provider routing and agent setup. For approved data, encrypted inference and zero data retention depend on model and provider. Partial offload remains sensible for offline work or when the larger model's quality repays the local waiting time.
Sources
- llama.cpp: GPU-layer and device arguments
- llama.cpp: Metal and CUDA backend builds
- Ollama: mapping num_gpu to llama.cpp placement
- Ollama: request options and dynamic GPU-layer default
- Ollama: generation HTTP request
- Ollama: processor split and concurrent memory allocation