Measure RadixAttention cache hits on a T4
Colab T4 · freenotebook90 minrequiredGoal · An SGLang server for Qwen2.5-0.5B-Instruct with a measured TTFT difference between unique prompts and prompts sharing a 600-token system prompt.
- 1In Colab run pip install "sglang[all]" openai and launch python -m sglang.launch_server --model-path Qwen/Qwen2.5-0.5B-Instruct --dtype half --port 30000 in the background.
- 2Confirm the server is up with curl http://localhost:30000/health and read the startup log for the KV pool size.
- 3Build 40 prompts with a shared 600-token system prompt and distinct short questions, and 40 prompts with 600 unique random tokens each.
- 4Send each set sequentially with stream=True and record TTFT (time to first content chunk) per request.
- 5Read the server log lines for cached tokens per request (or GET /metrics) and compute the hit rate for each set.
- 6Plot TTFT distributions for both sets and compute the ratio of medians.
- 7Repeat the shared-prefix set with --disable-radix-cache and record the difference.
- Deliverable
- A notebook with the two TTFT distributions, the hit-rate numbers and the radix-disabled comparison.
- Check
- Median TTFT for the shared-prefix set is at least 30 percent lower than for unique prompts, and the gap disappears with --disable-radix-cache.
- Fallback
- Run the same TTFT experiment against the toy CPU server from p3-llm-serving-architecture-l1 after adding a dict-based prefix cache of past_key_values keyed by prompt prefix.