Leanpub Header

Skip to main content

Practical LLM Inference

Quantization, GGUF and Local Models

Practical LLM Inference
This book is 100% completeLast updated on 2026-08-20

Running LLMs locally is easy. Running them well is an engineering problem. Practical LLM Inference gets into the details that matter, from quantization and GGUF internals to GPU offloading, benchmarking and production deployment. Learn how to size hardware, find bottlenecks and build fast, reliable inference systems without the AI hand-waving.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
169
Pages
About

About

About the Book

This book teaches systems engineers how large language model inference actually works on real hardware, from transformer mechanics and quantization mathematics through GGUF internals and llama.cpp deployment to production-grade local inference services. You will learn to calculate exact memory requirements, diagnose performance bottlenecks systematically, configure GPU offloading correctly, benchmark rigorously, and build reliable multi-user inference systems that run efficiently on commodity CPUs and GPUs. No hand-waving about AI magic, just the engineering details that matter when you are responsible for making it work.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

Quantization, GGUF and Local Models

Introduction: The Local Inference Stack

  1. Why Engineers Care About Local Inference
  2. What This Book Will Not Teach You
  3. The Real Bottleneck: Memory Bandwidth, Not Compute
  4. How to Read This Book

Chapter 1: Transformer Inference Fundamentals

  1. From Training to Inference: What Changes
  2. The Forward Pass Anatomy
  3. Self-Attention and Its Costs
  4. Why Autoregression Matters
  5. Arithmetic Intensity and Compute Density

Chapter 2: Tokenization, Prefill, and Decode

  1. How Tokenizers Actually Work
  2. The Prefill Phase: Parallel Computation
  3. The Decode Phase: Sequential Bottleneck
  4. Context Length and Its Real Cost
  5. Why These Phases Demand Different Optimizations

Chapter 3: Model Weights, Formats, and GGUF Architecture

  1. From Checkpoints to Inference: Weight Formats
  2. The GGML Story and Design Goals
  3. GGUF Header Structure and Metadata
  4. Tensor Storage Layout and Quantization Types
  5. Reading a GGUF File: A Practical Walkthrough

Chapter 4: Quantization: Mathematics, Methods, and Tradeoffs

  1. Why Quantization Works on Transformers
  2. Symmetric vs Asymmetric Quantization
  3. Per-Tensor, Per-Channel, Per-Group Schemes
  4. GGUF Quantization Types Decoded
  5. Measuring Quality Loss: Benchmarks and Perception
  6. Choosing a Quant Level for Your Use Case

Chapter 5: Memory, Bandwidth, and Hardware Constraints

  1. Computing Model Size: The Exact Formula
  2. KV-Cache Memory Requirements
  3. Memory Bandwidth vs Compute Throughput
  4. CPU Architectures for Inference
  5. GPU Architectures and VRAM Realities
  6. Hardware Selection Decision Framework

Chapter 6: llama.cpp: Installation, Models, and Core Usage

  1. Building llama.cpp from Source
  2. Installing Prebuilt Binaries
  3. Acquiring Models: Hugging Face and Beyond
  4. Converting Weights to GGUF
  5. Quantizing Models with llama.cpp
  6. Your First Inference Run

Chapter 7: GPU Acceleration and Offloading Strategies

  1. How Offloading Works Under the Hood
  2. Full vs Partial Offloading: When Each Wins
  3. CUDA Backend Configuration
  4. Vulkan and Cross-Vendor GPU Support
  5. Apple Silicon and Metal Acceleration
  6. Diagnosing Offloading Failures

Chapter 8: KV-Cache, Context Windows, and Memory Management

  1. How the KV-Cache Works
  2. Sizing Your KV-Cache Correctly
  3. Context Overflow and Handling Strategies
  4. RoPE Scaling and Long-Context Techniques
  5. Cache Eviction and Sliding Windows
  6. Memory Fragmentation and Allocation Patterns

Chapter 9: Throughput, Batching, and Concurrency

  1. Single Request vs Concurrent Serving
  2. Static Batching Mechanics
  3. Continuous Batching and Scheduling Strategies
  4. Queue Management Under Load
  5. Configuring llama.cpp Server for Throughput
  6. Capacity Planning and Dimensioning

Chapter 10: Benchmarking, Profiling, and Bottleneck Diagnosis

  1. Metrics That Matter: Definitions and Formulas
  2. Designing Valid Benchmark Experiments
  3. Profiling CPU Utilization and Vector Units
  4. GPU Profiling and Occupancy Analysis
  5. Memory Bandwidth Measurement Techniques
  6. Systematic Bottleneck Diagnosis Workflow

Chapter 11: Production Systems: APIs, RAG, and Deployment

  1. Building a Private Local Assistant
  2. Coding Assistant Integration Patterns
  3. RAG Service Architecture
  4. Multi-User Inference API Design
  5. Containerization and Orchestration
  6. Observability, Security, and Reliability

Chapter 12: Troubleshooting, Comparisons, and the Road Ahead

  1. Common Failure Modes and Diagnostics
  2. Performance Troubleshooting Decision Tree
  3. llama.cpp vs Other Inference Runtimes
  4. What Is Durable vs Rapidly Changing
  5. Emerging Trends and Open Problems

Conclusion: Engineering Judgment Over Magic Numbers

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub