Design a system to serve Large Language Models (ChatGPT)

    Serving a large language model (ChatGPT) means running a model too big for one GPU, generating tokens autoregressively with low latency, and streaming them to users — while enforcing quotas and safety.

    AI & Machine Learning, 6 components, about 40 min

    The full guide covers requirements, estimates, the API, the data model, deep dives, trade-offs, failure modes and the follow-up questions interviewers ask.

    Read the full guide on Substack

    Key points

    • Model Parallelism: Split model across multiple GPUs (Tensor/Pipeline parallelism).
    • KV Cache: Store intermediate activation states to avoid re-computing previous tokens.
    • Token Streaming: Use Server-Sent Events (SSE) to send text as it is generated.
    • Rate Limiting: Strict token-based quotas per user/API key.
    • Safety Layer: Secondary model (Guardrails) checks prompt/response for violations.

    Sign in to track this guide in your curriculum progress.