A 175 billion parameter model needs 350 GB at 16 bits, and a phone has 4 GB. See how compression closes that gap, and why every efficiency number matters.
Learn why modern AI outgrew its hardware, how pruning and quantization shrink a model, and what each part of the course will teach you.
Pick a model and a device, then lower the bits and remove weights. Watch the bar reach the dashed memory line. Then we walk the lecture in order, from vision on phones to language models on a laptop.
You need to know what a weight in a neural network is and what a byte is. We build the rest from zero.
Based on Lecture 1 of MIT 6.5940: TinyML and Efficient Deep Learning Computing (Fall 2026), taught by Song Han and the MIT HAN Lab. Lecture 1 slides. Every idea is re-taught here in our own words and devices. Next lecture: neural network building blocks.
Illustrative arithmetic: size = parameters x (1 minus the share removed) x bits / 8, in decimal units, with no cost for storing which weights were removed. Parameter counts for ViT-H (0.6B), Llama 3 (8B) and GPT-3 (175B) come from the lecture slides; the Tiny CNN (0.5M) is a made-up size. Cloud GPU is an 80 GB A100 and Phone is 4 GB of memory, both from the slides. The microcontroller limit is its 1 MB of flash storage, because it keeps weights in flash and activations in a separate 320 kB.
Chapter 0
See why the biggest models no longer fit on one chip, and how compression closes the gap
You download a language model with 8 billion parameters and press run on your laptop. The program stops with "out of memory". Your code is fine. The model is larger than the room you gave it.
Lecture 1 opens with a chart of two curves. The first is model size, counted in parameters: one parameter is one learned number, such as a weight. The second is the memory of a top GPU. The slide's verdict: model compression bridges the gap.
| Curve | 2017 | End of the chart | Growth |
|---|---|---|---|
| Model size | 0.05B (Transformer) | 2,700B (Grok-3) | about 54,000 times |
| GPU memory | 16 GB (P100) | 288 GB (R200) | 18 times |
Call the number of parameters P. Call the bits that store one parameter b. The lecture's chart assumes FP16, a 16-bit float, so b = 16. A byte is 8 bits.
Size equals P times b, over 8.
Multiply the parameter count P by the bits b. Divide by 8. The result is the size of the weights in bytes.
GPT-3 has P = 175 billion. At b = 16: 175 × 109 × 16 / 8 = 350 GB. An A100 holds 80 GB, so the weights alone need 5 cards (350 / 80 = 4.4, rounded up).
The bar is the weight size. Each short tick marks the memory of one GPU from the slides. Slide the model, then lower the bits.
Parameter counts are from the lecture's chart: 0.05B, 0.11B, 0.34B, 1.5B, 8.3B, 175B, 530B, 1,800B (marked with an asterisk on the slide, so treat it as an estimate) and 2,700B. GPU memories are the slide's: P100 16 GB, V100 32 GB, A100 80 GB, B200 192 GB, R200 288 GB. Counts are for weights only and round up.
At 4 bits GPT-3 drops to 87.5 GB: four times smaller, and still bigger than one A100. Grok-3 at 4 bits needs 1,350 GB.
Compression adds one step between training and inference, the stage where the network answers new inputs. A big trained model goes in. A small model that answers almost as well comes out. The main tools:
Papers on pruning and sparse networks stayed few from Optimal Brain Damage (1989) to Deep Compression and EIE (2015 and 2016). Then the count climbs to about 3,600 by 2023 (slide 5). Hardware followed: NVIDIA's Ampere Sparse Tensor Core runs 2:4 sparsity, where two of every four weights are zero.
Symptom: you cut GPT-3 to 4 bits and it still crashes on an 80 GB card. Measure: 87.5 GB is 7.5 GB too many, before any activations. Fix: stack the methods. Remove 10% of the weights as well: 175 × 109 × 0.9 × 4 / 8 = 78.75 GB. Now the weights fit, with almost no room left.
pythondef weight_bytes(params, bits, removed=0.0): # params: int, bits: 16 | 8 | 4 | 2, removed: share of weights deleted (0..1) return params * (1 - removed) * bits / 8 gpt3 = 175e9 print(weight_bytes(gpt3, 16) / 1e9) # 350.0 GB print(weight_bytes(gpt3, 4, 0.1) / 1e9) # 78.75 GB, fits one 80 GB card
Chapter 1
Count the multiply-adds behind one photo label, then see how a smarter design cuts them fourteen times
Your phone labels a thousand photos with no server. How do such costly networks get light and fast?
Image classification gives a picture one label. On ImageNet (over a million photos, 1,000 labels) the score is top-5 error. That is how often the right label is missing from the five best guesses.
Each bar is one year's winner. The dashed line is the human error of 5.1%. Slide the year forward.
Numbers are the lecture's ImageNet chart: 28.2, 25.8, 16.4 (AlexNet), 11.7, 6.7 (GoogLeNet), 3.6 (ResNet), 3.0, 2.3 (SENet) and human 5.1, all top-5 error in percent.
Slide 9 plots accuracy against MACs. One MAC (multiply-accumulate) multiplies two numbers and adds the result to a running total. The best handmade networks, such as ResNeXt-101, sit near 8 billion.
Count the MACs of one convolution layer, which slides a k by k window of weights over an image. It makes an H by W grid of outputs, with Cin channels in and Cout channels out.
MACs equal H times W, times C-out, times C-in, times k squared.
Count the positions, H times W. Each makes C-out values. Each value reads k squared weights from each of the C-in channels.
With an illustrative layer, H = W = 56, C-in = 64, C-out = 128, k = 3: 3,136 × 128 × 64 × 9 = 231,211,008 MACs. It holds only 9 × 64 × 128 = 73,728 weights, because each weight works at every position.
Set the layer shape. The bar shows MACs against the 595 million budget of an efficient ImageNet network. Then switch to the separable design.
The 595 million MACs line is the Once-for-All network on slide 10 (80.0% top-1 on ImageNet). The layer shapes are illustrative, and a real network stacks dozens of layers. The separable design splits the 3 by 3 layer into a per-channel 3 by 3 step plus a 1 by 1 mixing step. Lecture 2 builds it in full.
Flip to Separable: 27,496,448 MACs for the same shape, 8.4 times fewer.
Neural architecture search (NAS) has a program try network shapes and keep the good ones. Its result, Once-for-All, reaches 80.0% top-1 with 595 million MACs: 14 times less computation (slide 10).
Such networks run Photo Tags and Lite Pose on phones. MCUNet runs mask and person detection on a microcontroller (MCU): an ARM Cortex-M7 with a few hundred kilobytes of memory.
Symptom: 2 more points of accuracy, but a slow, hot phone. Measure: about 8 billion MACs against Once-for-All's 595 million. Fix: set a MAC budget first, then search under it.
pythondef conv_macs(h, w, c_in, c_out, k, separable=False): if not separable: return h * w * c_out * c_in * k * k depthwise = h * w * c_in * k * k # one k x k filter per input channel pointwise = h * w * c_in * c_out # 1 x 1 mixes channels return depthwise + pointwise print(conv_macs(56, 56, 64, 128, 3)) # 231,211,008 print(conv_macs(56, 56, 64, 128, 3, True)) # 27,496,448, about 8.4x fewer
Chapter 2
Find out why training needs far more memory than inference, and how three tricks shrink it by thousands of times
Your smart speaker would work better if it learned your voice, but that audio is private. On-device learning trains on the device that holds the data. Slide 14 lists better privacy, lower cost, customization and life-long learning. The catch: training costs more than inference, and edge memory is small.
Inference runs forward once and frees each layer's input after the next layer uses it. So about two activations (the data between layers) are alive at once. Training adds a backward pass, and a layer y = Wx needs its input x again for its weight gradient. So every input stays until the backward pass returns.
Call the weight memory w. Call the memory for the gradients (one number per weight that says how to nudge it) g. Call the activation that layer i saves ai.
M-train equals w plus g plus the sum over i of a-i.
Add the weights w and the gradients g. Then add the saved activation a-i of every layer. The total is M-train.
With made-up sizes: w = g = 100 KB, activations 48, 32, 24 and 16 KB. M-train = 100 + 100 + 120 = 320 KB. Inference needs w plus the largest pair: 100 + 48 + 32 = 180 KB. A 256 KB chip can run this network but not train it.
Slide 15 (MCUNetV3) gives one task's training memory: TensorFlow 652 MB, PyTorch 303 MB, the edge framework MNN 41.5 MB. All miss the 256 KB limit. The Tiny Training Engine and three ideas close the rest.
Each bar is the memory to train one network under one setup. The dashed line is the 256 KB limit of a microcontroller. Slide to add the next idea.
Sizes and step factors are read from slide 15 of the lecture (MCUNetV3, Lin et al.). The step factors on the slide are 7.3x, 2.0x, 8.8x and 2.4x; dividing the rounded sizes gives slightly different values, so we quote the slide's. The limit is taken as 256 KB in decimal units.
| Idea | What it does | Gain on the slide |
|---|---|---|
| Quantization-aware scaling | The network stores weights as 8-bit integers, so weights and gradients sit on different scales. It rescales each weight gradient by one over the square of that weight's scale, which keeps training stable. | 2.0x |
| Sparse layer and tensor update | Train only some layers, or part of a layer. A layer that does not update needs no saved input and no gradient. | 8.8x |
| Operator reordering | Use each gradient and free it before the next one exists, so fewer buffers are alive. This reading is ours; the slide gives only the name. | 2.4x |
The slide labels the ladder 2300x. 303 MB over 141 KB is about 2,100, so the label likely uses another baseline. The test (slide 16): an ImageNet pre-trained MCUNet adapts to VWW (Visual Wake Words: is a person in view?). It runs on an OpenMV Cam H7 with 185 KB of SRAM and 467 KB of flash.
Symptom: training works on the laptop and crashes on the board. Measure: even the Tiny Training Engine alone needs 5.7 MB. Fix: add the ideas one at a time and measure after each. Only the full stack fits.
pythondef peak_memory(weights_kb, acts_kb, training): # acts_kb: activation size of each layer, in order if not training: peak = max(a + b for a, b in zip(acts_kb, acts_kb[1:])) # two neighbours alive return weights_kb + peak return weights_kb + sum(acts_kb) + weights_kb # all acts saved, plus gradients print(peak_memory(100, [48, 32, 24, 16], False)) # 180 KB print(peak_memory(100, [48, 32, 24, 16], True)) # 320 KB
Chapter 3
Learn where a model spends its compute, then watch five different tricks cut it for the same picture
You tap a mug in a photo and an outline snaps around it. You type "an astronaut riding a horse on Mars" and a picture appears. Both feel instant. Neither is cheap.
Segmentation marks which pixels belong to an object. Segment Anything (SAM, slide 17) is promptable: you click or draw a box, and it returns that object's mask. A heavy image encoder reads every pixel, and a small prompt encoder and mask decoder do the rest. So almost all the cost sits in the encoder.
EfficientViT-SAM swaps only that encoder for EfficientViT. On an A100 it runs 182 images per second where SAM-ViT-H runs 11: 16.5 times faster (slide 19). Slide 18 says it matches SAM-ViT-H's zero-shot accuracy with a 48.9 times speedup.
A diffusion model starts from noise and cleans it many times, guided by your text. Training Stable Diffusion cost about $600,000 on 256 A100s for 150,000 GPU hours (slide 20). That is about 24 days of the whole cluster, at $4 per GPU hour. One step of each model on slide 21:
| Model | Input | MACs per step |
|---|---|---|
| ViT-H (0.6B) | a 518 x 518 image | 1.02 T |
| Llama 3 (8B) | 1,024 tokens in, 512 out | 11.2 T |
| FLUX.1 (12B) | one 1K x 1K image step | 37.2 T |
| CogVideoX (5.6B) | one step for 49 frames of 480 x 720 | 332 T |
The slide adds that cost grows faster than the square of the resolution. A bigger picture has more patches, or tokens. Most layers cost in proportion to the tokens, but attention, where every token looks at every other, costs in proportion to their square. Double the side: tokens grow 4 times and attention 16 times.
The solid curve is a fitted cost for one step. The dashed curve is the cost if it grew only with pixel count. Slide the side length.
Illustrative fit: cost = 37.2 T x (L r² + A r⁴) / (L + A), where r is side / 1024 and A / L = 0.19. The 37.2 T at 1,024 is from slide 21. The value near 2,000 T at 4,096 is read by eye from the slide's chart, so the fit is approximate. Real cost depends on the model.
At 4,096 the pixels grew 16 times and the cost about 54 times. The attention term makes the difference.
| Method | The trick | The numbers |
|---|---|---|
| GAN Compression (22) | Prune a GAN image generator | 9 to 21 times fewer MACs across three tasks. CycleGAN: 56.8 G to 3.50 G, 12.1 to 40.0 fps on a Jetson Xavier, FID (lower is better) 61.5 to 53.6 |
| Anycost GAN (23, 24) | Train once, slice into sub-networks: small for previews, large for the final image | Budget 1x to 0.2x, priced $0.01 to $0.002 per image |
| SIGE (25) | Recompute only the edited region | 11.6% masked: 1,855 G and 369 ms to 514 G and 95.0 ms. A 2.9% edit: 353 G and 76.4 ms (RTX 3090) |
| DistriFusion (26) | Split one image over 4 GPUs and keep the pieces consistent | One GPU: 907 T, 12.3 s. Naive split: 3.14 s with duplicated subjects. DistriFusion: 227 T per GPU, 4.16 s, no artifacts |
| SVDQuant (27) | 4-bit weights and activations | FLUX.1-dev 12B: 24 GB to 6 GB of weights, so it runs on a 16 GB RTX 4090 laptop without CPU offloading |
Symptom: you move one small object and wait for the whole image. Measure: 2.9% of the pixels changed, yet the model redrew the whole image in 369 ms. Fix: cache what did not change and compute only the edit, as SIGE does: 76.4 ms.
pythondef step_cost(side, base=37.2, attn_ratio=0.1867): r = side / 1024 # resolution relative to 1024 return base * (r**2 + attn_ratio * r**4) / (1 + attn_ratio) # T MACs per step print(step_cost(2048)) # about 219 T print(step_cost(4096)) # about 2,000 T
Chapter 4
Turn frames per second into metres travelled blind, and see how a faster 3D network earns its place on a car
A car at 72 km/h has a perception network that answers five times a second. Between answers the car moves 4 metres unseen. For a car, slow is unsafe.
Diffusion models also make 3D objects from one photo (One-2-3-45++, slide 28) and videos from text (slides 29 and 30). The slide quotes Imagen Video: video is harder, and performance is not yet saturated at 5.6 billion parameters. One CogVideoX step costs 332 T MACs.
Slide 31 shows an early Waymo car with "a whole trunk of workstation". Its key sensor, LiDAR, is a spinning laser that returns a point cloud: N points with x, y and z. The cloud is mostly empty, so sparse convolution computes only where points exist. NeRF and 3D Gaussian Splatting covers 3D scenes.
Slide 32 gives three speeds for one LiDAR task, against a 30 fps real-time line. A kernel is the low-level program for one operation on the chip.
| Network | Speed | Where the gain comes from |
|---|---|---|
| MinkowskiNet | 5 fps | "Too slow to drive" |
| MinkowskiNet with kernel optimization | 18 fps | 3.6 times from better kernels; the answers do not change |
| Fast-LiDARNet | 47 fps | 2.6 times more from algorithm and system co-design: the network and the software designed together |
Call the car's speed v (metres per second), the network's rate f (frames per second) and the distance between two answers d.
d equals v over f.
Divide the speed v by the frame rate f. The result d is how far the car moves before the network answers again.
At v = 20 m/s, MinkowskiNet (f = 5) gives d = 4.0 m. Fast-LiDARNet (f = 47) gives d = 0.43 m. The unseen stretch shrinks almost ten times.
Bars show frames per second against the 30 fps real-time line. Below, the length shows metres travelled between two outputs. Pick a network, then change the speed.
The frame rates 5, 18 and 47 fps and the 30 fps real-time line are from slide 32 (Fast-LiDARNet, Liu et al., ICRA 2021). Car speed is your choice; 20 m/s is 72 km/h. Distance is speed divided by frame rate, a simple estimate that ignores sensor delay.
At 40 m/s the slowest network leaves 8 m unseen, longer than a car.
BEVFusion (slide 33) turns camera and LiDAR features into one BEV (bird's-eye view) grid, a top-down map of shape C × H × W. That one grid feeds two heads: 3D object detection (car, truck, pedestrian, barrier) and map segmentation (drivable area, lane divider, walkway, crosswalk). The car pays for the expensive front half once.
Symptom: the model finds every pedestrian in testing, yet the car reacts late. Measure: at 5 fps the car travels 4.0 m between answers. Fix: set the frame budget first. At 30 fps one frame has 33.3 ms for sensing, the network and planning together.
pythondef blind_metres(speed_mps, fps): return speed_mps / fps # metres between two outputs for name, fps in [('Minkowski', 5), ('+kernels', 18), ('Fast-LiDARNet', 47)]: print(name, round(1000 / fps, 1), 'ms', round(blind_metres(20, fps), 2), 'm') # Minkowski 200.0 ms 4.0 m / +kernels 55.6 ms 1.11 m / Fast-LiDARNet 21.3 ms 0.43 m
Chapter 5
Follow a translation model from 176 MB to 9.7 MB with almost no loss, and see how pruning words saves attention work
You open a chat assistant and it says it is at capacity. Slide 35 shows that screen, and one that caps GPT-4 at 50 messages every 3 hours. Every answer is expensive, so the provider rations it.
A large language model (LLM) predicts the next word, after training on huge amounts of text. The slides show GitHub Copilot suggesting code (36) and translation on a phone (37). Two skills grow with size:
Both come "at the cost of large model size". Slide 44 (FP16) runs from 0.05B parameters in 2017 to MT-NLG's 530B, 10,600 times more. GPU memory grew 5 times, to the A100's 80 GB. MT-NLG's weights alone are 1,060 GB.
Slide 38 follows English to French translation. BLEU scores a translation by counting short word sequences that match a human reference; higher is better. The original Transformer is 176 MB at 39.9 BLEU. The Lite Transformer, with a lighter attention design, is 69.2 MB at 39.6.
Pick a stage. Top bars show model size in MB. The dots below show the BLEU score on a zoomed axis, so small drops look large.
Sizes and BLEU are from slide 38 (Lite Transformer, Wu et al., ICLR 2020), English to French. The slide's factors are 2.5x, 4.0x and 1.8x, and 18.2x overall. Our readings of what each step does (32-bit to 8-bit numbers; about 44% of weights removed) come from our arithmetic on those sizes.
Quantization takes 69.2 MB to 17.3 MB, exactly 4 times: the step from 32-bit to 8-bit numbers. Pruning takes 17.3 MB to 9.7 MB, so about 44% of the weights go. The model ends 18 times smaller, and BLEU falls only from 39.9 to 39.5.
SpAtten (slide 45) drops unimportant tokens as a sentence climbs the layers. For "As a visual treat, the film is almost perfect.", layer 1 reads 11 tokens with 12 attention heads (parallel attention units). Layer 2 keeps 5 tokens and 10 heads. Layer 3 keeps "film perfect" and 8 heads.
Cost follows tokens times heads: 5 × 10 / (11 × 12) = 38% and 2 × 8 / 132 = 12%, as the slide labels. SpAtten adds each token's attention probabilities down its column and drops the small sums. In the code below, sums of 0.4, 1.5, 0.6 and 0.5 keep tokens 1 and 2.
Symptom: the compressed translator garbles names and numbers. Measure: you cut 18 times and never ran BLEU. Fix: measure quality after every step, as the lecture's ladder did (0.4 BLEU lost in all), and stop when the drop matters.
pythonimport numpy as np attn = np.array([[.1, .6, .2, .1], [.2, .5, .1, .2], [.1, .4, .3, .2]]) # (queries, tokens) score = attn.sum(axis=0) # cumulative importance per token: [.4 1.5 .6 .5] keep = np.argsort(score)[::-1][:2] # keep the 2 best tokens: [1 2] print(sorted(keep.tolist()), 2 * 8 / (11 * 12)) # cost share of layer 3, about 0.12
Chapter 6
Learn why a token costs one pass over the weights, and how 4-bit storage turns a 13B model into a 30 token per second chat
On a plane with no internet, or in a hospital that keeps patient text private, the model must run on your own hardware.
A chat model makes one token (a word piece) at a time. For each token the chip reads every weight once and uses it in one multiply-add. So data movement, not arithmetic, sets the speed: the model is memory-bound.
Call the bytes per second the chip reads, its memory bandwidth, BW. Call the weight size from chapter 0 model bytes.
Tokens per second is at most B-W over model bytes.
Divide BW by the model bytes. That is how many passes over the weights the chip makes each second, and each token needs one pass.
With a made-up BW of 200 GB/s: 7B at 16 bits is 14 GB, so at most 200 / 14 = 14 tokens per second. At 4 bits it is 3.5 GB, so at most 57.
Top bar: the weights against the roughly 7 GB a small edge board has free. Bottom bar: the upper limit on tokens per second at your chosen bandwidth.
The 7 GB free memory is from slide 48 (a Jetson Orin board with about 7 GB available). Bandwidth is illustrative: pick any value. The slide's measured speeds are 30 tokens/s for LLaMA-2-7B and 17 for 13B at W4A16 on Orin, and 50 versus 166 tokens/s for 7B on an RTX 4090, FP16 versus AWQ. The limit ignores compute, caches and the attention cache.
13B at 4 bits is 6.5 GB, under the roughly 7 GB free on a Jetson Orin (slides 48 and 51).
W4A16 means 4-bit weights and 16-bit activations. Activations are hard to quantize: a few huge outliers stretch the one shared scale, so small values lose precision (slide 47).
SmoothQuant divides each activation channel by a factor and multiplies the matching weight row by it, so their product stays the same. Toy numbers: activation maxima 1 and 64, weight maxima 1, factors 1 and 8. The INT8 activation scale falls from 64 / 127 = 0.50 to 8 / 127 = 0.063.
AWQ (activation-aware weight quantization) protects the weight channels that meet large activations. On slide 56 its 4-bit VLM names da Vinci as the Mona Lisa's painter; plain rounding (INT4-g128 RTN) does not.
| Engine and board | Measured |
|---|---|
| TinyChatEngine (47) | C and C++ from scratch, easy to install and move to edge platforms |
| TinyChat on Jetson Orin (50, 51) | LLaMA-2-7B at W4A16: 30 tokens/s. 13B: 17 tokens/s |
| TinyChat on RTX 4090 (52) | 7B: 50 tokens/s at FP16, 166 with AWQ (3.3x), 195 in exLLaMA's setting. 3.3x is 83% of the ideal 4x: the attention cache and 16-bit activations do not shrink. All-Python interface |
Symptom: the 8-bit model gives odd answers. Measure: at the toy scale of 0.50, an activation of 0.3 rounds to 0.50, a 68% error. At the smoothed scale of 0.063 it rounds to 0.315, a 5% error. Fix: smooth outliers first, or keep activations at 16 bits.
pythondef max_tokens_per_s(params_b, bits, bw_gbs): model_gb = params_b * bits / 8 # billions of params x bytes = GB return bw_gbs / model_gb # one pass over the weights per token print(max_tokens_per_s(7, 16, 200)) # 14.3 print(max_tokens_per_s(7, 4, 200)) # 57.1, four times higher
Chapter 7
Trace a picture into visual tokens, see which parts VILA trains at each stage, and check a robot's 15 Hz budget
You point your phone at a street sign in a foreign language and ask if you can park there. One model must read the picture and your question, then answer in words. A multimodal model handles more than one kind of input.
LLaVA (slide 55) answers questions about images, with a 13B LLaMA as its language half. Asked who drew the Mona Lisa, it names Leonardo da Vinci. VILA's diagram (slide 57) shows the plumbing:
Shapes: a 336 by 336 picture in 14 pixel patches gives 24 × 24 = 576 patches. The ViT outputs 576 × Dv, and the projector makes 576 × D, where D is the LLM's width. The LLM holds 576 tokens before you type a word. More in vision-language models and LLaVA 1.5.
VILA trains in three stages. Each block is either frozen, with fixed weights, or trained.
Blocks in colour are being trained. Grey blocks are frozen. Pick a stage.
The stages and which blocks are trained follow the VILA diagram on slide 57 (Lin et al., CVPR 2024): the vision encoder stays frozen, the projector trains in every stage, and the LLM is frozen only in stage 0. The parameter counts (ViT 0.3B, projector 0.02B, LLM 7B) are illustrative round numbers, not the paper's.
Stage 0 trains only the projector. Stage 1 unfreezes the LLM on interleaved image and text documents. Stage 2 is joint SFT (supervised fine-tuning) on image tasks plus text-only data. The slide's five findings:
Slides 58 to 63 show VILA describe a soccer goal and predict a strawberry smoothie and spices ground in a mortar. It answers "San Francisco" after Boston and Toronto, and names Pompeii.
AWQ keeps a 4-bit VLM answering well (slide 56), and VILA runs on a MacBook M1 CPU (slide 64). A vision-language-action model (VLA) reads camera images and an instruction, and outputs robot actions. Slides 65 and 66 show an arm playing ping-pong and ForeAct with π0.5, both at 15 Hz on a laptop RTX 5090. The VLA lesson covers these models.
15 Hz is a frame budget: 1,000 ms / 15 = 66.7 ms for the camera, the model and the motor command together. Miss it and the arm lags behind the ball.
Symptom: your VLM describes pictures but forgets plain text questions and cannot learn from examples in the prompt. Measure, as the slide reports: pairs alone lose in-context learning and text-only skill. Fix: unfreeze the LLM, use interleaved data, and blend text-only data back in.
pythondef vlm_forward(image, text_ids, vit, projector, llm, embed): patches = vit(image) # (N, Dv): one vector per image patch vis_tokens = projector(patches) # (N, D): into the LLM's word space txt_tokens = embed(text_ids) # (T, D): embeddings of the prompt row = torch.cat([vis_tokens, txt_tokens]) # (N + T, D): one row of tokens return llm(row) # next-token scores # 336 px image, 14 px patches: N = 24 * 24 = 576 visual tokens before any text
Chapter 8
See what the great results cost, how chips learned to love fewer bits, and how large the gap to a tiny device still is
AlphaGo beat Lee Sedol 4 to 1 with 1,920 CPUs and 280 GPUs, at $3,000 of electricity per game. AlphaFold (Nature 2021) used 16 TPUv3s (128 cores) for a few weeks. Neither fits in a pocket.
Deep learning stands on algorithm (the ideas and network designs), hardware (the chips) and data (slides 69 and 78). Slide 71 shows why the course focuses on algorithms and software. Chip design cost rises with each node, from $28.5M at 65 nm to $542.2M at 5 nm: 19 times. In the 5 nm bar, software is the largest slice.
Slide 70 shows that chips built for lower precision and sparsity jump in speed: FP32 to FP16 to INT8 (8-bit whole numbers), dense to sparse. The chart counts INT8 TOPS, trillions of operations per second, for one chip.
Each bar is one chip's single-chip inference performance in TOPS, on a log scale. Slide to add the next generation.
Values are read from slide 70, Bill Dally's chart of single-chip inference performance: K20X 3.94, M40 6.84, P100 21.20, V100 125.00, Q8000 261.00, A100 1,248.00 TOPS. The slide labels the trick at each step: scalar FP32, FP16 and 4-element 8-bit dot products (DP4A), half-precision matrix multiply (HMMA), 8-bit integer matrix multiply (IMMA), and structured sparsity on A100. Our assignment of a label to a chip follows the chart's layout.
The K20X manages 3.94 TOPS with scalar FP32. The A100 with structured sparsity reaches 1,248: 317 times in 8 years. Smaller numbers, matrix units and skipped zeros all mean less work per answer.
| Chip | Dense FP16 TOPS | Memory bandwidth | Memory |
|---|---|---|---|
| P100 (2016) | 18.7 | 732 GB/s | 16 GB |
| V100 (2017) | 125 | 900 GB/s | 32 GB |
| A100 (2020) | 312 | 2,039 GB/s | 80 GB |
| H100 (2022) | 990 | 3,350 GB/s | 80 GB |
| B100 (2024) | 1,750 | 8,000 GB/s | 192 GB |
| Rubin (2026) | 4,000 | 22,000 GB/s | 288 GB |
From P100 to Rubin, compute grew 214 times but bandwidth only 30 times and memory 18 times (slide 72). A chip multiplies far faster than it fetches weights, so fewer bytes help even when arithmetic is plentiful.
Edge chips are smaller again (slides 73 to 76):
| Edge family | Range on the slides |
|---|---|
| NVIDIA Jetson (Nano to AGX Thor) | 0.5 to 1,035 TOPS; up to 128 GB |
| Qualcomm Hexagon DSP (S845 to S8G1) | 3 to 52 TOPS |
| Apple Neural Engine (A11 to A17) | 0.6 to 35 TOPS |
| Microcontrollers (Arduino Zero to STM32 F746NG) | 32 KB to 320 KB of memory |
| Slide 77 | Cloud AI | Mobile AI | Tiny AI |
|---|---|---|---|
| Memory (activations) | 80 GB | 4 GB | 320 kB |
| Storage (weights) | TB to PB | 256 GB | 1 MB |
80 GB over 320 kB is 250,000 times. The course lives in that gap. Slides 79 and 80 set today's deep learning (a lot of computation, carbon, engineers and data) against tiny deep learning, which needs less of each.
Symptom: you buy a 4,000 TOPS chip and your model barely speeds up. Measure: bandwidth grew 30 times while TOPS grew 214, and a memory-bound model sees the 30. Fix: cut bytes with quantization and pruning, and check which resource limits you before you shop.
pythonchips = {'P100': (18.7, 732, 16), 'Rubin': (4000, 22000, 288)} # TOPS, GB/s, GB a, b = chips['P100'], chips['Rubin'] print([round(y / x, 0) for x, y in zip(a, b)]) # [214.0, 30.0, 18.0]: compute outruns memory
Chapter 9
Find where each later lesson sits, learn the three questions that guide every choice, and see what you will build
Every chapter hit one wall: the model is too big, too slow or too hungry. Slides 81 to 91 put the answers in order.
The overview (slides 83 to 86) stacks three boxes:
On the sides sit system (software and hardware) and algorithm (design and training). The course stands between them, because co-design beats polishing either alone. Tags for EE, CS and AI+D mark its roots, and intro machine learning is a prerequisite.
The three boxes are the course's three parts. Pick one and read which lessons teach it.
The three parts and their topics are from slides 83 to 85. The lesson lists are this series' own mapping of lectures to parts, so the grouping is ours. Lab names are from slide 89.
Ask three things: the bytes you store, the MACs you compute, and the MACs you get per byte you move. The third decides whether a chip works or waits.
Take one layer that multiplies a weight matrix of R rows and C columns by n input vectors at once (the batch). Each weight has b bits. Call the MACs per byte of weights read the arithmetic intensity, I.
I equals R times C times n, over R times C times b over 8, which is 8 n over b.
Every weight meets all n vectors, so the MACs are R times C times n. The chip reads every weight once. Divide, and the matrix size cancels.
A 4,096 by 4,096 layer at b = 16 and n = 1: 16,777,216 MACs over 33,554,432 bytes, so I = 0.5. At n = 64, I = 8 × 64 / 16 = 32. The chip waits in the first case and works in the second.
pythondef macs_per_byte(rows, cols, bits, batch): macs = rows * cols * batch # one MAC per weight per input vector bytes_moved = rows * cols * bits / 8 # weights read once per layer call return macs / bytes_moved print(macs_per_byte(4096, 4096, 16, 1)) # 0.5 print(macs_per_byte(4096, 4096, 16, 64)) # 32.0
Lab 0 is a PyTorch warm-up. Labs 1 to 5 cover GPU basics, pruning, architecture search, quantization, and a quantized LLM chatbot on your laptop. Lab 5 needs 8 GB of memory and 5 GB of storage on macOS, Linux or Windows (x86 or Apple M1/M2).
| Part | Weight | Detail |
|---|---|---|
| Labs 1 to 5 | 14% each | 6 late days in total, then 50% off per late day; zero credit 2 days past the limit |
| Project proposal | 5% | Groups of 3 or 4 |
| Presentation and final report | 25% | Past projects: keyword spotting with distillation and quantization, rowing analytics on a phone, TinyEngine kernels |
Work is due at 11:59 PM, and the rules have no exceptions. The five takeaways (slide 91):
Symptom: you remove half the weights and the GPU runs no faster. Measure: a normal kernel still multiplies the zeros, so its MACs did not change. Fix: use a pattern the hardware skips, such as 2:4 sparsity on NVIDIA's Ampere Sparse Tensor Core (slide 5).
Chapter 10
Review the numbers, the terms and the code, then use the checklist on the next model you meet
Models grew far faster than the chips that hold them, and compression closes the gap. Each kind of model pays a different bill and needs a different cure.
A model's weight size is parameters × bits / 8, and you count its work in MACs. Training also stores every layer's activations and a gradient per weight. A chat model reads all its weights once per token, so it is memory-bound: fewer bytes mean faster tokens.
Pruning removes weights, quantization stores them with fewer bits, and architecture search finds cheaper shapes. Real-time work, such as driving at 30 fps or a robot at 15 Hz, has a frame budget. Measure bytes, MACs, MACs per byte moved, and quality, in that order.
| What | Number | Why it matters |
|---|---|---|
| GPT-3, 175B parameters | 350 GB at 16 bits; 87.5 GB at 4 bits; 78.75 GB with 10% removed | Bits and pruning stack (Ch 0) |
| Model size against GPU memory | 0.05B to 2,700B against 16 GB to 288 GB | The gap compression bridges (Ch 0) |
| One 3x3 layer, 56x56, 64 to 128 channels | 231,211,008 MACs; separable 27,496,448 | 8.4 times fewer for the same shape (Ch 1) |
| ImageNet top-5 error | 3.6% in 2015 against human 5.1% | Accuracy passed humans; cost did not fall (Ch 1) |
| Once-for-All | 595M MACs, 80.0% top-1, 14 times less compute | Search finds cheap shapes (Ch 1) |
| Training memory on a microcontroller | 652 MB down to 141 KB; limit 256 KB | Three ideas make training fit (Ch 2) |
| Diffusion step, 1,024 to 4,096 pixels | 37.2 T to about 2,000 T MACs | Cost outruns pixels (Ch 3) |
| EfficientViT-SAM on A100 | 11 to 182 images per second | Fix the heavy encoder (Ch 3) |
| LiDAR network at 20 m/s | 5, 18, 47 fps: 4.0, 1.11, 0.43 m between answers | Slow means unsafe (Ch 4) |
| Lite Transformer | 176 MB to 9.7 MB; BLEU 39.9 to 39.5 | 18 times smaller, almost no loss (Ch 5) |
| 13B model at 4 bits | 6.5 GB; 200 GB/s gives at most 30.8 tokens/s | Bytes set chat speed (Ch 6) |
| AWQ on RTX 4090, 7B | 50 to 166 tokens/s, 3.3 times | 83% of the ideal 4 times (Ch 6) |
| Image to LLM tokens | 336 px, 14 px patches: 576 visual tokens | Pictures cost tokens (Ch 7) |
| Robot policy on laptop | 15 Hz is 66.7 ms per step | A frame budget (Ch 7) |
| K20X to A100 inference | 3.94 to 1,248 TOPS: 317 times | Hardware loves low precision (Ch 8) |
| Cloud against tiny memory | 80 GB against 320 kB: 250,000 times | The gap to close (Ch 8) |
| 4,096x4,096 layer, 16 bits | I = 8n / b: 0.5 MAC per byte at batch 1; 32 at batch 64 | Why batch size matters (Ch 9) |
| Term | Plain meaning | Where |
|---|---|---|
| Parameter, weight | One learned number in the model | 0 |
| FP16, INT8 | A 16-bit float; an 8-bit whole number | 0, 8 |
| MAC | One multiply plus one add, the unit of neural network work | 1 |
| Top-5 error | How often the right label is outside the five best guesses | 1 |
| Neural architecture search | A program that tries network shapes and keeps good ones | 1 |
| Activation | The data flowing between layers | 2 |
| Gradient | The number that says how to nudge a weight | 2 |
| Segmentation mask | A picture that marks which pixels are an object | 3 |
| Diffusion model | Makes images by cleaning noise in many steps | 3 |
| Frame budget | The time one answer may take at the required rate | 4, 7 |
| LiDAR, BEV | A laser range sensor; a top-down map grid | 4 |
| Zero-shot, few-shot | A task done from words alone; from words plus a few examples | 5 |
| BLEU | A translation score; higher is better | 5 |
| Memory-bound | Limited by moving data, not by arithmetic | 6 |
| W4A16 | 4-bit weights with 16-bit activations | 6 |
| Visual token, projector | An image patch as a token; the adapter that makes them | 7 |
| VLA | A model that reads images and words and outputs robot actions | 7 |
| 2:4 sparsity | Two of every four weights are zero, a pattern chips can skip | 0, 9 |
| Co-design | Designing the algorithm and the system together | 4, 9 |
Every formula of the lecture fits in a few lines. Comments give units and shapes.
pythonimport numpy as np def weight_bytes(params, bits, removed=0.0): # bytes, no index overhead return params * (1 - removed) * bits / 8 def conv_macs(h, w, c_in, c_out, k, separable=False): if not separable: return h * w * c_out * c_in * k * k return h * w * c_in * (k * k + c_out) # depthwise + pointwise def peak_memory(weights, acts, training): # acts: size of each layer's activation if not training: return weights + max(a + b for a, b in zip(acts, acts[1:])) return weights + sum(acts) + weights # all activations + gradients def max_tokens_per_s(params_b, bits, bw_gbs): # memory-bound decoding return bw_gbs / (params_b * bits / 8) def blind_metres(speed_mps, fps): # distance between two outputs return speed_mps / fps def macs_per_byte(rows, cols, bits, batch): return rows * cols * batch / (rows * cols * bits / 8) def smooth_scales(act_max, w_max): # SmoothQuant-style factor per channel, (C,) return np.sqrt(act_max / w_max) def keep_tokens(attn, n): # attn (queries, tokens) -> kept token ids return np.sort(np.argsort(attn.sum(0))[::-1][:n])
Run them on the worked examples. You get 350 GB; 231,211,008 and 27,496,448 MACs; 180 and 320 KB; 14.3 and 57.1 tokens per second. Then 4.0 and 0.43 metres, 0.5 and 32 MACs per byte, and the factors 1 and 8.
This lecture is the map. Lecture 2 builds the network pieces whose costs you now know how to count. Pruning, quantization, search, distillation, and the two tiny-systems lessons, MCUNet and TinyEngine, then supply the cures. The LLM lessons return to the memory-bound view of chapter 6.
This lesson follows Lecture 1 of MIT 6.5940, TinyML and Efficient Deep Learning Computing (Fall 2026), taught by Song Han and the MIT HAN Lab. Read the lecture on the course site, which links the lecture slides. The works the lecture cites include Once-for-All, MCUNet and MCUNetV3, EfficientViT-SAM, GAN Compression, Anycost GAN, SIGE, DistriFusion, SVDQuant, Fast-LiDARNet, BEVFusion, Lite Transformer, SpAtten, SmoothQuant, AWQ, TinyChat, LLaVA, VILA, AlphaGo and AlphaFold. All explanations, devices and examples here are our own, and the toy numbers say so where they appear.
Now press Teach and explain why a 13 billion parameter model can chat on a small board at 4 bits but not at 16. Then go back to the model at the top and find the cheapest setting that fits a phone.