{
  "study": "study-1",
  "title": "SGLang + KVStash serving study",
  "dates": "29-30 October 2026",
  "published": "2026-11-04",
  "source": "https://kvstash.com/benchmarks/",
  "setup": {
    "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)",
    "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",
    "method": "Cold = the whole prompt recomputed. KVStash = the server's GPU and host caches flushed and verified empty, so the prefix can only come from KVStash. Time to first token (TTFT) measured at the client."
  },
  "units": {
    "ttft": "seconds, measured at the client",
    "throughput": "input tokens per second",
    "reused": "percent of prompt tokens"
  },
  "prompt_length_sweep": {
    "caption": "SGLang 0.5.15.post1, Qwen2.5-7B-Instruct BF16, one L40S, KVStash on the same host, default settings, median of 5 reads per point after a verified cache flush. Run r20261029-sweep1, 29 Oct 2026.",
    "rows": [
      {
        "tokens": 8016,
        "label": "8k",
        "cold": 0.64,
        "kvstash": 0.12,
        "speedup": 5.3
      },
      {
        "tokens": 32016,
        "label": "32k",
        "cold": 3.38,
        "kvstash": 0.42,
        "speedup": 8
      },
      {
        "tokens": 64016,
        "label": "64k",
        "cold": 9.03,
        "kvstash": 0.85,
        "speedup": 10.6
      },
      {
        "tokens": 110016,
        "label": "110k",
        "cold": 20.8,
        "kvstash": 1.52,
        "speedup": 13.7
      }
    ]
  },
  "spread_110k": {
    "caption": "110,016-token prompt, SGLang 0.5.15.post1, Qwen2.5-7B-Instruct BF16, one L40S per run, 8 runs on different Modal machines, 29 Oct 2026. Cold recompute ranged 19.3-20.8 s. Median read about 1.45 s (about 14x). 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.",
    "rows": [
      {
        "run": "profile4",
        "read": 1.045,
        "speedup": 18.7
      },
      {
        "run": "profile3",
        "read": 1.08,
        "speedup": 18
      },
      {
        "run": "repeat1",
        "read": 1.12,
        "speedup": 18
      },
      {
        "run": "fill1",
        "read": 1.41,
        "speedup": 14.5
      },
      {
        "run": "occ1",
        "read": 1.5,
        "speedup": 13.5
      },
      {
        "run": "sweep1",
        "read": 1.52,
        "speedup": 13.7
      },
      {
        "run": "ab-default",
        "read": 1.56,
        "speedup": 13.1
      },
      {
        "run": "ab-big",
        "read": 1.6,
        "speedup": 12.9
      }
    ]
  },
  "where_the_time_goes_110k": {
    "bytes": "6.31 GB",
    "blocks": "3,436",
    "fixed": 0.26,
    "explanation": "A 110k-token prefix is 6.31 GB of KV cache in 3,436 blocks. The read costs a fixed 0.26 s (tokenizing the text prompt and scheduling, also paid by a GPU cache hit), plus the transfer from KVStash into SGLang's host memory, plus the copy from host memory to the GPU. SGLang does the last two one after the other; overlapping them is the next large gain and needs an SGLang change."
  },
  "nvme_tier": {
    "text": "A 32k-token prefix read wholly from the NVMe tier in 0.77 s, against 3.6 s to recompute (4.7x); 0.42 s from DRAM. 28 GB passed through a 4 GiB DRAM arena with 0 misses.",
    "caption": "Modal GPU container disk (not a dedicated NVMe drive), SGLang 0.5.15.post1, Qwen2.5-7B BF16, nvme_admit_min_hits set to 0, 30 Oct 2026 (run r20261030-tier1)."
  },
  "correctness": [
    {
      "check": "Output matches SGLang's own cache at the same reuse split",
      "result": "12/12 identical",
      "run": "r20261029-parity1"
    },
    {
      "check": "Store killed (SIGKILL) during a 512-request load",
      "result": "512/512 requests completed; SGLang recomputed",
      "run": "load test"
    },
    {
      "check": "Empty store after a restart",
      "result": "requests served; cache refilled (64/64, 75% reuse)",
      "run": "load test"
    },
    {
      "check": "Partial prefix, request cancellation, store killed mid-read, wrong model identity",
      "result": "all correct",
      "run": "r20261029-correct1"
    },
    {
      "check": "Bytes flipped in the NVMe tier",
      "result": "47 checksum errors caught; no damaged block reached an output",
      "run": "r20261029-correct1"
    },
    {
      "check": "Cost of checksum verification",
      "result": "about 20 ms on a 28k-token prompt",
      "run": "r20261029-correct1"
    }
  ],
  "load_l40s": {
    "caption": "SGLang bench_serving, generated shared-prefix workload: 8k-token prefixes, 128 groups x 4 questions, 512 requests per pass. One L40S, Qwen2.5-7B-Instruct BF16, SGLang host-memory pool 48 GB, KVStash response budget raised, store on the same host. SGLang cache = GPU radix cache + host-memory HiCache. One pass per row, 29 Oct 2026. KVStash: 0 misses, 0 aborts in every pass.",
    "rows": [
      {
        "pass": "First pass, concurrency 16",
        "mode": "SGLang cache",
        "mean": 3.17,
        "p50": 2.99,
        "p99": 8.99,
        "tps": 20033,
        "reused": 54
      },
      {
        "pass": "First pass, concurrency 16",
        "mode": "SGLang cache + KVStash",
        "mean": 1.88,
        "p50": 0.99,
        "p99": 9.05,
        "tps": 28818,
        "reused": 74
      },
      {
        "pass": "Second pass, concurrency 4",
        "mode": "SGLang cache",
        "mean": 0.78,
        "p50": 0.8,
        "p99": 2.18,
        "tps": 14449,
        "reused": 61
      },
      {
        "pass": "Second pass, concurrency 4",
        "mode": "SGLang cache + KVStash",
        "mean": 0.13,
        "p50": 0.12,
        "p99": 0.24,
        "tps": 23638,
        "reused": 99
      },
      {
        "pass": "After a server restart, concurrency 16",
        "mode": "SGLang cache",
        "mean": 3.08,
        "p50": 2.94,
        "p99": 9.02,
        "tps": 19939,
        "reused": 54
      },
      {
        "pass": "After a server restart, concurrency 16",
        "mode": "SGLang cache + KVStash",
        "mean": 0.34,
        "p50": 0.32,
        "p99": 0.8,
        "tps": 60835,
        "reused": 99
      }
    ]
  },
  "load_default_settings": {
    "result": "Default settings: mean TTFT 1.9 s to 0.5 s, p99 8.3 s to 1.2 s, 3.1x requests per second, 98.5% of prompt tokens cached, 0 connection errors",
    "setup": "One L40S, SGLang 0.5.15.post1, Qwen2.5-7B-Instruct BF16, 8k-token shared prefixes, 32 groups x 4 questions, concurrency 16, two passes. KVStash daemon and SGLang adapter on default settings (no raised budgets), store on the same host. Run r20261029-correct1, 29 Oct 2026.",
    "run": "r20261029-correct1"
  },
  "load_h100": {
    "caption": "One H100 80 GB, 30k-token shared prefixes, 96 requests per pass, host pool 48 GB, 29 Oct 2026. The 1,010 KVStash misses after the restart were capacity evictions (85 GiB arena, 77 GiB of prefixes), not errors; a larger arena removes them.",
    "rows": [
      {
        "pass": "First pass, concurrency 16",
        "mode": "SGLang cache",
        "mean": 6.77,
        "p50": 6.68,
        "p99": 12.91,
        "tps": 39865,
        "reused": 30
      },
      {
        "pass": "First pass, concurrency 16",
        "mode": "SGLang cache + KVStash",
        "mean": 5.16,
        "p50": 3.45,
        "p99": 12.66,
        "tps": 49662,
        "reused": 50
      },
      {
        "pass": "Second pass, concurrency 4",
        "mode": "SGLang cache",
        "mean": 1.27,
        "p50": 1.18,
        "p99": 3.21,
        "tps": 37882,
        "reused": 35
      },
      {
        "pass": "Second pass, concurrency 4",
        "mode": "SGLang cache + KVStash",
        "mean": 0.54,
        "p50": 0.51,
        "p99": 1.35,
        "tps": 101525,
        "reused": 95
      },
      {
        "pass": "After a server restart, concurrency 16",
        "mode": "SGLang cache",
        "mean": 6.35,
        "p50": 6.44,
        "p99": 12.54,
        "tps": 40032,
        "reused": 30
      },
      {
        "pass": "After a server restart, concurrency 16",
        "mode": "SGLang cache + KVStash",
        "mean": 2.53,
        "p50": 2.25,
        "p99": 4.66,
        "tps": 93626,
        "reused": 81
      }
    ]
  },
  "shared_two_servers": {
    "rows": [
      {
        "mode": "SGLang cache only",
        "mean": 2.5,
        "p50": 2.44,
        "p99": 4.08,
        "tps": 40725,
        "reused": 34
      },
      {
        "mode": "SGLang cache + KVStash",
        "mean": 1.65,
        "p50": 1.62,
        "p99": 3.12,
        "tps": 58768,
        "reused": 73
      }
    ],
    "caption": "Server A computes 128 prompts with 8k-token shared prefixes; server B (separate process and GPU memory) then receives the same prompts. Server B shown. One H100, KVStash on the same host, 29 Oct 2026. Without a shared store, B cannot use what A computed."
  },
  "shared_three_servers": "Three SGLang servers on one H100 sharing one KVStash: the two servers reading what the first computed got 1.8-1.9x requests per second and 4x lower p99 TTFT, 98.5% of prompt tokens cached, 0 errors. With too little store memory they fell back to normal speed without errors (run r20261029-shared3b).",
  "not_tested": [
    "S3 tier under SGLang",
    "Store on a separate machine over a real network",
    "Tensor parallel greater than 1",
    "524k and 1M token prompts on the SGLang lane",
    "A dedicated NVMe drive (the NVMe result used GPU container disk)"
  ]
}
