When an LLM processes a prompt, it computes a Key and Value vector for every token — the KV cache. If many requests share the same system prompt, recomputing its KV cache from scratch each time is wasteful. Radix Cache stores these computed prefixes in a Radix Tree and reuses them across requests, which is one of the main reasons SGLang achieves high throughput.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Parser where | |
| newtype Parser a = P { parse :: String -> [(a, String)] } | |
| instance Functor Parser where | |
| fmap g p = P (\inp -> case parse p inp of | |
| [] -> [] | |
| [(v, out)] -> [(g v, out)]) | |
| instance Applicative Parser where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Parser where | |
| newtype Parser a = P { parse :: String -> [(a, String)] } | |
| instance Functor Parser where | |
| fmap g p = P (\inp -> case parse p inp of | |
| [] -> [] | |
| [(v, out)] -> [(g v, out)]) | |
| instance Applicative Parser where |