Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Serving Open-Weight Models

Free · sign in to start and track progress

1 · What the server does with your GPU

  • 1Inside an inference engine

    Exercise answers

    • Answer: Simulate static versus continuous batching with a paged KV cache
    • Answer: Measure what prefix caching saves on a real server
  • 2GPU sizing arithmetic
  • 3Serving your adapter

2 · Smaller, faster, still correct

  • 4Quantisation with evidence
  • 5Latency, throughput and honest benchmarks
  • 6Speculative decoding in practice
  • 7Structured outputs and tool calls

3 · Ship it and run it

  • 8What self-hosting makes you responsible for
  • 9Deployment and rollout
  • 10Observability and operations
CapstoneShip the triage endpointReference implementation

Module 1 · What the server does with your GPU · Lesson 1

Inside an inference engine

Prefill and decode are different workloads, and an inference engine's whole job is keeping a memory-bound decode loop busy with many requests at once through iteration-level batching, paged KV memory, chunked prefill and prefix caching.

85 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvThe Quillmoor triage kitServe a model with vLLMRun GPU code on Modal

By the end of this lesson you can

  • Compute the arithmetic intensity of a decode step at a given batch size and say whether it is memory- or compute-bound on a named GPU
  • Explain iteration-level (continuous) batching and why it beats static batching for generation
  • Explain how PagedAttention allocates the KV cache in blocks and what that buys
  • Predict the effect of chunked prefill and automatic prefix caching on time to first token and inter-token latency
  • Choose between vLLM, SGLang, TensorRT-LLM and llama.cpp for a stated workload and hardware

On this page

  • Two phases, two bottlenecks
  • Arithmetic intensity: the number behind every latency
  • Iteration-level batching
  • PagedAttention: the KV cache as pages
  • Chunked prefill and prefix caching
  • Which engine
  • Quillmoor's traffic through the engine
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Two phases, two bottlenecks
  2. 02Arithmetic intensity: the number behind every latency
  3. 03Iteration-level batching
  4. 04PagedAttention: the KV cache as pages
  5. 05Chunked prefill and prefix caching
  6. 06Which engine
  7. 07Quillmoor's traffic through the engine
  8. 08Connections
  9. 09Summary

Sources & further reading

  • Efficiently Scaling Transformer InferencePaper · Pope, Douglas, Chowdhery, Devlin, Bradbury et al. · Google · 2022The arithmetic-intensity analysis of decode that this lesson's floor calculations rest on. Sections 2 and 3: why generating one token at a time is bound by memory traffic, and how batch size moves it.
  • Efficient Memory Management for Large Language Model Serving with PagedAttentionPaper · Kwon, Li, Zhuang, Sheng, Zheng et al. · 2023The vLLM paper. Section 3 measures how much KV memory earlier servers wasted; section 4 is the block table, sharing and copy-on-write.
  • Orca: A Distributed Serving System for Transformer-Based Generative ModelsPaper · Yu, Jeong, Kim, Kim, Chun · 2022Iteration-level scheduling and selective batching, the idea every modern engine implements as continuous batching. OSDI 2022.
  • Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-ServePaper · Agrawal, Kedia, Panwar, Mohan, Kwatra et al. · Microsoft · 2024Chunked prefill and stall-free batching: why a long prompt landing in a decode step hurts every other user, and how splitting it fixes that. OSDI 2024.
  • Mastering LLM Techniques: Inference OptimizationLab research · NVIDIA · 2023A one-page tour of the same ideas from the GPU maker, with prefill versus decode, in-flight batching and the KV cache in one place.
  • Automatic Prefix Caching (design)Docs · vLLMHow vLLM hashes KV blocks (parent hash, block tokens, extra keys such as the LoRA id), why only full blocks are cached, and how eviction works.
  • Optimization and TuningDocs · vLLMThe scheduler's defaults: chunked prefill on, decode first, and what `max_num_batched_tokens` trades between inter-token latency and time to first token.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 9 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks