Inference vs Training

Why does training need hundreds of GPUs but inference just one?

Training Inference Backpropagation
8 min read
Chapter 01

Learning vs Taking an Exam

The simplest way to understand training and inference is: Training = Learning, Inference = Taking an Exam. Learning requires a huge amount of time, effort, and resources; while an exam only requires applying existing knowledge to answer questions quickly.

โ— TRAINING
๐Ÿ“š
Learning Phase
  • ๐Ÿ“– Read trillions of tokens of text data
  • โœ๏ธ Iteratively adjust billions/trillions of parameters
  • โฑ๏ธ Takes weeks to months
  • ๐Ÿ’ฐ Costs tens to hundreds of millions of dollars
  • ๐Ÿ–ฅ๏ธ Requires thousands of GPUs
Weeks ~ Months
โ— INFERENCE
โœ๏ธ
Answering Phase
  • ๐Ÿ” Read one question from the user
  • โšก Compute the answer using existing weights
  • โฑ๏ธ Millisecond-level response
  • ๐Ÿ’ฐ ~$0.001 to $0.03 per query
  • ๐Ÿ“ฑ A phone or laptop is enough
~500ms

Training is like spending three years learning English; inference is like using English to order a coffee โ€” learning is slow, but using it is fast.

Chapter 02

Training: Backpropagation & Gradient Updates

At its core, training is a repeated loop: Forward Pass (compute predictions) โ†’ Compute Loss (compare with correct answers) โ†’ Backpropagation (compute gradients for each parameter) โ†’ Update Weights (fine-tune parameters).

The key memory bottleneck: training needs to store all intermediate activations (the output of every layer), because backpropagation needs them to compute gradients. This is the fundamental reason why training is so memory-hungry.

// INTERACTIVE DEMO: THE FOUR-STEP TRAINING LOOP

Input Hidden 1 Hidden 2 Output Loss stored stored
Memory Usageโ€”

Backpropagation is like a teacher grading an exam โ€” tracing back from the final answer (loss) to find errors at each step, then correcting them.

Chapter 03

Inference: Forward Pass Only

Inference does just one thing โ€” the forward pass. Data flows from the input layer to the output layer, weights are frozen (read-only), no gradients are computed, and no intermediate activations need to be stored. This means memory requirements are only a fraction of what training needs.

// INTERACTIVE DEMO: INFERENCE โ€” FORWARD PASS ONLY

Input Hidden 1 Hidden 2 Output ๐Ÿ”’ ๐Ÿ”’ Weights Frozen ยท Read-Only ยท No Gradients
Memory Usageโ€”

Inference is like solving problems after memorizing the formulas โ€” no need to derive the formulas (training), just plug in and compute.

Chapter 04

The Compute Gap: Worlds Apart

The compute gap between training and inference can exceed 100 million times. This is why only large corporations and research labs can afford training, while inference can run on your phone.

// COMPUTE COMPARISON

GPT-4 Training~25,000 ร— A100 ร— 90 days
~$100,000,000
GPT-4 Single Inference1 ร— GPU ร— 500ms
~$0.03
Llama 3 70B Training~6,000 ร— H100 ร— weeks
~$10,000,000+
On-Device Inference (9B on MacBook)1 ร— Apple Silicon ร— real-time
$0 (your device)
โ€”

The compute gap between training and inference

Training is like building a factory (massive investment); inference is like the factory producing a single product (marginal cost is extremely low).

Chapter 05

Summary

๐Ÿ“š

Training is Learning, Inference is Applying

Training learns patterns and knowledge from data; inference uses that knowledge to answer questions.

๐Ÿ”„

Training Needs Gradients, Inference Doesn't

Training requires backpropagation to compute gradients and update weights; inference only does a forward pass.

โšก

Training is Compute-Bound, Inference is Memory-Bound

Training is compute-intensive (massive matrix operations); inference is memory-bandwidth-intensive (reading weights).

๐Ÿ“ฑ

Inference Can Run on Edge Devices

Training requires data centers, but inference only needs one device โ€” this is the foundation of on-device AI.

Training creates intelligence, inference unleashes it โ€” and edge inference puts it at your fingertips.

This is why AtomGradient focuses on edge inference โ€” bringing trained intelligence to your device.

Next: Prefill & Decode โ†’