Long prompts on SGLang: 110k tokens in 1.5 s instead of 20.8 s
Reading the KV cache back from KVStash reached the first token 5.3x to 13.7x sooner than recomputing it on one L40S, growing with prompt length; 13-19x at 110k tokens across 8 runs. KVStash is for prefixes SGLang no longer holds; while its own GPU and host-memory caches still hold one, they are faster.
- SGLang 0.5.15.post1
- Qwen2.5-7B-Instruct, BF16
- One GPU per server
- Store on the same host
- NVIDIA L40S
- 29-30 October 2026
Last updated
Results in brief
-
20.8 s→1.52 s
Time to first token for a 110,016-token prompt, recomputed and read from KVStash.
-
13-19x
Faster than recomputing at 110k tokens, across 8 runs from different experiments, median about 14x.
-
12 of 12
Outputs identical to SGLang's own cache at the same reuse split.
Test setup
One engine, one model and one GPU per server, with the store on the same host. Every number on this page comes from this setup on L40S machines.
- Engine
- SGLang 0.5.15.post1 (official cu129 runtime image), HiCache with KVStash as the storage tier, page size 64
- Model
- Qwen/Qwen2.5-7B-Instruct (revision a09a3545), BF16 weights and KV cache (57,344 bytes per token), one GPU
- GPU
- NVIDIA L40S 48 GB on Modal (some runs on H100 80 GB). This page uses L40S runs only.
- Store
- KVStash daemon on the same host as the GPU server, reached over TCP (loopback), DRAM arena unless stated
- Long context
- YaRN x4 rope scaling for prompts above 32k tokens
- Cache flush
- SGLang's GPU and host caches flushed and checked empty before each KVStash read, so the prefix could only come from KVStash.
- Timing
- Time to first token (TTFT) measured at the client, not inside the engine.
- Runs
- Length sweep: run r20261029-sweep1, 5 distinct prompts per length, median reported. 110k spread: 8 runs on different machines.
Time to first token by prompt length
Recompute grows faster than the prompt; the read grows roughly with the bytes moved. So the gain grows with length, from 5.3x at 8k to 13.7x at 110k.
Figure 1Time to first token, recomputed and read from KVStash
| Prompt | Tokens | Recomputed | Read from KVStash | Faster by |
|---|---|---|---|---|
| 8k | 8,016 | 0.64 s | 0.12 s | 5.3x |
| 32k | 32,016 | 3.38 s | 0.42 s | 8.0x |
| 64k | 64,016 | 9.03 s | 0.85 s | 10.6x |
| 110k | 110,016 | 20.8 s | 1.52 s | 13.7x |
The 110k prompt in 8 separate runs
One fast run would overstate the gain, so we collected every 110k read we made, each on its own Modal machine, and quote the range, not the best. They come from different experiments, not one controlled repeat.
Figure 2Read time for the 110k prompt, one bar per machine
- Fastest
- 1.04 s
- Median (about)
- 1.45 s
- Slowest
- 1.60 s
The spread is machine to machine: the same container read the same prompt at 1.49-1.52 s with 19 GB or 51 GB stored.
- 110,016-token prompt, SGLang 0.5.15.post1, Qwen2.5-7B-Instruct BF16, one L40S per run, 29 Oct 2026.
- 8 separate runs, each on its own Modal machine, taken from different experiments (two profiling runs, a repeat, fill, occupancy, the length sweep and two A/B settings), not 8 controlled repeats.
- Cold recompute ranged 19.3-20.8 s.
Where the time goes in a 110k-token read
A 110k-token prefix is 6.31 GB of KV cache in 3,436 blocks. After a fixed 0.26 s, the read is two copies, one after the other.
Figure 3The three parts of a read from KVStash
Reading the prefix from the NVMe tier
Every number above reads from KVStash's DRAM tier. One run forced a 32k-token prefix to come wholly from the disk tier instead.
Figure 4A 32k-token prefix read from disk
- From disk, 4.7x sooner than recomputing. 28 GB passed through a 4 GiB DRAM arena with 0 misses.
- Container disk is the GPU machine's own virtualised storage. A dedicated NVMe drive is not tested yet.
- With
nvme_admit_min_hitsat 0, blocks went to disk on their first demotion. The default is 1.
Does the output stay the same?
Speed only matters if the answer is right. We compared outputs and broke things on purpose.
Figure 5Correctness and failure checks
- Output matches SGLang's own cache at the same reuse split12 of 12 identical
- Store killed (SIGKILL) during a 512-request load512 of 512 requests completed; SGLang recomputed
- Empty store after a restartRequests served; cache refilled (64 of 64, 75% reuse)
- Partial prefix, request cancellation, store killed mid-read, wrong model identityAll correct
- Bytes flipped in the NVMe tier47 checksum errors caught; no damaged block reached an output
- Cost of checksum verificationAbout 20 ms on a 28k-token prompt
Why we compare at the same reuse split
SGLang runs a request with a cached prefix through a different kernel path than a full recompute, so greedy text can diverge partway with any cache. The fair test is against SGLang's own cache with the same number of reused tokens.
- 12 of 12KVStash vs SGLang's own cache, same split
- 4 of 12SGLang's own cache vs a full recompute
- 4 of 12KVStash vs a full recompute, the same prompts
Method and limits
How each number was taken, and what this study does not show.
Method
- Start SGLang with KVStash as the HiCache storage tier and the KVStash daemon on the same host.
- Send each prompt once with nothing cached and record the client-side time to first token (recomputed).
- Flush SGLang's GPU and host caches through its flush endpoint and check the flush succeeded.
- Send the same prompt again, so the prefix can only come from KVStash. Record time to first token and the tokens read from storage.
- Repeat with 5 distinct prompts per length and report the median.
Limits of this study
- Against recomputing, not against SGLang's own caches: on the same machine a GPU hit took 0.26 s and SGLang's host memory 0.51-0.59 s, against 1.04-1.08 s from KVStash (see where the 12x went).
- One model (7B, BF16), one GPU per server, tensor parallel 1.
- KVStash on the same host over loopback TCP; no network hop between machines.
- DRAM tier for every number except Figure 4 (container disk). The S3 tier was not tested under SGLang.
- Longest prompt 110k tokens; 524k and 1M-token prompts are not measured on this lane.
- Single requests, not serving load. For load, restarts and failures see Study 1b.
- Cloud machines vary: the same software read the 110k prompt in 1.04-1.60 s on different hosts.
Download the data
Generated from the same source as this page. Speed-ups in the spread file are against each run's own recompute time.
Questions about this study
Changelog. 4 November 2026: first published, runs from 29-30 October 2026. 9 November 2026: added SGLang's own GPU and host-memory times next to KVStash, and relabelled the 8 machines as 8 separate runs from different experiments.
How much faster is time to first token on SGLang with KVStash?
It grows with prompt length. On one L40S with default settings, reading the prefix from KVStash was 5.3x at 8k, 8.0x at 32k, 10.6x at 64k, 13.7x at 110k faster than recomputing it. At 110k tokens, 8 runs on different cloud machines gave 13-19x, median about 14x.
Why does the speed-up vary between machines?
The 110k read took 1.04 s to 1.60 s in 8 separate runs, each on its own L40S machine with the same software. The runs come from different experiments (two profiling runs, a repeat, fill, occupancy, the sweep and two A/B settings), so this is a spread across runs, not a controlled repeat. The same container read the same prompt in 1.49-1.52 s with 19 GB or 51 GB stored, so the spread is machine to machine (CPU, memory bandwidth, neighbours), not store size. We quote the range, not the fastest run.
Does reading the KV cache from KVStash change the output?
Not in our tests. Outputs with KVStash matched SGLang's own cache at the same reuse split in 12 of 12 prompts. Both can differ from a fully recomputed answer in some prompts, because SGLang uses a different kernel path when part of the prompt is cached; that is prefix caching in general, not KVStash.
Is the gain still there with a short prompt?
Yes, but smaller. At 8,016 tokens the read was 0.12 s against 0.64 s recomputed. The fixed costs of a request (tokenizing and scheduling) matter more as the prompt gets shorter.
Was the store on another machine?
No. In this study the KVStash daemon ran on the same host as the GPU server and was reached over loopback TCP. A store on a separate machine over a real network is not tested yet under SGLang.
Measure it on your prompts.
Send your engine, model, GPU and typical prompt length. We will tell you what read time to expect and how we would check it.
Or write to rudray@kvstash.com