Four agents, one cache
Why I run Claude Code as four 512K sessions on one local GPU, and how to shrink that same split when the card is smaller.
I run Claude Code on a local model. The model is Inkling 2 Mini. It sits on one RTX PRO 6000, 96 GB, served by SGLang. The Mac I type on is the other machine, joined over a tailnet. No data goes to a cloud API.
A 1M session sounds like the roomy setup. It is the one that hogs the cache. One request at that length can fill most of the 1.98 million tokens we actually have, and a subagent then has little space.
Four sessions fit in the same pool. That is the setup I want.
Four slots, not one hog
The cache is one pool. The profile decides how many requests can live in it at once.
512k-x4
This is the new default.
- 4 requests in parallel
- 512K tokens each
- Four full sessions fill the cache
- Claude Code compacts at 400K, so a session is summarized before it hits the slot wall
A session and a subagent can both be full residents. Each one has a real window.
256k-x8
Eight requests, 256K each, when I want more subagents than full sessions. Compaction sits at 200K. This one needs a small patch. The FP8 decode kernel had a limit of 32 tokens per verify step, and this profile trips it.
Same pool, thinner slots. 4 x 512K and 8 x 256K are both 2048K of scheduled context. That product is multiplication, not a second measurement of the card. The measured cache is 1.98M tokens. Four full sessions fill it. Benchmarks for these two profiles are not ready.
The path, then the box
Hardware
- One Ubuntu desktop
- One NVIDIA RTX PRO 6000, 96 GB
- One Mac as the client
- A tailnet between them
SGLang
SGLang serves the model in a Docker container. A profile file sets the context length, the cache type, and the number of parallel requests. ./serve.sh takes the profile name. Startup takes about 1.5 minutes.
./serve.sh 512k-x4
Three changes make long context faster.
FP8 KV cache
The cache for the full-attention layers is FP8, not bf16. That halves the memory per token. The cache holds 1.98 million tokens. Before the switch it held 1.26M. Half the bytes per token is the mechanism. 1.26M to 1.98M is what we measured on this card. The whole GPU did not double, because the weights are still sitting there.
Split prefill
The model adds a position bias only to keys near the query. Far keys get no bias. Far keys and near keys run as two passes, then we merge them. The result is exact. Attention is 1.34 to 1.42 times faster.
Warmup
The server compiles its kernels at startup. The first request is not the one that pays for that compile.
The 1M numbers
These are the before and after at 1M context, on this one GPU. FP8 KV, split prefill, warmup. Not the new profiles.
| Measurement | Before | After |
|---|---|---|
| Decode step at 1M tokens | 34.2 ms | 24.9 ms |
| Cold prefill of 1M tokens | 302 s | 217 s |
| Cache capacity | 1.26M tokens | 1.98M tokens |
| Needle retrieval at 256K and 1M | not tested | 6 of 6 |
Short prompts decode at 270 to 490 tokens per second. That is the range we have, not a single point.
Needle retrieval at 256K and at 1M was not tested before these changes. After, it was 6 of 6.
The Go gateway
Claude Code speaks the Anthropic Messages API. SGLang does not. A small Go program sits in front and does five jobs:
- It checks a private token.
- It sends every model name to Inkling.
- It turns the thinking budget into an effort level.
- It sends keepalive events during a long prefill.
- It turns an over-length prompt into a "prompt is too long" error. Claude Code then compacts.
That last one is the backstop. Compaction is the thing we aim to hit first: 400K on the 512K profile, 200K on the 256K profile.
A profile that does not touch the normal one
The inkling alias starts Claude Code with its own config folder. The normal Claude Code setup does not change.
- Every model name points at Inkling, including the subagent model.
- Web search is off.
- The attribution header is off, so the server can cache the system prompt across sessions.
Switching
The context size in Claude Code has to agree with the server profile. If the client still thinks it has 1M and the server is on 512k-x4, compaction and the "too long" error fire at the wrong time.
- On the server, run
./serve.shwith the profile. About 1.5 minutes. - Build the Mac installer again, with the same context size.
- Run that installer on the Mac.
When the GPU is smaller
This box is 96 GB. A 24 GB card, a 32 GB card, a 48 GB card, or an Apple Silicon Mac has the same shape of problem and less room. I have no measurements for those machines. Same mechanics, plus arithmetic on the numbers above. Back-of-envelope, not a benchmark.
Four levers.
- Fewer parallel slots, or a shorter context on each slot. Two cuts I would actually try:
2 x 256K, or4 x 128K. - FP8 on the KV cache. Half the bytes per token, so the same cache budget holds twice the tokens. On this 96 GB box the measured cache went from 1.26M to 1.98M. That pair is the evidence. A token count for a 24 GB card would also have to subtract the weights, and I do not have that weight size, so I am not printing one.
- Match Claude Code's context, and its compaction, to the profile you started. On the two profiles we run, compaction is 400K inside 512K and 200K inside 256K.
400/512and200/256are the same fraction. - A smaller model, or a more quantized one, when the weights themselves no longer fit.
The slot math, shown rather than implied:
4 x 512K = 2048K, compaction at 400K. This is the real default profile.8 x 256K = 2048K, compaction at 200K. Real profile, plus the 32 token verify patch.2 x 256K = 512K. Envelope. Compaction at 200K is the 256K rule we already use.4 x 128K = 512K. Envelope.128K x 400/512 = 100K. That 100K is the fraction applied to a slot we have not run. It is not a measured compaction point.
Limits
- FP8 is an approximation. Use a bf16 profile when you need exact results.
- The patches agree with one pinned SGLang image. Check them again before you upgrade the image.
- Benchmark results for
512k-x4and256k-x8are not ready yet.