Introduction
As Large Language Models (LLMs) evolve, their application has shifted from simple single-turn interactions to complex, multi-agent workflows. Modern systems often employ strategies like "Tree of Thoughts" (ToT) or multi-round debates between specialized AI agents to solve difficult reasoning tasks. While these methods significantly improve output quality, they introduce a substantial computational overhead. In a typical multi-agent setup, every new contribution requires the system to re-encode the entire preceding conversation, leading to redundant processing of static data and increased latency.
Researchers from Johns Hopkins University have addressed this bottleneck with a new framework called Prompt Choreography. By reimagining LLM memory as a shared global cache rather than a series of isolated, stateless events, they have achieved latency reductions of up to 6x.
The Problem: Stateless Serving in a Stateful World
Standard LLM serving is inherently stateless. Each request triggers a "prefill" phase where the model encodes input tokens into Key-Value (KV) representations. In iterative workflows—where Agent A generates a thought, Agent B critiques it, and Agent C summarizes the exchange—the same messages are re-encoded multiple times.
Existing optimizations like Prefix Caching offer some relief for static prompts but fail in dynamic environments where message order changes or where agents need to access non-contiguous parts of a conversation. This leads to two primary issues:
- Redundant Computation: The repeated encoding of identical text strings wastes GPU cycles.
- Contextual Mismatch: Simply concatenating pre-encoded blocks (e.g., placing Message B after Message A) can degrade model performance because the original encodings lack the cross-attention context of the new sequence.
The Prompt Choreography Framework
Prompt Choreography introduces a "shared memory" architecture for LLM agents. Instead of treating each generation as a fresh start, the framework maintains a persistent, dynamic global KV cache.
The framework is built on several key technical innovations:
- Global KV Cache: A centralized repository for message encodings accessible by all agents in a workflow.
- Choreography API: The traditional
generate()function is decoupled intoprefill(encoding and caching) anddecode(generating tokens based on selected cached messages). - Virtual Position Updates: Utilizing Rotary Positional Embeddings (RoPE), the system can mathematically "rotate" cached encodings to reflect their new logical positions in a prompt without requiring re-encoding.
- Dynamic Masking: By leveraging "FlexAttention," the framework creates custom attention masks that ensure agents only "see" the specific subset of messages relevant to their current task, preventing information leakage.
- PEFT-based Distillation: To overcome contextual mismatch, the authors use Parameter-Efficient Fine-Tuning (LoRA). By training on "gold" outputs from standard full-context models, the choreographed model learns to interpret out-of-order cached encodings with high accuracy.
Experimental Evaluation
The researchers tested Prompt Choreography across several benchmarks designed to simulate real-world complexity:
- MATH: Competition-level math problems requiring multi-step reasoning.
- TriviaQA: A "MultiQA" task testing the model's ability to process multiple independent queries simultaneously.
- CommonGen: A "Branch-Solve-Merge" task where story components are generated in parallel and then synthesized.
- Prisoner’s Dilemma: A simulation used to detect "Information Leakage" between agents with private and public contexts.
Key Results and Insights
The implementation of Prompt Choreography yielded significant performance gains:
- Latency Reduction: The framework achieved a 2.0× to 6.2× improvement in Time-to-First-Token (TTFT). In prefill-heavy workflows, end-to-end speedups exceeded 2.2×.
- Accuracy Recovery: While naive caching initially caused accuracy to drop, LoRA fine-tuning successfully restored performance to levels nearly matching the baseline, demonstrating that models can be taught to handle "choreographed" context.
- Parallelism: The global cache enables the system to interleave the decoding of multiple agent responses in GPU memory, maximizing hardware utilization.
Conclusion
Prompt Choreography marks a transition from viewing LLMs as stateless functions to treating them as stateful, memory-aware processors. By optimizing how context is stored and reused, this framework paves the way for more efficient and scalable multi-agent AI systems.
Summary updated