Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

100 Days of LLM Inference

A structured deep-dive into inference engineering — from CUDA kernels to multi-cloud autoscaling — built around Inference Engineering by Philip Kiely (Baseten Books, 2026).

Each entry is a runnable script. All experiments run on a home-lab cluster of two NVIDIA DGX Sparks.


What is Inference Engineering?

"Doing inference well requires three layers: Runtime, Infrastructure, and Tooling." — Philip Kiely, Inference Engineering

Inference engineering is the discipline of serving generative AI models in production — faster, cheaper, and more reliably. It spans the full stack from CUDA memory layouts to Kubernetes autoscaling policies. This challenge covers all three layers systematically.


The Plan

Phase 1 — Runtime: Single-Instance Optimization

Getting the most out of one GPU. This is where most of the leverage lives.

DayTopicBook
01LLM Inference Mechanics: End-to-end text generationCh 2.2
02Inference from Scratch: Model internals & tokenizationCh 2.2
03Embeddings: From integers to vectorsCh 2.2.1
04Transformer Blocks & Attention Deep DiveCh 2.2.2–2.2.3
05KV CacheCh 2.2
06Ops:Byte Ratio & Arithmetic IntensityCh 2.4
07CUDA Kernels, Kernel Selection & Kernel FusionCh 4.1
08PyTorch, Model File Formats, ONNX & TensorRTCh 4.2
09vLLM: PagedAttention & Continuous BatchingCh 4.3.1
10SGLang: RadixAttention & Structured OutputsCh 4.3.2
11TensorRT-LLM: Compilation & Plugin SystemCh 4.3.3
12NVIDIA Dynamo: Disaggregated ServingCh 4.4
13Quantization: Number Formats (FP8, INT8, INT4, NVFP4)Ch 5.1.1
14Quantization Algorithms: GPTQ, AWQ, SmoothQuantCh 5.1.2
15Speculative Decoding: Draft-Target, Medusa, EAGLECh 5.2
16KV Cache: Prefix Caching & Cache-Aware RoutingCh 5.3
17Model Parallelism: Tensor, Expert, Pipeline & DataCh 5.4
18Disaggregation: Prefill/Decode SplitCh 5.5

Phase 2 — Infrastructure: Scaling Across Clusters

Getting the most out of many GPUs across clouds and regions.

DayTopicBook
19GPU Architecture: SMs, Memory Hierarchy, HBMCh 3.1
20GPU Generations: Hopper, Ada, Blackwell, RubinCh 3.2
21Multi-GPU Instances & Multi-Instance GPU (MIG)Ch 3.3
22Containerization: Docker & NVIDIA NIMsCh 7.1
23Autoscaling: Concurrency, Batching & Cold StartsCh 7.2
24Routing, Load Balancing & QueueingCh 7.2.3
25Multi-Cloud Capacity ManagementCh 7.3
26Zero-Downtime Deployment & Cost EstimationCh 7.4

Phase 3 — Tooling: Productivity & Observability

The instrumentation layer that makes the other two debuggable.

TopicBook
Performance Benchmarking: Tooling & ProfilingCh 4.5
Observability: Metrics, Tracing & DashboardsCh 7.4.3
Client Code: Streaming, Async & Protocol SupportCh 7.5

Phase 4 — Deep Implementation: Build It from Scratch

The book explains the concepts. Now implement them.

Project
Implement a BPE tokenizer from scratch
Build a bare autoregressive decoder loop in PyTorch
Implement scaled dot-product attention (SDPA) with masking
Implement Flash Attention (simplified, tiling in Python)
Profile attention memory growth across sequence lengths
Build an INT8 quantization pipeline: quantize → dequantize → measure error
Implement GPTQ-style round-to-nearest with Hessian weighting
Sweep quantization bit widths and plot perplexity vs compression
Simulate draft-target speculative decoding with acceptance sampling
Build a simple KV cache manager (block allocator, eviction policy)
Implement prefix caching with hash-based deduplication
Simulate tensor parallelism: split a matmul across N workers
Benchmark ops:byte ratio in practice across matrix sizes
CUDA profiling: profile a PyTorch model with torch.profiler
Write a custom elementwise CUDA kernel via Triton
Build a PyTorch custom op with CUDA backend
Deploy vLLM on spark-01, benchmark TTFT and throughput
Deploy SGLang, benchmark structured output latency
TensorRT-LLM: compile a model and compare with eager PyTorch
NVIDIA Dynamo: run a disaggregated prefill experiment
Simulate continuous batching: queue arrivals, dynamic batch formation
Visualize PagedAttention block layout and fragmentation
Benchmark TTFT vs throughput tradeoff across batch sizes

