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
  • 2GPU sizing arithmetic

    Exercise answers

    • Answer: A GPU budget calculator from any config.json
    • Answer: Compare the calculator with the engine's own KV sizing
  • 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 2

GPU sizing arithmetic

A GPU budget is four numbers (weights times bytes per parameter, KV bytes per token times tokens in flight, activations and graph headroom, and what is left) and the engine flags that implement it; the same three numbers give the speed floors and decide between one GPU, tensor parallel and pipeline parallel.

80 min 1 video 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvHugging Face account and CLIThe Quillmoor triage kitServe a model with vLLMRun GPU code on Modal

By the end of this lesson you can

  • Compute the KV-cache bytes per token of a model from its config and the serving dtype, including grouped-query attention
  • Produce a memory budget for a named GPU that gives the maximum concurrent sequences at a chosen context length, with headroom
  • Estimate batch-1 decode speed from weights and memory bandwidth, and prefill time from FLOPs
  • Decide between a single GPU, tensor parallel and pipeline parallel for a model that does not fit, and state the communication cost of each
  • Read the vLLM flags that implement the budget, and know which to change first when the engine reports preemptions

On this page

  • Where the memory goes
  • The four terms with real numbers
  • Speed from the same numbers
  • When the model does not fit
  • The flags that implement the budget
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Where the memory goes
  2. 02The four terms with real numbers
  3. 03Speed from the same numbers
  4. 04When the model does not fit
  5. 05The flags that implement the budget
  6. 06Connections
  7. 07Summary

Sources & further reading

  • GQA: Training Generalized Multi-Query Transformer Models from Multi-Head CheckpointsPaper · Ainslie, Lee-Thorp, de Jong, Zemlyanskiy, Lebrón, Sanghai · Google · 2023Why the KV formula has the number of key/value heads in it rather than the number of query heads, and what sharing them costs in quality. EMNLP 2023; sections 2 and 4.
  • AI and Memory WallPaper · Gholami, Yao, Kim, Hooper, Mahoney, Keutzer · UC Berkeley · 2024Peak FLOPS have grown far faster than memory bandwidth across GPU generations, which is why the decode floor is a bandwidth number and why the gap keeps widening.
  • The Llama 3 Herd of ModelsPaper · Grattafiori et al. · Meta · 2024The inference section describes serving the 405B model across GPUs with pipeline and tensor parallelism and how FP8 halves the footprint; the worked example of a model that does not fit.
  • Engine ArgumentsDocs · vLLMThe reference for every flag this lesson names: `--max-model-len`, `--max-num-seqs`, `--max-num-batched-tokens`, `--gpu-memory-utilization`, `--kv-cache-dtype`, `--kv-cache-memory-bytes`, `-tp`, `-pp`.
  • Optimization and TuningDocs · vLLMHow vLLM sizes the KV cache from measured free memory, what the preemption warning means and the four remedies, and when to use tensor, pipeline, expert and data parallelism.
  • NVIDIA L4 Tensor Core GPUDocs · NVIDIAThe product page the kit's `gpus.json` was built from: 24 GB, 300 GB/s, and the Tensor Core figures that are halved for dense arithmetic.
  • Quantization overviewDocs · Hugging FaceThe bytes-per-parameter rule of thumb (an 8B model at 16 GB in bf16, 8 GB at 8 bits, 4 to 5 GB at 4 bits) and the pre-quantised versus quantise-on-load distinction used in the next module.
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.

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