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.

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

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.

1M context on one RTX PRO 6000
MeasurementBeforeAfter
Decode step at 1M tokens34.2 ms24.9 ms
Cold prefill of 1M tokens302 s217 s
Cache capacity1.26M tokens1.98M tokens
Needle retrieval at 256K and 1Mnot tested6 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:

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.

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.

  1. On the server, run ./serve.sh with the profile. About 1.5 minutes.
  2. Build the Mac installer again, with the same context size.
  3. 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.

The slot math, shown rather than implied:

Limits