What this is about
Think of a desk and a warehouse. The desk is small and close. The warehouse is huge and far. You keep on the desk what you use all the time, and fetch the rest when you need it. A computer works the same way, and so does a big model on a graphics card.
In this article, the desk is the card's fast memory, and the warehouse is your computer's ordinary memory. We keep the rarely used parts of a large model in the warehouse. This article is about what that costs, and what we found hard.
Why it matters
A big model may not fit on your card. If the only choice were "fits or does not fit", most home computers could run nothing big. Moving the less-used parts to ordinary memory gives you a middle path.
But the move is not free. Every fetch takes time, and the way you fetch matters more than you would guess. We learned that the hard way, and the lesson applies to any program that keeps data in two places.
How the trade works
The model in our test is a mixture of experts. Each layer has 256 experts, and for each token only 8 of them work. So at any moment, most of the model's weight is idle. That is what makes the trade possible.
The setup. We keep the shared parts of the model, 2.68 GB, on the card. The other 18.3 GB, which holds the experts, stays in host RAM. The card keeps a small cache of experts it used lately.
A neat shortcut. Our two expert programs on the card do not care how many experts exist. They only ask "where is expert number so-and-so?" So we could hand them 64 cache slots instead of 256 experts, and they ran unchanged. The only new code decides which slot holds which expert and fetches the missing ones.
What happens per token. The router picks 8 experts. The engine checks which are already in the cache. It fetches the rest, then runs the math.
The cache is not the bottleneck. We replayed 51,200 expert requests offline across 20 prompts before building the live version. A 4.5 GB cache with 64 slots would cover 76.7 percent of them. The live cache hit 77.43 percent, inside the predicted band. What to fetch was never the problem.
The three rounds
Round 1: correct and slow. The first version fetched through the operating system's page cache, one blocking read at a time. That meant about 40 round trips per token, one for each layer. The output matched the full engine on 20 of 20 prompts. The speed was 39 tokens a second. On the first prompt, 1.74 seconds of a 1.75 second decode went to waiting for fetches.
Round 2: pin the memory. Normal memory can be moved or swapped by the operating system. If you pin a block, it stays put, and the card can copy from it directly. Same cache, same output. In one session the unpinned version read 48.57 tokens a second and the pinned one 67.12, a 1.38 times gain. That is a bigger gain than the raw copy speed predicts. When we compared pinned and normal copy directly, they differed by only 0.6 percent. The win was not bandwidth. It was avoiding the page-fault path.
The price: 18.3 GB of a 64 GB machine is now locked and no other program can use it.
Round 3: read it where it sits. If a kernel needs an expert anyway, it can read it straight from pinned memory while it computes, instead of copying it first. We did this for two of the three kernel kinds. In its own session, speed went from 67.71 to 72.02, a 1.064 times gain. Output still identical.
A small test explains the limit. Reading over the card's link to host memory ran at 24.6 to 27.2 GB per second when 8 to 24 reads were in flight at once. With only 2 in flight it dropped to 14 to 15. Reading in place wins when the kernel has enough independent reads going to hide the delay. It does not beat a copy automatically.
What it cost
The full engine on the same card, with all 21 GB in VRAM, reached 111.89 tokens a second in a comparable run. So the tier runs at about two-thirds of that. It is a way to run a model that does not fit, not a replacement for having enough memory.
Two things we did not measure. We have not tested the design on a model whose experts really do not fit in 24 GB. And we do not know yet how much the locked memory hurts on a machine that is busy with other jobs.
The rule we wrote down
A cache that fetches correctly is not the same as a cache that fetches fast. Measure what you fetch and how you fetch it as two separate questions.
Words you may not know
- Host RAM: the ordinary memory of your computer.
- VRAM: the memory on the graphics card.
- Cache: a small fast store of recently used things.
- Pinned memory: memory the operating system promises not to move.
- Page fault: a stop while the operating system finds or loads a piece of memory.
- LRU: "least recently used", a rule for what to drop from a cache first.
- tok/s: tokens per second, how fast the model writes.
Try it
Our engine with this expert tier is on the mojo-baro project page, and the code is on GitHub. The repository records each measurement with its protocol.
A small test at home: time how long your computer takes to read a 1 GB file the first time, and then again. The second read is fast because the system cached it. That gap is the same idea in miniature. Tell us what you found at gllm.forum.
Read next
Experts in Host RAM has the full engineering detail and the commit-level steps.

Komentarze
Brak komentarzy.
Zaloguj się aby skomentować.