Run in production
Size KVStash and tune the network
How much memory and flash a store node needs follows from one number: bytes of KV cache per token. How fast blocks come back follows from the bandwidth you can actually deliver between engine and store.
Last updated
Bytes per token
Each token stores a key and a value vector in every layer, for every KV head. From the model's config.json:
bytes per token = 2 × layers × KV heads × head dim × bytes per value
Bytes per value is 2 for BF16 or FP16 and 1 for an FP8 KV cache. Models with grouped-query attention have far fewer KV heads than attention heads, which is what keeps these numbers manageable.
| Model | BF16, per token | FP8, per token | 100k-token prompt, BF16 |
|---|---|---|---|
| Llama 3.1 8B | 131,072 B | 65,536 B | 13.1 GB |
| Llama 3.1 70B | 327,680 B | 163,840 B | 32.8 GB |
| Qwen2.5 7B | 57,344 B | 28,672 B | 5.7 GB |
| Mistral 7B (v0.3) | 131,072 B | 65,536 B | 13.1 GB |
A measured example: the 524,231-token prompt in our vLLM study read back 21.47 GB from the store per request, 8,191 blocks. For any other model, use the KV cache calculator.
Sizing each tier
DRAMdram_arena_bytesYour hot prefix set: the system prompts, documents and conversations reused within minutes, multiplied by bytes per token. Reads from here are limited by the network, not the store.
NVMenvme_max_bytesThe warm tail reused within hours or days. Size it to what you would otherwise recompute; leave headroom on the device, since the budget must fit inside the filesystem.
S3no size settingGrows with what spills from NVMe; the bucket lifecycle rule bounds it. Budget storage cost, not capacity.
Blocks are typically 0.4 to 2.5 MB. The arena must hold at least one block of max_blob_len (32 MiB by default); anything above a few GiB is a real deployment.
Deployment shapes
| Shape | DRAM arena | NVMe | Notes |
|---|---|---|---|
| Laptop or test | 1 GiB | none | The quickstart default |
| Store on the GPU server | 16 to 64 GiB, hugepages | optional, 1 device | Engines connect over loopback, the fastest path. Most of our GPU benchmarks ran this way. |
| Shared cache node | 64 to 256 GiB, hugepages | 1 to 8 devices | Several GPU servers share it over 25 to 100 GbE. Apply the host tuning below and measure the network ceiling. |
A store on the GPU server keeps blocks across engine restarts on that server. A shared node also lets a new or different server start warm with prompts another server already computed.
Network: what matters
Reading a prefix back takes roughly its size divided by the bandwidth you can deliver. A 13 GB prefix over a link that delivers 3 GB/s takes about 4.3 seconds; recomputing it on the GPU may take less or far more, depending on the model and prompt length. The longer the prompt, the more reading wins, because recompute grows faster than linearly with length while reading grows linearly.
- The store can fill the wire. Batched reads at 6.22 GB/s on a 50 GbE link, 100% of the iperf3 ceiling measured on the same pair minutes earlier, with checksums on. Two AWS c6in.8xlarge, private IPs, cluster placement group; payload-only goodput (decimal GB/s), GET-only, batch 32, median of 3.
- Below about 10 GbE between engine and store, recompute usually wins for anything but the longest prompts. Put the store on the GPU server in that case.
- Several streams per engine. The adapters open several TCP connections and read in parallel; our vLLM results use 8 streams and 8 parallel reads.
- No RDMA needed, and none supported: KVStash is built for the Ethernet most clusters already have.
Host tuning
For links of 25 GbE and above, apply this profile on the store and on engine hosts. It is the one our benchmark machines use, derived from ESnet's guidance for fast hosts: fair queueing for per-flow pacing, large socket buffer ceilings, BBR congestion control and deeper accept queues.
# /etc/sysctl.d/90-kvblockd-net.conf, for 25-100 GbE links
net.core.default_qdisc = fq
net.core.rmem_max = 268435456
net.core.wmem_max = 268435456
net.ipv4.tcp_rmem = 4096 87380 268435456
net.ipv4.tcp_wmem = 4096 65536 268435456
net.core.optmem_max = 1048576
net.core.somaxconn = 4096
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_congestion_control = bbr
net.ipv4.tcp_mtu_probing = 1 sudo sysctl -p /etc/sysctl.d/90-kvblockd-net.conf - Socket buffers. The daemon asks for 16 MiB per connection (
sock_sndbuf,sock_rcvbuf). Untuned hosts cap it silently; the daemon logs the size it actually got when a client connects, so check the log once. - Jumbo frames (MTU 9001) helped on our AWS machines. Enable them only if every hop supports them.
Measure your ceiling
Compare KVStash against what your network delivers, not against the NIC's label. Measure with several streams between an engine host and the store:
# on the store machine
iperf3 -s
# on an engine machine: 8 parallel streams, 20 seconds
iperf3 -c STORE_HOST -P 8 -t 20 Then watch rate(kvb_bytes_total{dir="out"}[1m]) during a warm request. On a tuned host, batched reads should approach the iperf3 figure. If they stay far below it, check the socket buffer log line, the sysctls above, and whether the engine is CPU-bound copying blocks into GPU memory.
Something missing or wrong on this page? Email rudray@kvstash.com and it gets fixed.