LLM profiling in CI/CD: evaluating inference, chip by chip

· Source: LLM on Medium · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Cloud Computing & IT Infrastructure · Depth: Advanced, short

Summary

This article details a hardware-agnostic model profiling harness designed to accurately evaluate LLM inference performance by dissecting the "tokens per second" metric. It highlights that this single figure obscures two distinct phases: prefill, which processes the prompt in one parallel pass and is compute-bound, and decode, which generates tokens autoregressively and is memory-bound due to repeated data movement. The profiling method, utilizing PyTorch and operator-level tracing on an open-weights Granite model, reveals that prompt length primarily impacts Time To First Token (TTFT) during prefill, while inter-token latency (p50 and p95) characterizes decode. Crucially, quantization, like INT8, can improve decode speed but potentially degrade long-prompt prefill performance and even increase peak memory. The analysis emphasizes that user experience is often dictated by p95 latency, not just p50.

Key takeaway

For MLOps Engineers optimizing LLM inference, relying solely on "tokens per second" is insufficient; you must profile prefill and decode phases independently. Instrumenting your models with tools like PyTorch's profiler to track Time To First Token (TTFT) and inter-token latency (p50/p95) will reveal true bottlenecks, especially regarding memory traffic during decode. This granular insight allows you to make informed hardware and quantization decisions, ensuring user-perceived performance (p95) is prioritized over misleading averages.

Key insights

LLM inference performance is split between compute-bound prefill and memory-bound decode, requiring distinct profiling.

Principles

Method

Run inference as two explicit phases (prefill/decode). Use PyTorch, operator-level tracing, and Perfetto for span duration queries. The method is hardware-agnostic.

In practice

Topics

Best for: Machine Learning Engineer, AI Engineer, MLOps Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by LLM on Medium.