this post was submitted on 28 Jul 2026
1 points (66.7% liked)

LocalLLaMA

4964 readers
11 users here now

Welcome to LocalLLaMA! Here we discuss running and developing machine learning models at home. Lets explore cutting edge open source neural network technology together.

Get support from the community! Ask questions, share prompts, discuss benchmarks, get hyped at the latest and greatest model releases! Enjoy talking about our awesome hobby.

As ambassadors of the self-hosting machine learning community, we strive to support each other and share our enthusiasm in a positive constructive way.

Rules:

Rule 1 - No harassment or personal character attacks of community members. I.E no namecalling, no generalizing entire groups of people that make up our community, no baseless personal insults.

Rule 2 - No comparing artificial intelligence/machine learning models to cryptocurrency. I.E no comparing the usefulness of models to that of NFTs, no comparing the resource usage required to train a model is anything close to maintaining a blockchain/ mining for crypto, no implying its just a fad/bubble that will leave people with nothing of value when it burst.

Rule 3 - No comparing artificial intelligence/machine learning to simple text prediction algorithms. I.E statements such as "llms are basically just simple text predictions like what your phone keyboard autocorrect uses, and they're still using the same algorithms since <over 10 years ago>.

Rule 4 - No implying that models are devoid of purpose or potential for enriching peoples lives.

founded 3 years ago
MODERATORS
 

A habit that saved me a lot of failed local runs: I started measuring my context budget before a run instead of discovering the ceiling when generation silently truncates or the KV cache OOMs my GPU.

The thing that finally clicked for me is that on local models the context window isn't just a quality knob — it's a hard memory bill you pay up front. KV-cache size scales with (context length × layers × heads × 2 × dtype bytes), so doubling the prompt you feed in can quietly double the VRAM you need for cache before a single token is generated. On a 24GB card that's the difference between a run that fits and a run that pages/OOMs mid-generation.

What I do now, in order, before a long-context run:

  1. Tokenize the actual prompt, not a guess. The system prompt + retrieved chunks + few-shot examples + chat history almost always adds up to more than I expect. I count them with the model's own tokenizer, because token/word ratios drift a lot between a code-heavy prompt and prose.
  2. Budget the reply too. n_predict/max_tokens reserves cache. If I want a 1k-token answer I need room for prompt + 1k, not just the prompt.
  3. Compare against the real ceiling I loaded with, not the model's advertised max. If I loaded llama.cpp with -c 8192, that 8192 is my wall regardless of what the model card says it can do — and rope-scaling to a bigger context has its own quality cost.
  4. Trim at the retrieval/history layer, not by truncating the front of the prompt. Silent left-truncation is how you lose the system prompt and get a model that "forgot its instructions."

The mindset shift: treat the context window like a resource you allocate deliberately, the same way you'd think about VRAM for weights. Once I could see the budget as a number before hitting enter, a whole class of "why did it cut off / why did it OOM / why did it ignore my instructions" problems just went away.

Curious what everyone else uses to keep an eye on this — do you eyeball token counts, script it, or just crank -c and hope the card holds?

you are viewing a single comment's thread
view the rest of the comments
[–] troed@fedia.io 1 points 4 days ago

When I start llama-server I point it to the models-config that have unique max context sizes per model - and they're allocated at their max size as soon as the server starts so since it comes up I will be able to use that context size too.

I'm actually a bit unsure as to how you run it since you get OOMs during usage :)

I also use the DCP plugin for Opencode to help manage the context cache and have less of a disruption as it gets compressed, but I wouldn't need to for the above to work. When I hit the context limit the context would still get compressed.