Phase 5 — Production Systems: From Notebook to Cluster

Ship it.

Project
Write a production Dockerfile for a vLLM inference server
Build and push a NIM-compatible container
Simulate an autoscaling policy: requests per second → replica count
Measure cold start latency: model load times at different sizes
Implement round-robin and least-connections load balancers
Build a priority request queue with batch formation
Multi-GPU tensor parallel benchmark across spark-01 and spark-02
Configure MIG on a Spark GPU: profile different partition sizes
GPU cost model: $/token across instance types at different utilizations
Blue-green deployment: zero-downtime model version swap
Emit Prometheus metrics from an inference server
Build a Grafana dashboard: TTFT, TBT, queue depth, GPU utilization
Add distributed tracing (OpenTelemetry) to an inference request
Load test with Locust: ramp traffic, find saturation point
Profile with Nsight Systems: identify kernel launch overhead
Build a streaming inference client using SSE
Async batch inference client using asyncio + aiohttp
Multi-cloud routing: geo-aware latency-based request routing
GPU memory profiling: find where your memory budget goes
Benchmark quantization levels on real throughput: FP16 vs INT8 vs INT4
Measure speculative decoding acceptance rates by draft model size
Measure KV cache hit rates across real traffic patterns
Tensor parallelism scaling: throughput and latency vs GPU count
End-to-end latency breakdown: tokenization → TTFT → TBT → detokenization
Build a reusable inference benchmark harness

Phase 6 — Modalities: Beyond Text

The book covers vision, audio, and video. Inference engineering applies to all of them.

TopicBook
Vision Language Model (VLM) inference: image preprocessing and batchingCh 6.1
Embedding model inference: batching and throughput optimizationCh 6.2
ASR (Whisper): single-chunk and long-file latency optimizationCh 6.3
TTS: streaming real-time text-to-speechCh 6.4
Image generation: diffusion model inference and kernel optimizationCh 6.5
Video generation: context parallelism and attention optimizationCh 6.6
Multi-modal batching: mixing text and image requestsCh 6.1–6.2
Embedding similarity search pipeline: embed → index → queryCh 6.2
Speech-to-speech pipeline: ASR → LLM → TTS end-to-end latencyCh 6.3–6.4
Long context: RoPE scaling, context parallelism across GPUsCh 5.3.4

Phase 7 — Advanced Techniques

The frontier of inference research, made practical.

Topic
EAGLE speculative decoding: feature-level draft vs token-level
Medusa: multi-head speculative decoding, measure speedup
MoE routing from scratch: top-K gating, load balancing loss
Expert parallelism: simulate routing across N expert shards
Dynamic disaggregation with NVIDIA Dynamo
Cache-aware routing: route requests to maximize KV cache hits
Long context without context parallelism: chunked prefill
Fine-tuning a small model for inference quality vs a large quantized one
Distillation for inference: teacher-student latency/quality tradeoffs
Intelligence evaluation: build an eval harness for a deployed model

Phase 8 — Capstone: A Production Inference Stack

Build something real.

Capstone Task
Design: sketch the full inference stack for a real use case
Build: FastAPI + vLLM inference server with health checks and metrics
Deploy: ship it to the home lab cluster with load balancing
Optimize: run the benchmark harness, find the bottleneck, fix it
Reflect: what I learned, what I'd do differently, what's next

Setup

Hardware: Two NVIDIA DGX Sparks (spark-01: 192.168.1.76, spark-02: 192.168.1.77)

Each notebook is self-contained. Run any topic independently:

ssh nvidia@192.168.1.76
cd ~/src/github.com/elizabetht/100-days-of-inference/dayNN
jupyter notebook

Generate notebooks with the Claude Code skill:

/learn-inference-eng next        # generate the next notebook
/learn-inference-eng 7           # jump to topic 07: vLLM
/learn-inference-eng quantization # fuzzy-match to topic 11

Progress

PhaseStatus
Runtime Layer18 / 18
Infrastructure Layer8 / 8
Tooling Layer0 / 3
Deep Implementation0 / 23
Production Systems0 / 25
Modalities0 / 10
Advanced Techniques0 / 10
Capstone0 / 5
Total26 / 102

Reference

  • Book: Inference Engineering — Philip Kiely (Baseten Books, 2026)
  • Cluster: spark-01 192.168.1.76 · spark-02 192.168.1.77
  • Start: 2026-03-31

关于 About

100 days of LLM inference engineering — daily posts, experiments, and visualizations

语言 Languages

Jupyter Notebook100.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
50
Total Commits
峰值: 13次/周
Less
More

核心贡献者 Contributors