SGLang
Instrumenting your SGLang application with Parea AI
SGLang from LMSYS is “a Structured Generation Language designed for LLMs”. Its main benefits is that it allows to structure complex LLM programs with multiple chained generation calls,control flow, multiple modalities, parallelism, and external interaction using plain Python. Additionally, one can take improve performance of local LLMs with its RadixAttention mechanism for automatic KV cache reuse across multiple calls.
Quickstart
First, create a Parea API key as shown here.
Second, call integrate_with_sglang()
on the Parea client to automatically instrument any OpenAI calls made through SGLang.
Finally, define a function like run_and_trace
to automatically log the outputs of the SGLang program to Parea and create a trace which associates all LLM calls together.
The following code snippet demonstrates a simple multi-turn question-answering program that logs the outputs of the LLM calls to Parea.
Visualization of the Trace
This will produce the following trace:
Was this page helpful?