Small Card, Smart Settings

You can't make a small graphics card bigger. You can stop it from wasting what it has.

Small Card, Smart Settings

Under my desk sits a server that would embarrass any data centre. It has
two server processors from 2017, a generous 141 gigabytes of ordinary
memory, and one modest graphics card: an Nvidia T400 with 4 gigabytes of
its own memory, drawing about as much power as a light bulb.

I wanted that card to do something that sounds ambitious for its size: read
a software project file by file and write a short summary of each one, the
kind of index a code-search tool needs. A cloud model can do this easily.
The question was whether a local one could do it well, on hardware I
already own.

The accelerators in data centres carry 20 times as much memory or more. On
my card, the AI model, its working memory and everything around it have to
share 4 gigabytes. So the problem is not raw power. It is budgeting.

Optimizing a local language model turns out to mean spending three budgets
carefully: memory, meaning what fits on the card; compute, meaning
how much the card can do per second; and the work itself, meaning how
much text you ask the model to read and write. Over a few days of
measurements I found six levers that move those budgets. One of them turned
up 1.7 gigabytes of the card held back for a feature my workload never
uses.

Lever 1: Pick a model that fits the card

A language model does two different jobs, at two different speeds. First it
reads: it processes the prompt, the text you give it. Then it
writes: it generates the answer, one piece at a time. Both are measured
in tokens, the word fragments models work with; a token is roughly three
quarters of a word.

I tested three small models. The veteran, qwen2.5 with 1.5 billion
parameters, is small and well-tested. The newcomer, qwen3.5 with 2
billion, uses a hybrid design that I'll come back to. The heavyweight,
lfm2.5, has 8 billion parameters, but as a "mixture of experts" it uses
only about 1 billion of them for each token, like a large staff in which
only a few people work on any given question.

Two line charts. Reading speed in tokens per second at 2k, 8k and 24k-token prompts: qwen3.5 183, 165, 128; qwen2.5 171, 118, 66; lfm2.5 70, 70, 64. Writing speed: qwen3.5 31.1, 29.1, 24.4; qwen2.5 40.0, 30.1, 18.1; lfm2.5 25.3, 21.8, 17.6.

Figure 1. Reading and writing speed for prompts of about 2,000, 8,000 and
24,000 tokens. Each point is the median of three runs; every run was within
3 percent of its median.

The heavyweight never had a chance. It did not fit entirely on the card, so
a slice of it ran on the main processor, and most likely because of that it
read at a flat 70 tokens per second, whatever the prompt length. It also
ignored my instruction not to "think out loud." Instead of reasoning in the
separate channel meant for it, it wrote its deliberations into the answer
itself: about 68 percent of all the characters it produced, pooled over
nine summaries (59 to 76 percent per summary). Those are characters I would
have had to strip out, and tokens I paid for in time.

The contest between the other two depended on the length of the prompt. On
short prompts the veteran wrote fastest. But as prompts grew it slowed
sharply. At 24,000 tokens it read at 66 tokens per second, about half the
newcomer's 128.

Model Reading 2k / 24k Writing 2k / 24k Fully on the card?
qwen3.5 2B 183 / 128 tok/s 31 / 24 tok/s yes
qwen2.5 1.5B 171 / 66 tok/s 40 / 18 tok/s yes
lfm2.5 8B-A1B 70 / 64 tok/s 25 / 18 tok/s no

"Fits," it turns out, means more than the parameter count. A model has to
fit the card's memory, and it has to cope with the length of the prompts
your work actually produces.

Lever 2: Know what a slot costs

To run several requests at once, the server sets aside a slot for each
one. Every slot needs its own working memory of the text, called the KV
cache
. For each token, the model stores a "key" and a "value" so it can
look back at that token later. For a window of 32,768 tokens, that adds up.

Here the newcomer's hybrid design pays off. Only 6 of qwen3.5's 24 layers
keep a token-by-token cache. The other 18 carry a small summary of fixed
size, no matter how long the text grows. It is like a reader who takes
detailed notes in a quarter of the chapters and keeps only the gist of the
rest.

Stacked bars of memory per slot. qwen3.5 as it is, with a KV cache in 6 of its 24 layers (measured): KV cache 204, scratch space 64, fixed-size state 19, about 287 MiB. If all 24 layers kept a KV cache (calculated): KV cache 816, scratch space 64, about 880 MiB.

Figure 2. Memory per slot in mebibytes (MiB, a little more than a
megabyte). Top: measured as the difference between loading the model with
two slots and with four. Bottom: calculated.

The measured cost is about 290 MiB per slot: roughly 204 for the KV cache,
19 for the fixed-size state and 64 for shared scratch space that grows with
the total window across all slots. Three independent readings agree to
within 1 MiB: the server's own buffer sizes, the graphics driver's memory
counter, and the loading planner's estimate. Had every layer kept a full
cache, a slot would cost about 880 MiB (a calculation, not a measurement),
and only one would fit beside the model.

Two more dials work on the same arithmetic: a shorter window shrinks the
cache proportionally, and storing the cache at 8-bit instead of 16-bit
precision halves it. I use 8-bit throughout.

Lever 3: Keep the card for the model that needs it

A code-search tool needs a second, much smaller model: an embedding
model
, which turns text into lists of numbers that can be searched by
meaning. If both models lived on the card, each could push the other out of
memory whenever the work switched between them, and reloading a model takes
seconds to minutes.

The fix was to run the embedding model on the main processor, which has
memory to spare. With each of the three chat models loaded, I alternated
chat and embedding requests five times: no reloads, no graphics memory used
for embeddings, and 3 to 4.5 text chunks embedded per second (one test per
model).

Lever 4: Find the hidden reserve

More slots should mean more work done at once, and my first, rougher
arithmetic said seven would fit. I set seven, and the model was pushed largely off the
card: only 5 of its 25 layers stayed on the graphics processor.

The explanation was in the server's logs and, eventually, its source code.
qwen3.5 can also look at images. In Ollama, the server software I use
(version 0.40 at the time of writing), a model with an image component makes
the memory planner keep that component's size plus 1 gigabyte free: 1,689
MiB on this card, nearly half of its free memory. The margin is deliberate, because the
planner doesn't yet count the image component itself. But for a workload
that only reads text, it is memory set aside and never used.

Stacked bars of GPU memory in MiB against the 3,635 MiB free on the card. Defaults with 2 slots: weights 1,205, per-slot memory 447, scratch 192, kept free 1,689; fits. Defaults with 7 slots: weights 1,205, per-slot 1,563, scratch 514, kept free 1,689; 1,336 MiB over. Kept free lowered to 900 with 4 slots: weights 1,205, per-slot 893, scratch 320, kept free 900; fits.

Figure 3. How the planner divides the card's free memory. One load per
setting; the planner's arithmetic is deterministic.

With the default reserve, only two slots fit. A single setting lowers the
reserve to 900 MiB, which still covers the roughly 665 MiB image component
with some margin. With it, four slots fit entirely on the card, with about
660 MiB still free. As a check, I sent one test image, split into a red half
and a blue half; the model named both colours. One image is a smoke test,
not proof for every image size, and the margin should be checked again
whenever the model changes.

Lever 5: Decide how many requests run at once

The intuition is that more slots mean more speed. The reality is more like a
kitchen with one cook and several pans. Extra pans don't make any single dish
faster, but up to a point the kitchen serves more dishes per hour.

I measured this first with fixed prompts, three runs each. Running two
requests together made each one slower: a 2,000-token prompt with a
1,024-token answer took a median of 45.5 seconds on its own and 70.5
seconds as half of a pair. Yet the pair got more done. With short prompts,
it produced 29 percent more output per minute than a single request, 12
percent with 8,000-token prompts and only 4 percent with 24,000-token
prompts.

Bar chart. Running two requests at once produces 29% more output per minute with 2k-token prompts, 12% with 8k and 4% with 24k.

Figure 4. Extra output per minute when two requests share the card,
computed from medians of three runs.

The pattern has a simple cause. Reading is limited by the card's compute, so
two requests reading at once just take turns. Writing gains from sharing, because the card can produce a token for each of two requests in much less
than twice the time of one. Long prompts are mostly reading, so they gain little.

Then came the real test: summarizing all 68 files of a code repository,
about 99,000 tokens of input, with one to four requests at once. Each
setting ran twice, in the order 1-2-3-4-4-3-2-1, so any drift over time
would affect every setting equally. The two runs of a setting never differed
by more than 43 seconds.

Two charts by number of requests at once, 1 to 4. Whole repository: 17.6, 15.4, 14.9, 14.0 minutes. Median wait per file: 11, 18, 25, 31 seconds.

Figure 5. Left: time to summarize the whole repository. Right: the median
time each file took within a run. Dots are the average of two runs; the
bars span both runs.

With four at once, the repository finished 21 percent sooner, while each
file waited nearly three times as long. For a background job, that is an
easy trade. For a chat in which a person is waiting, fewer at once will feel
faster.

Requests at once Whole repository Saved vs 1 Median wait per file
1 17.6 min (17.3 and 17.9) – 11 s
2 15.4 min (15.0 and 15.8) 12% 18 s
3 14.9 min (14.8 and 15.1) 15% 25 s
4 14.0 min (13.9 and 14.0) 21% 31 s

Lever 6: Don't do work you don't need

On this card, writing a token costs five to six times as much as reading
one: qwen3.5 reads 165 to 183 tokens per second at short and medium prompt
lengths, and writes 29 to 31 (medians). The cheapest speed-up, then, is to
ask for shorter answers. My file summaries averaged 216 tokens (mean of 544
summaries; median 200).

The input deserves the same scrutiny. In my own repositories the typical
file is small: the median is about 300 tokens. But in one of them, a single
machine-generated list of dependencies, a so-called lock file, made up 41
percent of all the text (both figures are estimates at four characters per
token). Skipping lock files, licences, binary files and empty files cost
nothing. The fastest token is the one the model never has to read.

What 4 gigabytes can do

The card under my desk now summarizes a 68-file codebase in about 14
minutes, drawing about as much power as a light bulb. None of it required
new hardware. It required finding out where the memory, the compute and the
work were going.

Lever Setting What it bought
Model hybrid qwen3.5 2B about twice the reading speed of the alternatives at 24,000 tokens (median of 3)
Slot cost 8-bit cache, hybrid layers about 290 MiB per slot (measured) instead of about 880 (calculated)
Embeddings on the main processor no reloads, no graphics memory (one test per model)
Hidden reserve keep 900 MiB free, not 1,689 4 slots instead of 2
Concurrency 4 requests at once 21% less total time (average of 2 runs)
Less work skip generated files, short answers a large share of tokens never processed

The card under my desk still has 4 gigabytes. It just wastes less of them.


How I measured

Hardware: one Nvidia T400 with 4 GB of memory, two Intel Xeon Silver
4110 processors and 141 GB of RAM. Software: Ollama 0.40.16, which runs
models on the open-source llama.cpp engine; models stored at 4-bit
precision (Q4_K_M); an 8-bit KV cache; a 32,768-token window.

Speeds are the server's own timings for reading and writing, so the
network between my laptop and the server doesn't affect them. Times to
finish a job are wall-clock times.

Repeats and statistics: the fixed-prompt tests ran one warm-up and
three measured runs; I report the median, and every run was within 3
percent of it. The repository test ran two runs per setting in up-down
order; I report their average and give both values. Memory figures come
from one load per setting. Memory is in mebibytes (1 MiB = 1,048,576
bytes).

Keeping runs independent: every prompt began with a unique marker, so
no run could reuse another's cached work. Every run was checked for
reasoning text in the output and for the model staying entirely on the
card.

Limits: one machine; one repository for the concurrency test; answer
quality judged by reading samples, not scored.

Subscribe to Dr. Jawad Tahir

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe