WhoBuilt

Mastering LLM Inference Optimization From Theory to Cost Effective Deployment

Jan 1, 2025· 34 min· 76K views·Watch on YouTube

Speaker

Mark Moyou, an architect at NVIDIA who works with retail clients, explains LLM inference performance and deployment costs at the AI Engineer conference.

How prompts become GPU work

Moyou walks through tokenization, prompt processing, and generation, which produces one token at a time. He explains that attention relates tokens to one another and that GPUs handle the matrix calculations used to represent them.

KV cache and GPU memory

The model creates query, key, and value matrices that help it interpret the prompt; the key and value matrices serve as memory. A KV cache lets the model process each new token against prior context without recomputing the whole prompt. As an example, Moyou estimates that an 8B model in FP16 uses about 16 GB, leaving roughly 4 GB on a 20 GB L4 for the cache.

Measure real request patterns

Moyou recommends tracking time to first token, time between tokens, total generation time, and input and output sequence lengths. He highlights four request patterns, including long input with short output and short input with long output, and says long inputs and outputs can fill GPU memory and limit concurrent requests. Histograms and latency plots can help teams size engines around the traffic they actually serve.

Optimize and deploy inference engines

Moyou describes Triton as a server for hosting models and TensorRT-LLM as NVIDIA's compilation package for LLM inference on its GPUs. He points to FP8 as a way to reduce model memory use by roughly half compared with FP16, and discusses in-flight batching, KV-cache quantization, and paged KV cache. He says engines are built for specific GPUs, and suggests measuring whether configurations tuned to different traffic patterns can lower cost or latency.

Takeaways

  • Measure the input and output lengths users actually send before sizing an inference engine.
  • Track time to first token, inter-token latency, and completion time under production load.
  • Long prompts and long generations both consume GPU memory and can reduce the number of concurrent requests.
  • A KV cache avoids recomputing attention for the full prompt after each new token, but its memory use affects capacity.
  • Evaluate reduced precision and cache optimizations against both model accuracy and deployment cost.

Mentioned in this talk

Search inside this talk

What was claimed 12

  • works at
    architect
    “I work at NVIDIA.”
    YouTube
    Verified3 sources· Talk, Web· archived
  • metric
    LLM inference: Generation typically produces one token at a time
    “it's typically one token generated at a time”
    YouTube
    Unverified1 source· Talk
  • feature
    GenPerf: Generates inference performance plots
    “It will generate these plots for you”
    YouTube
    Unverified1 source· Talk
  • feature
    NVIDIA Inference Microservices: Enterprise offering for building, deploying, and optimizing inference engines
    “Building these engines, deploying them, and optimizing them at scale isn't easy, so we've made that easier as an enterprise offering.”
    YouTube
    Unverified1 source· Talk
  • feature
    Triton: Open-source inference server for deploying models on CPU or GPU
    “Triton is an open-source inference server, so you can deploy models on CPU or GPU”
    YouTube
    Unverified1 source· Talk
  • metric
    FP8: Going from FP16 to FP8 cuts memory use roughly in half, with almost the same accuracy
    “going from FP16 to FP8 cuts my memory use roughly in half, with almost the same accuracy”
    YouTube
    Unverified1 source· Talk
  • feature
    TensorRT-LLM: Model compilation package for LLMs on NVIDIA GPUs
    “this is the model compilation package for LLMs on NVIDIA GPUs”
    YouTube
    Unverified1 source· Talk
  • feature
    in-flight batching: Allows a new request to be injected as soon as another request finishes
    “The moment your request finishes, I can inject a new request while others...”
    YouTube
    Unverified1 source· Talk
Show all 12 facts

Related talks