Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Chi Wang, Peiheng Hu

Rating No ratings yet

Large language models (LLMs) are rapidly becoming the backbone of AI-driven applications. Without proper optimization, however, LLMs can be expensive to run, slow to serve, and prone to performance bottlenecks. As the demand for real-time AI applications grows, along comes this comprehensive guide to the complexities of deploying and optimizing LLMs at scale. Authors Chi Wang and Peiheng Hu take a real-world approach backed by practical examples and code, and assemble essential strategies for designing infrastructures that are equal to the demands of modern AI applications. Learn the key principles for designing a model-serving system and how to build a system that meets specific business requirements.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical, code-backed guide to deploying and optimizing large language models in production, aimed at engineers who must turn an LLM prototype into a reliable, cost-efficient service. If you own an LLM endpoint and need to reason about latency, throughput, and GPU spend, this book is your systems companion. 【Book Arc】 - **Opening (~0%–10%)**: Frames why LLM serving is its own discipline—autoregressive, stateful, prefill/decode phases, dominant inference cost—and why classic ML deployment thinking breaks down. - **Early (~10%–30%)**: Defines the audience, prerequisites, and scope; walks through model anatomy (data, architecture, execution code) and the ML lifecycle from training to serving. - **Middle (~30%–55%)**: Explains LLM execution mechanics (attention, prefill, decoding), core serving metrics, and how to design single-model and multi-model serving systems from scratch. - **Late (~55%–80%)**: Moves into best practices and optimization—agent and RAG pipelines, enterprise architectures, buy vs. self-host decisions, then continuous batching, quantization, kernel fusion, and prefix caching. - **Ending (~80%–100%)**: Covers advanced techniques (speculative decoding, multi-GPU parallelization, prefill-decode disaggregation, KV cache management) and surveys frameworks like vLLM, TensorRT-LLM, SGLang, and llama. 【Key Takeaways】 - **LLMs are not just bigger ML models** (Opening): Their stateful, autoregressive nature and split prefill/decode phases create new physics, economics, and stakes that demand dedicated serving strategies. - **Serving is the product experience, not backstage infrastructure** (Opening): Because LLMs sit inside interactive UX, latency is visible, streaming is mandatory, and reliability directly drives trust and revenue. - **Inference cost dominates** (Opening): GPU memory and scheduling efficiency translate directly into dollars, making optimization a business concern, not just an engineering one. - **Models are executable programs, not static data** (Middle): Treating a model as architecture + execution code + data clarifies packaging, versioning, and deployment decisions. - **Serving sits late in the ML lifecycle but determines realized value** (Middle): Training only pays off once a model is deployed, served reliably, and operated at scale. - **Optimization has a layered toolkit** (Late): Continuous batching, quantization, kernel fusion, and prefix caching are broadly applicable; speculative decoding, multi-GPU parallelism, and prefill-decode disaggregation are advanced levers. - **Framework choice matters** (Ending): vLLM, TensorRT-LLM, SGLang, and llama each embody different trade-offs; understanding why specialized frameworks exist guides selection. - **Buy vs. self-host is a first-class decision** (Late): Public APIs, cloud endpoints, serving libraries, and self-managed services each carry distinct cost, safety, and control implications. 【Reading Tips】 - **Deep-read Chapters 2–3 and 6–7**: Execution mechanics, system design, and optimization techniques are the book's core; skim the intro chapters if you already know the LLM landscape. - **Run the code**: The hands-on value comes from experimenting with batch sizes, model sizes, sequence lengths, and schedules—then measuring the differences yourself. - **Pair with a general LLM text**: If transformers or attention are unfamiliar, read a foundational book alongside this one and treat this as your serving companion. - **Focus on trade-offs, not recipes**: The durable skill is reasoning about latency, throughput, and cost under changing workloads and evolving frameworks. - **Use the framework survey as a map, not a verdict**: Chapter 8 helps you evaluate options; expect the landscape to shift and revisit your choices. 【Coverage Limits】 This guide is based on stratified excerpts covering the front matter, introduction, and early-to-middle chapters; later chapters on advanced optimization and framework surveys are summarized from the book's own chapter outline rather than detailed excerpt content.
Excerpt 1
m/catalog/errata.csp?isbn=9798341621497 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Hands-On LLM Serving and Opt...
View in text
Excerpt 2
enough to connect it to serving and optimization decisions. If you’re new to machine learning or transformers, we encourage you to pair this book with a more...
View in text
Excerpt 3
cal) 707-829-0104 (fax) support@oreilly.com https://oreilly.com/about/contact.html We have a web page for this book, where we list errata, examples, and any...
View in text
Excerpt 4
)) x = self . pool ( F . relu ( self . conv2 ( x ))) x = x . view ( - 1 , 16 * 5 * 5 ) x = F . relu ( self . fc1 ( x )) x = F . relu ( self . fc2 ( x )) x =...
View in text
Excerpt 5
ur specific business use cases and performance requirements. Cloud vendors design their model serving solutions based on various customer needs and package t...
View in text
Excerpt 6
companies with slower or more expensive inference solutions. In the next section, we’ll look at an example to help you get a feeling for why an optimized mod...
View in text
Excerpt 7
ng and intuition needed to reason about LLM serving systems. You’ll gain clarity on their behavior, limitations, and optimization opportunities—laying the gr...
View in text
Excerpt 8
Transformer performs text generation given an input prompt. 1 A defining characteristic of LLMs is their autoregressive nature: they generate text one token...
View in text
Tags
AI categories
Artificial IntelligenceCloud NativeSoftware
Publisher: O'Reilly Media
Publish Year: 2026
Language: English
File Format: EPUB
File Size: 10.8 MB