GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
arXiv preprint

Parrot: Efficient Serving of LLM-based Applications with Semantic Variable

LLM APIs see single requests, not the agent workflow behind them. Parrot has apps mark prompt inputs and outputs as variables, so the service chains, batches and shares work: up to 11.7x faster.

Breakdown by FDE Interviews · 11 min read · Updated

About the original · 2024
AUTHORS
Lin, Han, Zhang, Yang, Yang, Chen, Qiu
FROM
Shanghai Jiao Tong University, Microsoft Research
PUBLISHED
May 2024 · arXiv preprint
CITED BY
169Semantic Scholar · Oct 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 20% of this breakdown.

01

The paper in one minute

LLM applications rarely make one call. A document summarizer maps over chunks and reduces; a chat search rewrites the query, retrieves, checks safety and answers; a multi-agent coder runs architect, coders and reviewers in rounds. Each step is a separate completion request to a public LLM service, which knows nothing about how they connect.

The authors identify three costs of that blindness. Round trips: for dependent steps the client must receive one output, build the next prompt and send it, paying network latency and a fresh place in the queue each time; in one production chain application, 30% to 50% of call latency was outside the GPU. Wrong objectives: the service minimizes each request's latency, but a map stage should be batched for throughput because only the final answer's latency matters. Missed sharing: long system prompts and growing conversation histories repeat across requests (94% of tokens in a production chat search), but finding shared prefixes by token matching across a cluster is too expensive.

Parrot adds one abstraction. A Semantic Variable is a marked region of a prompt template, an input or an output, such as input:task or output:code (written between double braces in Parrot's templates). Applications submit all their templated requests up front and fetch final outputs with a goal (latency or throughput). From the variables the service builds a request graph and can: run dependent requests itself as soon as inputs are ready; deduce objectives, marking parallel steps that feed a latency-critical output as a task group to batch together; and hash prompts at variable boundaries to find shared prefixes, co-locate those requests and use a kernel that reads the shared KV once.

With LLaMA 7B and 13B against vLLM-based baselines, Parrot was 11.7x faster on a MetaGPT coding workflow, sustained 12x the request rate for four apps sharing prompts, and was 2.37x faster on map-reduce summaries.

THE IDEA, VISUALLY
SEMANTIC VARIABLES (SECTION 4) @SemanticFunction def WritePythonCode(task): """Write python code of {{input:task}}. Code: {{output:code}}""" def WriteTestCode(task, code): """Test {{input:task}} given {{input:code}}: {{output:test}}""" code.get(perf=LATENCY); test.get(perf=LATENCY) The service sees the graph, not just isolated prompts: WritePythonCode code WriteTestCode test → client THREE OPTIMIZATIONS IT ENABLES (SECTION 5) chain on the server the next request runs as soon as its input exists: no client round trip, no re-queueing deduce the goal parallel steps feeding a latency goal form a task group, batched for throughput as a whole share prefixes hash the prompt at variable boundaries to find shared text; co-locate those requests, read shared KV once Native code and control flow still run on the client, by design SPEEDUP OVER VLLM-BASED BASELINES (SECTION 8) MetaGPT coding vs latency-tuned 11.7x GPTs apps, request rate 12.0x MetaGPT vs throughput-tuned 2.45x chain summary + background load 2.38x map-reduce summary 2.37x Bing Copilot prompt vs no sharing 2.4x chain summary alone 1.38x LLaMA 7B and 13B on one A100 or four A6000s; baselines are vLLM (and HuggingFace) behind a request-level API. Each request got 200-300 ms of emulated network delay. WHERE THE TIME GOES (TABLE 1, FIGURE 3) 30-50% of a production chain app's call latency was outside the GPU (over 70% at worst) repeated prompt text: chat search 94%, MetaGPT 72%, AutoGen 99%, long-document analytics 3% Bing Copilot-like prompt: ~6,000-token system prompt
A completion API sees one prompt at a time. Parrot's Semantic Variables expose how an application's prompts connect, so the service can run the next step itself, batch a parallel stage as one group and find shared prompt text.
Research notes: the problem, approach and results
11.7x

faster multi-agent coding workflow (MetaGPT) than a latency-tuned vLLM baseline; 2.45x against a throughput-tuned one

94%

of prompt text repeated across requests in a production LLM chat-search application

30-50%

of a production chain application's call latency spent outside the GPU, in network and queueing

THE PROBLEM

LLM applications such as agents, chained summaries and map-reduce analytics make many calls per task, but a completion API sees each call alone. The client must wait for each result, rebuild the next prompt and queue again; the service optimizes each call's latency even when the application only cares about the last one; and shared prompt text goes undetected across thousands of requests.

THE IDEA

Let applications write prompts as templates whose placeholders are Semantic Variables, marked as inputs or outputs, and state the performance goal for final outputs. The service builds a request graph from the variables, executes dependent requests itself, deduces which parallel steps can trade latency for throughput, hashes prompts at variable boundaries to find shared prefixes, and schedules with all three in mind.

THE RESULT

On LLaMA 7B and 13B with vLLM-based baselines, Parrot sped up a MetaGPT coding workflow 11.7x (2.45x against a throughput-tuned baseline), sustained 12x the request rate for four apps with shared prompts, and ran map-reduce summaries 2.37x faster.

02

Why it matters to an FDE

Customers building agents often see slow end-to-end times and blame the model. Parrot's measurements say much of the time can sit between calls: client round trips, re-queuing behind other tenants and per-request scheduling that ignores the workflow.

Measure time outside the model first. Log, per workflow, the time each step spends waiting to be sent, in transit and in the provider's queue. If it's a large share, moving orchestration next to the model or batching steps helps more than a faster model.

Self-hosted stacks can exploit the workflow. With an open model on your own engine, you control the API: submit a whole stage at once, keep dependent steps server-side and group parallel calls. Prefix-sharing engines (SGLang, vLLM's prefix caching) do part of this already.

Templates matter for caching. Prompt structure (static role, quasi-static examples, dynamic input) decides how much KV can be shared. Putting the stable parts first and keeping them byte-identical lets any prefix cache work.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 149 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    The abstraction, the optimizations, what drove each result and three misreadings

    Free account
  2. 04How it works

    The API, graph analysis, objective deduction, prefix hashing and the scheduler

    Premium
  3. 05The numbers that matter

    Setup, document analytics, popular apps, multi-agent and mixed workloads

    Premium
  4. 06Try it yourself

    Recheck the paper's figures, model chaining, map-reduce capacity and shared-prefix memory

    Premium
  5. 07Where it breaks

    Requires a new API, client-side code, emulated networks, small models, and slips

    Premium
  6. 08Using it on a deployment

    Measuring orchestration overhead, restructuring calls, and choosing a serving stack for agents

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →