memory vs. compute
DGX B200 8 GPUs connected
Concept 🧩 🚀 GPU architecture

Kernel is a function that runs on GPU. When using PyTorch, each primitive operation launches a kernel
⚠️ moving data from memory is expensive

HBM: high bandwidth memory
naive, fused
operator fusion, tiling (FlashAttention)
sharding (parameters, activations, gradients) across GPUs
prefill phase

When a Large Language Model (LLM) generates a response, the process (called inference) doesn’t happen all at once. It is split into two distinct steps: the Prefill Phase and the Decode Phase.
The Prefill Phase is the very first step where the model reads and processes your entire input prompt.
Unlike generating text (which happens one word at a time), the model reads your entire prompt all at once. Because the input tokens are already known, the GPU processes them in parallel. This step is highly efficient and relies heavily on the sheer computational power of the GPU (it is “compute-bound”).
As the model processes your prompt, it calculates and stores mathematical representations of every word to understand their context and relationships. It saves these calculations in what is known as the Key-Value (KV) Cache. This is a crucial step because it acts as the model’s short-term memory for your prompt.
The culmination of the prefill phase is the model predicting and outputting the very first token (word or sub-word) of its response.
Once the first token is generated, the prefill phase ends and the Decode Phase begins.
Imagine you are handed a piece of paper with a complex math word problem on it.

FLOP budget -> hyperparameters
Scaling laws Flops budget = 6 * N * D: use a bigger model (N) or more tokens (D)? Hoffman2022 (Chinchilla caling laws)
🤔 D = 20 * N scaling law: 70B parameter model should be trained on 1.4T tokens
🎮 scaling laws practical VERY GOOD using nanoGPT by Andrew Karpathy
this can be used to calculate a token budget
đź’ˇ also used to ask for more money to investors!
🤔❓ data: what capabilities you want your model to have? Conversation? Agentic coding?
diverse set of evaluations since LLMs are general purpose.
Perplexity within token budget
licesing issues: lot of github code does not have a license. So assume permissive?
efficiency: hardware, data, compute, memory, communication bandwidth. How do you build the best model?
Faster inference
