All field notes

FIELD NOTES /

Renting a brain by the hour

I rented a V100 by the hour, taught a 27B model to guess its own next words, and squeezed 60% more context out of the same card. Exact numbers, exact settings.

  • infrastructure
  • ai
  • self-hosting

I wanted my own AI assistant. Not someone else’s API, with someone else’s limits and someone else’s monthly bill. My own model, running on a computer I controlled, that I could plug into my coding tools like any other service.

The model is Qwen3.8 27B, a 27-billion-parameter open-weights model, which I run as a GGUF file in the Q5_K_M quantization: 19.5 GB. It has a hybrid state-space and attention architecture, a native context length of 262,144 tokens, and a built-in multi-token-prediction head (more on that shortly).

A model that size needs a very specific, very expensive piece of hardware: a graphics card with a lot of memory, the kind normally bought by companies training the next big thing, not by one person for a side project. Buying one outright didn’t make sense, so I rented one by the hour: a 32 GB NVIDIA V100, for about $0.21 an hour, from Vast.ai, a marketplace where people with spare GPU capacity list it for anyone to use.

Renting a brain by the hour Your laptop OpenCode / Codex you, at your desk a rented computer, somewhere else a stranger's spare GPU, by the hour The AI model 27 billion settings "explain this bug" the answer
The request and response arrows draw themselves in on load.

That part worked on the first day. The model ran under Ollama at first, and later directly under llama-server, the serving engine from llama.cpp, and my coding tools talked to it over a plain OpenAI-compatible API like any other provider.

The hard, interesting part came after: making it fast enough and long-memoried enough to be genuinely pleasant to use. That’s the part worth writing down, with the actual numbers.

The slow way a model normally talks

A model writes one token at a time (a token is roughly a piece of a word). What makes that slow usually isn’t the maths. It’s memory traffic: to produce each token, the GPU has to read every one of the model’s weights, all 19.5 GB of them, out of its memory. A V100 moves about 900 GB a second, so it can do that roughly 46 times a second. That’s the ceiling for one token per pass, no matter how fast the chip computes.

There’s a shortcut called speculative decoding. Let the model guess several tokens ahead cheaply, using a small prediction head built into the same model, then check all of those guesses in a single pass. Checking four tokens costs barely more than checking one, because the expensive part, reading the weights, happens once either way. If the guesses were right, which they usually are, you got several tokens for the price of one pass. If one was wrong partway through, you keep the tokens before it and redo from there. You never end up worse off than the slow way.

Why speculative decoding is faster the model drafts 4 words ahead, cheaplyg1g2g3g4 the real model checks all 4 at onceone pass, not four best case: all 4 land 4 words kept, 1 check instead of 4 typical case: one misses 2 words kept, redo from the miss either way: never slower than checking one word at a timea wrong guess costs a small redo, never a wrong answer
Draft cheap, verify once, keep what's right.

Turning this on took one flag at launch: --spec-type draft-mtp. The model already knew how to guess its own next few tokens, that ability (multi-token prediction) was baked into the GGUF, so llama.cpp just had to be told to use it, no separate draft model to download or manage. Every guess still gets checked against the full model before it counts, so a wrong guess costs a small redo, never a wrong answer.

On my first rental, generation went from about 12 tokens a second to about 42. Treat that as rough. The 12 was the model running under Ollama’s default setup, the 42 was llama-server with speculative decoding on, so the jump also includes the switch between the two, and I never measured llama-server without it on that machine.

Every number from here on comes from a later rental and a fixed benchmark prompt, and they’re higher again, around 53 to 54 tokens a second. Three things changed: a smaller file (the Q5_K_M quantization at 19.5 GB, instead of the 22.4 GB Q6_K I started with, and every token means reading the whole file), a newer llama.cpp build, and a prompt whose next tokens the model guessed a little more often (70% of guesses accepted instead of 65%). Note that 54 is above the ceiling of 46 tokens a second for one token per pass. That’s only possible because each pass now yields more than one token.

Giving it a longer memory

Speed solved, the second problem was memory, specifically the model’s working memory of the conversation (its KV cache), not RAM in the everyday sense. Everything said to it so far in a session has to stay resident on the same GPU as the model itself. Once the card fills up, the conversation can’t get any longer.

At -c 163840 (163,840 tokens of context) and full precision, the server used 30,178 MiB of the card’s 32,768 MiB, leaving about 2.6 GB of headroom. That’s a long conversation already, but my coding tools paste in a lot of surrounding code on every turn, and I wanted more room before hitting the wall.

The fix was KV cache quantization: two flags, -ctk q8_0 -ctv q8_0, storing each cached token at 8-bit precision instead of 16-bit. At the same 163,840-token context, memory use dropped to 25,960 MiB, a 4.2 GB reduction, enough headroom to push the context all the way to 262,144 tokens, the model’s full native length, while still using only 30,176 MiB.

Why 60% more context and not double, if each entry is half the size? It isn’t quite half: the 8-bit format also stores a scale factor for every block of 32 values. And some of the server’s other working buffers grow with the context too. In the end, 60% more context filled the same memory, which also happens to be as far as this model goes.

I checked this wasn’t a free lunch with a catch: I sent the model the exact same prompt at temperature: 0 (its single most confident, deterministic setting) before and after enabling the quantized cache. Both runs accepted exactly 203 of 288 speculative-decoding guesses and produced identical output on that test prompt. Throughput was unchanged too, 53 to 54 tokens a second either way. One prompt isn’t proof that nothing ever changes, but it’s a strong sign. A hybrid state-space and attention model like this one only keeps a KV cache for its attention layers, which may be why it tolerates this kind of compression better than a pure attention model would.

Making room for a longer conversation the GPU has one fixed memory budget, about 30 GB, every time model weights, fixed 16-bit cache 163,840 tokens fit 30,178 MiB used model weights, fixed 8-bit cache 262,144 tokens fit 30,176 MiB used same budget, same model, smaller cells, 60% more room for conversation
Same 30 GB of VRAM, 60% more context, because the cache got smaller per token.

A trick that didn’t travel

Here’s the part I almost skipped writing about, because it’s a story about something not working, but it taught me the most useful lesson of the project.

While researching speculative decoding, I found a published benchmark running this exact model on a Jetson Thor board, where raising --spec-draft-n-max (how many tokens ahead the model is allowed to guess per batch, default 3) had taken throughput from about 13 tokens a second to about 35. Free extra speed, same model: I copied the setting.

On the V100, it didn’t transfer. I benchmarked each value with the same deterministic prompt, temperature: 0, 300 tokens, restarting the server for each setting:

--spec-draft-n-max runs tokens/second guesses accepted
3 (default) 3 53.9 to 54.6 203 of 288 (70.5%)
4 1 55.0 216 of 330 (65.5%)
6 1 47.1 227 of 429 (52.9%)

At temperature: 0 the output is deterministic, so the accepted counts were identical on every run. Only the speed wobbles. I ran 4 and 6 once each, so the yardstick for noise is the three default runs, which spread over 0.7 tokens a second. Four’s 55.0 sits 0.4 above the best of those, which is indistinguishable. Six’s 47.1 is almost seven below the worst, which is a real drop: the model proposed more tokens per batch, but the acceptance rate fell faster than the batch grew, so each pass did more wasted work for the same payoff.

My best explanation goes back to memory bandwidth, though I haven’t measured it directly. Checking extra guesses is nearly free only while reading the weights dominates each pass. A Jetson Thor has roughly a third of a V100’s memory bandwidth and far more compute for every byte it reads, so reading weights dominates even more there, and longer guesses keep paying off. The V100 sits at a different balance, where the extra checking work of longer guesses starts to show, and the wrong guesses cost more than the right ones save. A tuning number that’s a free win on one card can be a net loss on another, and the only way to know is to measure on the card you actually have.

What it cost

The V100 these measurements ran on cost $0.21 an hour. Across every rental since September, including false starts on hosts that turned out to be broken, I’ve spent $10.35 in total.

Only $2.47 of that was GPU time, about twelve hours of it. The biggest line on the bill was something else. When you stop a rented machine, you stop paying for its GPU but not for its disk, which keeps the 19.5 GB model so you don’t have to download it again. I left one stopped machine sitting for 25 days, and its disk came to $7.54, three times what all the GPU time cost. If you try this, destroy the machine when you’re done. Downloading the model again next time cost me about five cents in bandwidth.

The sweet spot, if you’re running this on a V100

If you’ve got this same model on the same class of card, a 32 GB V100, here’s the configuration I landed on after all of the above:

llama-server \
  --model Qwen3.8-27B-Q5_K_M.gguf \
  --spec-type draft-mtp \
  -ctk q8_0 -ctv q8_0 \
  -c 262144 \
  -ngl 999 -np 1 -b 512 -ub 512 \
  --flash-attn auto

The three settings this post is about:

  • --spec-type draft-mtp at the default --spec-draft-n-max (3). Don’t raise it on a V100. Four made no measurable difference, and six was clearly slower.
  • -ctk q8_0 -ctv q8_0, always on. Identical output on my test prompt at temperature: 0, and it’s the one change that buys real headroom.
  • -c 262144, the model’s full native context, only reachable because of the quantized cache. Expect roughly 30.2 GB used out of 32 GB, about 2.6 GB of margin.

And the rest, which are standard for a single-user setup:

  • -ngl 999 puts every layer of the model on the GPU. Any number above the layer count works, 999 just means “all of them”.
  • -np 1 gives the server one conversation slot, so the whole context belongs to one user. Two slots would split it in half.
  • -b 512 -ub 512 set how many prompt tokens are processed per batch. They affect how quickly a long prompt is read in, not how fast the answer is written.
  • --flash-attn auto uses the fused attention kernel where the GPU supports it.

One flag is missing on purpose: --context-shift, which normally lets a long conversation roll its oldest part out of memory. On this model it never engages. The server logs “KV cache shifting is not supported for this context, disabling KV cache shifting” every time, so budget for a hard wall at 262,144 tokens, not a graceful rollover past it.

Expect somewhere around 54 tokens a second on a single stream, and full native context, on a GPU that costs about 21 cents an hour. None of this required new hardware or new code, just about twelve hours of rented GPU, changing one setting at a time and trusting the measurement over the write-up, including this one.

Back to field notes