atlas

Research map / Large language models / Agents, code and math

SGLang: Efficient Execution of Structured Language Model Programs

NeurIPS 2024 · Large language models › Agents, code and math · approach: Execution-based code verification · 109 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Introduces SGLang, a Python-embedded language and runtime for structured LM programs that speeds execution via RadixAttention KV cache reuse, compressed FSM constrained decoding, and API speculative execution.

Problem

LM programs with multiple dependent generation calls, control flow, and structured outputs are hard to program and execute inefficiently, since existing inference engines discard KV cache across calls and decode constrained outputs one token at a time.

Approach

Treats the KV cache as an LRU cache organized in a radix tree so that prefixes are automatically shared across calls and forks, schedules requests by longest shared prefix, compresses singular-transition FSM edges to decode multiple tokens per step, and co-designs a frontend language with the runtime.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
add RadixAttention KV-cache reuseSGLang · llava-bench-in-the-wildthroughput: 0.18 image/s -> 1.15 image/sHelped
add RadixAttention KV-cache reuseSGLang · ActivityNetthroughput: 0.02 frame/s -> 0.10 frame/sHelped
use SGLang runtime optimizationsLM program workloads · Various LM program workloadsthroughput: up to 6.4×Helped
use SGLang runtime optimizationsLM program workloads · Various LM program workloadslatency: reduces latency by up to 3.7×Helped
add a compressed finite state machine for constrained decodingJSON decoding · JSON decoding benchmarkthroughput: +1.6× throughputHelped
redo FSM preprocessing for each request instead of reusing the preprocessed state machine for a batch (ablation)Compressed finite state machine · JSON decoding benchmarkthroughput: 2.4× lowerHurt
remove KV-cache reuse (ablation)RadixAttention · Representative RadixAttention benchmarksperformanceHurt
replace the radix tree with a simple table-based cache (ablation)RadixAttention · Representative RadixAttention benchmarksperformanceHurt
replace cache-aware scheduling with FCFS scheduling (ablation)RadixAttention · Representative RadixAttention benchmarksperformanceHurt
replace cache-aware scheduling with random scheduling (ablation)RadixAttention · Representative RadixAttention benchmarksperformanceHurt
remove frontend interpreter parallelism (ablation)SGLang · Representative RadixAttention benchmarksruntime performanceHurt
remove frontend fork hints (ablation)SGLang · Representative RadixAttention benchmarksruntime performanceHurt

Surprising findings

Limitations

Experimental setup

Datasets: MMLU HellaSwag GSM-8K llava-bench-in-the-wild ActivityNet ShareGPT

Benchmarks: MMLU HellaSwag ReAct agent traces generative agents traces GSM-8K tree-of-thought skeleton-of-thought tip generation JSON decoding multi-turn chat DSPy RAG llava-bench-in-the-wild ActivityNet

Metrics: throughput (programs per second) latency cache hit rate images/s and frames/s

Baselines: Guidance vLLM LMQL

Builds on: vLLM PagedAttention continuous batching Guidance LMQL

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy