How much context still fits on your GPU? mtop 1.7 works it out
mtop is a terminal view for local model servers: the models you have loaded and the VRAM they hold, the GPU, and the requests going through with their tok/s. It works with Ollama, llama.cpp, LM Studio, vLLM, Lemonade and SGLang.
How much context fits
Ollama picks the context size from your total VRAM: 4k on cards under 23 GB, 32k up to 47 GB, 256k above. So on a 12 or 16 GB card you're probably running 4k without knowing it, often with room for a lot more.
And when you go the other way and raise num_ctx too far, Ollama doesn't shrink it to fit. It moves layers to the CPU, and from then on every token waits on system RAM.
1.7 puts a line under the models table for the selected Ollama model:
ctx 4k ยท up to 22k fits on GPU
If the whole trained context fits, it says full 40k fits on GPU. And the CPU warning from 1.6 now tells you what to set:
โณ 38% of model on CPU ยท fits at ctx 16k
Reload with num_ctx 16384 (or OLLAMA_CONTEXT_LENGTH) and it's all on the GPU again. If no context would be small enough, because the weights themselves don't fit next to whatever else is loaded, it says GPU too full.
Where the number comes from
Each token of context costs a fixed amount of KV cache, and Ollama's /api/show hands over everything needed to work it out: layer count, KV heads, head size. For qwen3:0.6b that's 112 KiB per token, which is exactly what Ollama's own log prints when it allocates the cache.
Sliding-window models (gemma, gpt-oss), MLA (DeepSeek) and hybrid models with recurrent layers are counted the way llama.cpp actually allocates them, since their cache doesn't grow on every layer.
mtop takes the free VRAM right now, keeps the 1 GB margin llama.cpp leaves when it places layers, subtracts whatever already spilled to CPU, and divides by the per-token cost. I checked it on a 5090 by forcing a model 24% onto the CPU: mtop said fits at ctx 29k, I reloaded at 29k, and it was back on the GPU.
It errs low. On Windows the driver also evicts other apps' VRAM when it has to, so there's usually a bit more room than it says.
Ollama doesn't report its KV cache type or how many parallel slots it runs, so mtop reads OLLAMA_KV_CACHE_TYPE and OLLAMA_NUM_PARALLEL from its own environment. If your Ollama runs with different values (a systemd unit, say), the number is off by that factor.
llama.cpp, LM Studio and vLLM rows don't get a fit yet, since they don't expose the layer shapes.
Try it
mtop --demo runs on a simulated 16 GB card with a qwen3:8b pushed to its full 40k context and spilling to CPU, so you can see the lines without a server.
brew install eladser/tap/mtop
scoop install mtop
winget install eladser.mtop
Single Go binary, MIT.
- GitHub: https://github.com/eladser/mtop
- Release notes: https://github.com/eladser/mtop/releases/tag/v1.7.0
Comments
No comments yet. Start the discussion.