Production-grade ML training notebooks. DPO, RLHF, LoRA, Diffusion, Audio, Vision — all runnable for free on Kaggle T4x2 or Google Colab.
DPO skips reward modeling and RL entirely. It trains the model directly on human preference pairs using a reformulation of the RLHF objective.
loss = -log( sigmoid( β · [ log(P/P_ref)_chosen - log(P/P_ref)_rejected ] ) )
β controls conservatism. Higher β = model stays closer to the original.
The missing link between training and serving: the artifact contract, merge-vs-adapter, a quality regression gate built before you optimize, quantize-then-re-gate, a serving config derived from capacity math, the SLO gate at N−1, and rollback triggers.
tools/e2e_pipeline.py as a CI release gateThe front door to the 23-notebook serving track. Paste your metrics and get a ranked diagnosis with the evidence for each finding, an ordered plan budgeted by accuracy risk and effort, a verification checklist, and a self-test that asserts the track's shared physics.
Train the same model with 4 different alignment methods. Compare quality AND training performance side by side.
The complete 3-stage alignment pipeline on Qwen2.5-0.5B. SFT teaches instruction following, DPO aligns offline, PPO/RLHF aligns online.
Train all 3 methods on the same model and data. Compare GPU memory, speed, and output quality side by side.
Direct Preference Optimization on TinyLlama. Learn how DPO works by training it yourself with real preference pairs.
Production-grade distributed training. Same code scales from 1 GPU to 100 GPUs with Ray Train orchestration.
Two-stage alignment on free Kaggle GPUs. SFT teaches instruction following, then DPO aligns with preferences. Auto-detects your hardware.
Fine-tune LLaVA 7B vision-language model. LoRA in 8-bit, QLoRA in 4-bit, then DPO to prefer detailed image descriptions.
Teach Stable Diffusion a new style or concept. LoRA on UNet attention layers — tiny adapters (~1MB), same results.
LoRA fine-tune ViT-base on Food-101. A text transformer that reads image patches instead of words.
Fine-tune Whisper-small for speech-to-text with LoRA. Multi-GPU with DeepSpeed on freely available FLEURS data.
Fine-tune Qwen2-VL-2B on image+text data with LoRA and multi-GPU acceleration.
Actually train all 124M parameters of GPT-2 end-to-end. ZeRO-3 shards the entire model across GPUs + CPU.
The simplest possible distributed fine-tuning notebook. GPT-2 + LoRA + DeepSpeed on 500 Alpaca examples. Start here.
Run identical training with DDP, ZeRO-2, and ZeRO-3. See exactly how much speedup and memory savings each gives you.
See a raw model become an assistant. Generate text at Base → SFT → DPO and compare side-by-side. The simplest possible explanation of post-training.
Train Qwen2.5-1.5B to solve math problems using pure RL. No reward model, no CoT data — just "is the answer correct?" The algorithm behind DeepSeek-R1.
QLoRA fine-tune Qwen2.5-7B on A100 40GB. 2048-token sequences, 4-bit NF4, benchmarked on 4 Open LLM Leaderboard tasks vs Llama-2, Mistral, Llama-3.
Full fine-tuning with modern techniques: cosine LR, gradient checkpointing, weight decay. Benchmarked against TruthfulQA (Open LLM Leaderboard).
Evaluate model outputs using LLM and VLM judges. Three methods: automated metrics, rule-based scoring, and model-as-judge. All local, no API needed.
Treat agent reasoning as a search over executable traces. 10 strategies × 3 benchmarks (ARC / SWE / MLE-style), 5-dim weighted scoring, hybrid trace synthesis, beam-search pruning, plus a TraceEvaluator that diagnoses failures and emits concrete retry actions. Rescues 4/4 failing strategies (26/30 → 30/30).
The mental model behind every serving engine, measured live: prefill vs decode, KV-cache memory math (GQA/MLA), TTFT/TPOT, and a continuous-batching simulator that shows where the 2× comes from.
Run the engine behind most self-hosted LLM APIs: PagedAttention explained, throughput vs Hugging Face measured, prefix caching demonstrated, then a live OpenAI-compatible server load-tested with 32 concurrent clients.
One model, four formats — FP16, AWQ-int4, GPTQ-int4, NF4 — benchmarked head-to-head for memory, batch throughput, single-user speed, and accuracy. Includes why the QLoRA trick is not a serving format.
Losslessly faster generation: draft-model speculation (3B + 0.5B on one T4), prompt-lookup decoding, the acceptance-rate math, EAGLE-3/Medusa/MTP, and the 2025 frontier — disaggregated prefill/decode, KV infrastructure, RadixAttention.
Four interactive D3 visualizations you can scrub and animate: a KV-memory explorer, static-vs-continuous batching as a live Gantt, the PagedAttention block pool frame by frame, and a speculative-decoding accept/reject strip.
Read a serving engine line by line: the 4 startup lines that decide your capacity, the periodic stats heartbeat, Prometheus histograms (percentiles computed by hand), a triage playbook, and an animated incident where KV saturation leads TTFT by 12 seconds.
Why most LLM benchmarks lie (closed-loop testing, means instead of tails), an open-loop Poisson load generator, finding the latency knee, goodput under an SLO, and $ per million tokens across GPUs and optimizations.
Build a token-masking FSM from scratch and watch a random number generator emit perfect schema-valid JSON. Then the real thing: xgrammar, guided_json, tool calling, and the traps (including how max_tokens still breaks your JSON).
Tensor parallel vs replicas, modeled and plotted against your latency SLO; the all-reduce communication tax that makes TP a within-node technique; and prefix-aware routing, which can rival a hardware upgrade for free.
Fifty fine-tunes, one GPU. How batched multi-LoRA keeps the expensive GEMM shared, why max_loras is a scheduling constraint rather than a memory knob, and the tenancy economics that turn 50 GPUs into one.
The roofline derived specifically for LLM inference across T4→B200 and MI210→MI355X: the exact batch size where decode stops being memory-bound, why quantization moves it, and why 192GB of VRAM changes your topology more than raw FLOPS do.
What actually runs where: the precision × architecture support matrix (hardware vs framework vs tuned kernel), CUDA/HIP/Triton trade-offs, the vLLM flag translation table, and one Triton kernel that compiles for both vendors.
Every equation from the track consolidated into one interactive model: change GPU, precision, batch, or context and watch throughput, latency and $/1M tokens move. Includes tornado sensitivity, a Pareto frontier, and a section on where the model lies to you.
The KV wall at 128k+ drawn across model families, then six ways through it: sliding-window and hybrid attention, MLA, FP8 KV, chunked prefill, and an eviction simulator showing exactly which tokens attention sinks and heavy-hitter policies throw away.
Total vs active parameters, the MoE roofline (why MoE decode is more memory-bound than dense at the same batch), expert parallelism's all-to-all cost, and a routing-imbalance simulator showing the straggler rank that sets everyone's step time.
Agent prefill is quadratic in turns. The prompt-layout rule that decides your cache hit rate, the KV cache hierarchy, model cascades and their break-even escalation rate, and why semantic caching trades correctness for cost.
The cancellation leak that silently eats capacity, why bounded queues beat unbounded ones, per-tenant fairness, graceful drain and rollout math, a failure taxonomy, and a chaos drill that shows exactly where N−1 headroom stops being optional.
Where the milliseconds actually go inside one decode step: GEMMs, attention over KV, sampling, and the fixed launch overhead that dominates small batches. An interactive budget you can re-proportion, a map of which optimization cuts which slice, and a profiler that runs on CUDA or ROCm.
FlashAttention is usually explained with a picture. Here you implement it — online softmax, tiling, FlashDecoding's split-K, and PagedAttention as a one-line change to the loop — in NumPy, each verified against the naive version to machine precision. Then why FA-3's speed is Hopper-specific even though the algorithm is not.
Four optimizations whose headline numbers multiply to 10× deliver 6× — and some pairs actively fight. A computed interaction matrix, bottleneck migration as you stack, and a search for the best stack under an accuracy-risk and effort budget.
One image is 500–7,000 tokens. Image→token math for LLaVA / Qwen2-VL / InternVL, the four-phase pipeline including the CPU stage no GPU metric shows, why variable image sizes wreck batching, and max_pixels as the master dial.
Embedding and prefix caching (and the hash-stability trap), where visual token pruning happens and whether it frees KV, adaptive resolution routing, why the ViT stays fp16 while the LLM goes int4, video frame sampling — and which of these fight each other.