COE 592Lecture 01Full guide
Why efficient deep learning
The whole lecture on one page, taught concept by concept. Work through the parts in order, mark each concept once you understand it, and open the slide chips when you want the original slides.
- Parts
- 3
- Concepts
- 15
- Slides
- 24
- Reading
- 90 min
Part 01: Accuracy comes at a cost
Deep learning now beats humans on ImageNet, but every accuracy gain was paid for in computation and model size, and efficient design (NAS, MCUNet, on-device training) is what brings it to phones and IoT devices.
6 concepts, slides 1-8
Why this part matters
Every later part of this lecture, from segmentation and diffusion models to LiDAR, language models, accelerators and microcontrollers, is a response to one trade-off introduced here: accuracy is bought with computation and memory, and the devices you want to deploy on cannot pay the bill.
This part builds that trade-off from the ground up. You will learn to read the two charts that anchor the whole course (top-5 error over the ImageNet years, then top-1 accuracy against MACs and parameters), to compute the reduction ratios that headline efficient-model papers, and to argue why efficiency matters for privacy, cost and connectivity and not only for speed. The exam asks exactly these things, and your own embedded ML research lives on the frontier the last two concepts describe.
By the end you can
- State the course challenge and name the three pillars, with one efficiency lever per pillar.
- Define top-5 error and top-1 accuracy precisely and explain why they cannot be compared directly.
- Read a bubble chart of top-1 accuracy versus MACs and parameters, and quantify diminishing returns.
- Compute a computation reduction ratio and explain the Pareto frontier shift produced by architecture search.
- Explain why TinyML and on-device training are hard, using the memory tiers and the cost of backpropagation.
Open the camera on your phone and it finds faces before you press anything. Ask a speaker a question and a language model answers. Paste a screenshot into a chatbot and it reads the text and the picture together. Vision, language and multimodal tasks are all served today by deep networks, and every one of those answers costs billions of arithmetic operations. Classifying a single image with ResNet-50 takes about 3.9 billion multiply-accumulate operations (Sze et al., 2017), and that is a model from 2015 doing the easiest of the three tasks.
That is the whole tension of this course, and slide 2 states it in one line. Machine learning (ML) and deep learning are applied everywhere, they are computationally expensive, and the challenge is to make them lightweight and fast without losing accuracy. Every technique you will learn, from pruning and quantization to architecture search, hardware accelerators and tiny Inference engines, is one answer to that single question. It helps to write the question the way an optimization course would: keep accuracy as high as possible while staying under whatever budget the target device imposes.
The budgets are what change from device to device. A cloud GPU has a generous C and M; a phone has a tight Latency T and a battery; a sensor node has a memory M measured in kilobytes. The accuracy you can afford depends on which row of that constraint list binds, and part 03 puts real numbers on each row.
Three pillars, one lens for the whole course
Slide 3 gives you the lens to organize everything that follows: deep learning advances when three things improve together. Its three pillars are the algorithm (the model and how it is trained), the hardware it runs on, and the data it learns from. None of them is enough alone. The 2012 breakthrough on ImageNet, which the next concept quantifies, needed all three at once: a new deep convolutional architecture, two GPUs able to run it for a week, and a dataset of about 1.2 million labeled images (Krizhevsky et al., 2012).
| Pillar | Contribution to AlexNet in 2012 | Efficiency lever in this course |
|---|---|---|
| Algorithm | A deep CNN with ReLU units and dropout, trained with SGD on two GPUs | Pruning, quantization, distillation, neural architecture search (pruning starts in lecture 04) |
| Hardware | Two GTX 580 GPUs, 3 GB each, running the convolutions for about six days | Accelerators from cloud GPUs to phone NPUs and microcontrollers (part 03) |
| Data | ImageNet: about 1.2 million labeled training images in 1000 classes | Data that stays on the device and drives local, private learning (slide 8) |
The same three words tell you where efficiency work happens. Compressing, quantizing and searching for architectures are algorithm-pillar work: the model changes, the chip does not. Building accelerators, from data-center GPUs down to the Hexagon DSP and the Neural Engine, is hardware-pillar work: the chip changes so that the same model runs faster or cooler. The deck returns to this exact slide as slide 17 to open the hardware section, so treat slide 3 as the introduction of the framework and slide 17 as the pivot to its second pillar. The data pillar makes its own appearance on slide 8, where data that cannot leave a device forces learning to happen on the device.
Why efficiency matters beyond speed
Speed is the obvious reason to want small models, but the exam will ask for more, and the deck gives you at least four. Privacy: a model that fits on the device can process a face or a voice without uploading it. Cost: training and serving large models is billed in GPU hours and, increasingly, in carbon. The Once-for-All paper notes that training a separate specialized network for every deployment target emits as much CO2 as five cars over their lifetimes (Cai et al., 2020). Connectivity: sensors in fields, mines and rural clinics may have no network at all, and MCUNet argues that on-device processing extends AI to areas without Internet access (Lin et al., 2020). Energy: a battery-powered node has a milliwatt budget, and every unnecessary multiply drains it.
- Privacy: raw data stays where it was collected.
- Cost: fewer GPU hours, smaller cloud bills, less carbon.
- Connectivity: the model works where the network does not.
- Energy: milliwatt devices need models sized for milliwatts.
Recall
State the three pillars and name one efficiency lever for each.
Look at the left panel of slide 4 before the bar chart. It shows six test images (a crop of the eight in the AlexNet paper) with the five classes AlexNet ranked highest for each. For the mushroom photo the top guess is "agaric" and the true label "mushroom" sits second. For the cherry photo the top guess is "dalmatian", followed by grape, elderberry, a bull terrier and currant; "cherry" is nowhere in the list. Under one scoring rule the mushroom counts as correct and the cherry does not; under another rule both are wrong. Which rule you use decides every number on the right of the slide.
The rule the contest used is Top-5 error rate. The ImageNet challenge (ILSVRC) let each algorithm return five labels per image and counted the image as correct if any one of them matched the single ground-truth label; the error is the fraction of test images with no match (Russakovsky et al., 2015, Eq. 1). The organizers allowed five guesses because ImageNet photos often contain several objects but carry only one label, and a system that names a visible second object should not be punished. From 2012 the contest reported only top-5 error, since all their measures ranked entries the same way.
The other rule, Top-1 accuracy, keeps only the single highest-scoring class and counts the fraction of images where it matches. It is stricter, so the same model always scores worse on top-1 than on top-5. Slides 5 and 6 use top-1 accuracy; slide 4 uses top-5 error. Keeping the two apart is the single most common slip in reading this part of the deck.
The same AlexNet predictions under both rules
- Mushroom (top guess agaric, mushroom second)
- Top-5 hit, top-1 miss
- Cherry (top guess dalmatian, cherry absent)
- Top-5 miss, top-1 miss
- Container ship (top guess container ship)
- Top-5 hit, top-1 hit
Eight years of the winning entry
With the metric fixed, the bar chart reads as a history. The winning top-5 error went from 28.2% in 2010 and 25.8% in 2011 to 16.4% in 2012, when SuperVision, the entry now called AlexNet, was the first deep convolutional network to win. The error kept falling as the networks deepened: Clarifai at 11.7% in 2013, GoogLeNet at 6.7% in 2014, ResNet at 3.57% in 2015 with an ensemble of residual networks up to 152 layers deep (He et al., 2016), Trimps-Soushen at 2.99% in 2016 and SENet at 2.25% in 2017 (Hu et al., 2018). The slide rounds those to one decimal.
| Year | Winner | Top-5 error (%) | Source |
|---|---|---|---|
| 2010 | NEC | 28.2 | Russakovsky et al., Table 5 |
| 2011 | XRCE | 25.8 | Russakovsky et al., Table 5 |
| 2012 | SuperVision (AlexNet) | 16.4 | Russakovsky et al., Table 5 |
| 2013 | Clarifai | 11.7 | Russakovsky et al., Table 6 |
| 2014 | GoogLeNet | 6.7 | Russakovsky et al., Table 7 |
| 2015 | ResNet (ensemble of six models, deepest 152 layers) | 3.6 (3.57) | He et al., 2016 |
| 2016 | Trimps-Soushen | 3.0 (2.99) | ILSVRC 2016 results |
| 2017 | SENet (WMW) | 2.3 (2.25) | Hu et al., 2018 |
| Human | One trained annotator | 5.1 | Russakovsky et al., Sec. 6.4 |
Worked example
Reading the drop
The deep learning break
2011 to 2012: 25.8 - 16.4 = 9.4 percentage points, a relative reduction of 9.4 / 25.8 = 36% in one year, after the previous year had removed only 2.4 points.Two more years of depth
2012 to 2014: 16.4 / 6.7 = 2.45x lower error with GoogLeNet, a 22-layer network (Szegedy et al., 2015).Crossing the human line
ResNet's 3.57% in 2015 is the first winning entry below the 5.1% human estimate, and by 2017 the gap is 5.1 - 2.25 = 2.85 points in the machine's favor.Result
Over eight years the winning error fell from 28.2% to 2.3%, about 12x lower, and nearly all of it came after the switch to deep networks.
What "super-human" actually means here
The human bar is not an average person. It is one expert annotator who trained on 500 images and then labeled 1500 test images at roughly one per minute, reaching 5.1% top-5 error; a second annotator with less training scored 12.0%, and GoogLeNet scored 6.8% on the same sample (Russakovsky et al., 2015, Sec. 6.4). So "DNNs achieve super-human accuracy" means that from 2015 the winning network beats a well-trained, patient human on the top-5 rule for 1000 fine-grained classes, many of them dog breeds. It says nothing about general vision, and it says nothing about top-1.
Quick check
In ILSVRC top-5 evaluation, when does one image count as correctly classified?
Recall
Define top-5 error precisely. Is the mushroom image, with top guess agaric and mushroom second, a top-5 hit? Is the cherry image?
Take two models from the same family. ResNet-50 needs about 3.8 billion multiply-adds per image and ResNet-101 about 7.6 billion, twice as many (He et al., 2016, Table 1). On slide 5 they sit at about 75.3% and 76.4% top-1 accuracy. Doubling the work bought about one percentage point. That one pair is the message of the slide: high accuracy comes at the cost of high computation, and the exchange rate gets worse as you climb.
To read the chart you need its currency. The horizontal axis counts MACs, multiply-accumulate operations: one multiplication of an input by a weight, immediately added into a running sum. Sze and colleagues call the MAC "the fundamental component" of both convolutional and fully connected layers (Sze et al., 2017). Counting MACs gives a hardware-neutral cost: the number is a property of the model and the input size, not of the chip, unlike latency or energy which change with every device. A convolutional layer's count follows directly from its shape.
Worked example
One 3 by 3 layer
Shape
A 3 x 3 convolution with 64 input and 64 output channels producing a 56 x 56 map.Multiply out
56 x 56 x 64 x 64 x 9 = 115,605,504 MACs.Result
About 0.116 GMACs for a single layer. ResNet-50 has dozens of such layers, which is how it reaches 3.9 GMACs per image.
How to read a bubble chart
Three quantities share the chart. Horizontal position is cost in billions of MACs, so left is cheaper. Vertical position is Top-1 accuracy on ImageNet, so up is better. Bubble area is Model size, the number of parameters, from 2 M to 64 M according to the legend. Parameters measure storage (how many bytes the weights occupy) and MACs measure work (how many operations each input triggers), and the two are related but not the same. Circles are handcrafted architectures and stars are found by AutoML, which becomes important on the next slide. The goal region is the upper left: high accuracy at low cost.
| Model | MACs (B) | Top-1 (%) | Parameters | Where the number comes from |
|---|---|---|---|---|
| MobileNetV1 | 0.57 | 70.6 | 4.2 M | paper (Howard et al.) |
| IGCV3-D | 0.3 | 72.3 | about 3.5 M | chart |
| InceptionV2 | 2.0 | 74.8 | about 11 M | chart |
| DenseNet-121 | 2.9 | 75.0 | about 8 M | chart |
| DenseNet-169 | 3.4 | 76.2 | about 14 M | chart |
| ResNet-50 | 3.9 | 75.3 | 25.5 M | MACs and params from Sze et al., accuracy from the chart |
| ResNeXt-50 | 4.2 | 77.8 | about 25 M | chart |
| DenseNet-264 | 5.7 | 77.8 | about 33 M | chart |
| InceptionV3 | 5.7 | 78.8 | about 24 M | chart |
| DPN-92 | 6.5 | 79.3 | about 38 M | chart |
| ResNet-101 | 7.6 | 76.4 | 44.5 M | MACs from He et al. (Table 1); parameters from torchvision |
| ResNeXt-101 | 8.0 | 78.9 | about 44 M | chart |
| Xception | 8.4 | 79.0 | about 23 M | params from Chollet |
Diminishing returns
Trace the chart from the cheapest model upward and the exchange rate collapses. For each step, divide the accuracy gained by the extra MACs spent. MobileNetV1 is the cheap starting point at 70.6% for 0.57 B MACs (Howard et al., 2017); every other number below is read from the chart.
| Upgrade | Extra MACs (B) | Extra top-1 (points) | Points per billion MACs |
|---|---|---|---|
| MobileNetV1 to ResNet-50 | 3.9 - 0.57 = 3.33 | 75.3 - 70.6 = 4.7 | 4.7 / 3.33 = 1.41 |
| ResNet-50 to Xception | 8.4 - 3.9 = 4.5 | 79.0 - 75.3 = 3.7 | 3.7 / 4.5 = 0.82 |
| ResNet-50 to ResNet-101 | 7.6 - 3.9 = 3.7 | 76.4 - 75.3 = 1.1 | 1.1 / 3.7 = 0.30 |
The marginal value of computation falls almost fivefold across the chart, from 1.41 to 0.30 points per billion, and the worst trade is inside a single family. Notice also that Xception is itself dominated: DPN-92 is more accurate (79.3%) with fewer MACs (6.5 B).
Quick check
On slide 5, which quantity does the area of each bubble encode?
Now put the stars back on the chart. Once-for-All (OFA) reaches 80.0% top-1 with 595 M MACs (Cai et al., 2020). Xception, the most expensive handcrafted model on the previous slide and within 0.3 points of the most accurate (DPN-92), needed about 8.4 B for 79.0%. Divide and you get 8400 / 595 = 14.1: the same accuracy, or one point more, for one fourteenth of the computation. That is the dashed arrow at the top of slide 6, and it is drawn straight from Figure 2 of the Once-for-All paper.
Worked example
Reduction ratios
Convert to one unit
Xception 8.4 B = 8400 M MACs; ResNet-50 3.9 B = 3900 M; Once-for-All 595 M.Divide reference by new
8400 / 595 = 14.1 and 3900 / 595 = 6.6.Result
Once-for-All needs 14x less computation than Xception and 6.6x less than ResNet-50 while being more accurate than both.
| Model | MACs (B) | Top-1 (%) | Reduction relative to OFA |
|---|---|---|---|
| MobileNetV1 | 0.569 | 70.6 | 0.96x (about the same budget) |
| ResNet-50 | 3.9 | 75.3 | 6.6x |
| Xception | 8.4 | 79.0 | 14.1x |
| Once-for-All | 0.595 | 80.0 | 1x (reference) |
The MobileNetV1 row makes the point from the other side: at essentially the same budget, the searched model is 9.4 points more accurate. The stars are all products of Neural architecture search (NAS): rather than a person choosing kernel sizes, widths and depths, an algorithm searches over them under an explicit MAC or latency budget. EfficientNet, NASNet-A, MobileNetV3, ProxylessNAS, AmoebaNet, PNASNet and DARTS all sit inside the boxed region below about 2.5 B MACs, next to two efficient handcrafted models, MobileNetV2 and ShuffleNet. Once-for-All adds one more idea: train a single large network once, then cut specialized sub-networks out of it for each device, which is what makes the 80.0% at 595 M affordable to produce as well as to run.
The frontier and why it moves left
The two arrows on the slide, "the higher the better" and "the lower the better", state the accuracy-efficiency trade-off as a partial order. Model A dominates model B if A is at least as accurate and at most as costly, with one of the two strictly better. The models nobody dominates form the Pareto frontier, the staircase you saw in the last visual. Every point below or to the right of it is a worse deal than something already available. Architecture search did not just add good models; it moved the entire staircase left, so that the best accuracy at 0.6 B MACs today exceeds the best at 8 B a few years earlier.
- Selected
- IGCV3-D
- Baseline
- ResNet-50
- Parameters
- 3.5 M
- Source
- read from the chart
The dashed staircase is the Pareto frontier of the visible set: a point stays on it only when no other visible model has both higher accuracy and fewer MACs. Switch from Handcrafted to AutoML and watch the frontier jump left. Values marked as read from the chart are approximate.
The slide names the payoff in two lines. Efficient deep learning enables daily-life applications on mobile phones, which is why the Once-for-All paper defines a "mobile setting" as anything under 600 M MACs and reports being the first to reach 80% inside it. And it enables private on-device Inference and training, the theme of the last concept in this part. Both follow from the same fact: a model that costs fourteen times less can live on a device that has fourteen times less to spend.
Quick check
Xception needs about 8.4B MACs for 79.0% top-1 and Once-for-All 595M MACs for 80.0%. By what factor is computation reduced?
Recall
ResNet-50 needs 3.9B MACs, Xception 8.4B, and Once-for-All 595M. Compute both reduction ratios.
Slide 7 shows two photographs of a small camera board on a desk. In one it reports whether the person in front of it wears a face mask; in the other it detects people in an office. There is no phone, no laptop and no network cable in the picture. The board is an OpenMV Cam, whose processor is an ARM Cortex-M7 Microcontroller (MCU), and the software is MCUNet, a framework from the same lab as Once-for-All (Lin et al., 2020).
This is TinyML: machine learning on devices with kilobytes of memory. MCUNet's reference target, the STM32F746, has 320 kB of SRAM and 1 MB of flash, and its Table 1 lines that up against a phone and a cloud GPU. The OpenMV Cam H7 in the photos is a somewhat larger sibling: STM32H743 at 480 MHz, with 1 MB of RAM in total, of which MCUNet's experiments use the 512 kB main SRAM block, and 2 MB flash (OpenMV). Both are bare-metal devices with no operating system and no DRAM. Slide 23 returns to these exact numbers as the tiny AI column of the hardware tiers. Its cloud and mobile columns are updated to an 80 GB GPU and a 256 GB phone, so expect those two cells to differ from the table below while the microcontroller column stays the same.
| Tier | Memory | Storage | Gap from the tier above |
|---|---|---|---|
| Cloud AI (NVIDIA V100) | 16 GB | TB to PB | reference |
| Mobile AI (iPhone 11) | 4 GB | more than 64 GB | 4x less memory, 1000x less storage |
| Tiny AI (STM32F746) | 320 kB | 1 MB | table prints 3100x less memory, 64000x less storage |
Why nothing off the shelf fits
The paper gives three failures. ResNet-50's weight storage is about 102 MB, 100x the flash. MobileNetV2 needs about 6.8 MB of peak activation memory, 22x the SRAM (the paper rounds up). Even the int8-quantized MobileNetV2 peaks at 1.7 MB, still 5.3x over, and that is before the runtime's own buffers. Reaching the board required designing the network and the inference engine together: TinyNAS searches architectures under the exact memory limits and TinyEngine executes them without interpreter overhead, and MCUNet as a whole uses 3.5x less SRAM and 5.7x less flash than int8 MobileNetV2 and ResNet-18 at similar accuracy. The result is 70.7% ImageNet top-1 on an STM32H743 (the OpenMV H7 chip, which MCUNet evaluates under a 512 kB SRAM and 2 MB flash budget, although the board has 1 MB of SRAM in total), the first time that bar was reached on an off-the-shelf microcontroller, and about 62% inside the 320 kB / 1 MB budget of the F746 (Lin et al., 2020, Table 4, 4-bit).
Worked example
Does ResNet-50 fit?
Weights in FP32
25.5 M parameters times 4 bytes is 102 MB, matching the paper.Against 1 MB of flash
102 / 1 = 102x too large.Even at 8 bits
25.5 MB, still 25x too large; quantization alone cannot save it.Result
Fitting a microcontroller needs a different architecture, not a compressed copy of a server model.
The reasons to bother are the same four from the first concept, now at their most extreme. MCUNet points out that there are around 250 billion microcontrollers in the world, that processing raw sensor data at the source protects privacy because nothing is transmitted, and that inference on the node works in places without Internet access (Lin et al., 2020). A mask detector on a camera board costs a few dollars, runs on milliwatts and never uploads a face.
Quick check
What memory gap does MCUNet's Table 1 print between a phone and the microcontroller?
Recall
What memory and storage does the MCU that MCUNet targets have, and how far is that from a cloud GPU?
A smart speaker slowly gets better at recognizing the voices in one house. A phone learns its owner's face after the first enrollment. Both need data that arrives after the product shipped, and both kinds of data (a voice, a face) are exactly what users least want uploaded. The figure on slide 8 draws the consequence: new and sensitive data flows from the user to the Edge device, the arrow from the device to the cloud is crossed out for privacy, and a small loop above the device shows the model updating itself where the data is.
That loop is On-device training (learning). The slide lists four benefits. Better privacy, because nothing leaves the device. Lower cost, because there is no upload and no cloud training bill. Customization, because the model adapts to this user, this room, this camera angle. Life-long learning, because the adaptation never has to stop; AI systems, as the slide puts it, need to continually adapt to new data collected locally. Lin and colleagues summarize the goal as letting users benefit from customized models without transferring their data to the cloud (Lin et al., 2022).
Why training is so much more expensive than inference
The third line of the slide is the catch: training is more expensive than Inference, hard to fit in edge memory, and limited by power. All three follow from how backpropagation works. Inference is one forward pass through the layers, and each layer's activations can be discarded as soon as the next layer has consumed them. Training runs the same forward pass, then a backward pass that costs about twice as much: propagating the gradient through each layer is one multiply by the transposed weights, which Goodfellow, Bengio and Courville note has the same cost as the forward multiply (Goodfellow et al., 2016, Sec. 6.5.7), and computing the weight gradient is a second multiply of the same size. So one training step is roughly three times the arithmetic of one inference pass, the convention behind the 6N versus 2N per-token estimate used in scaling studies (Kaplan et al., 2020). The backward pass also needs the activations that the forward pass produced. Goodfellow and colleagues put it directly: the input to each hidden nonlinearity must be stored from the moment it is computed until the backward pass has returned to the same point, so memory grows with the number of examples in the batch and the width of the layers. On top of that, the optimizer keeps its own state: a momentum buffer, or two moment estimates for Adam, each the size of the model.
| Resource | Inference | Training |
|---|---|---|
| Compute per example | One forward pass | Forward plus backward, about 3x the multiply-adds (backward is about 2x forward) |
| Activations | Freed layer by layer as the input flows through | Every layer's activations kept until the backward pass returns |
| Extra state | Weights only | Weights, gradients and optimizer state (momentum, Adam moments) |
| Memory scaling | Largest single layer | Grows with depth and batch size |
Worked example
Training MobileNetV1 on a microcontroller, naively
Weights
4.2 M parameters in FP32 is 16.8 MB.Gradients and momentum
One gradient per weight and one momentum value per weight: two more copies, another 33.6 MB.Total before activations
50.4 MB of state, against 320 kB of SRAM.Result
About 157x over budget before a single activation is stored. Lin et al. (2022) get training under 256 kB by updating only a sparse subset of weights and by training directly on quantized values, using less than a thousandth of the memory of PyTorch or TensorFlow on the same task.
Power is the last constraint. A training step roughly triples the arithmetic of every example, and a device that runs on a battery or a solar cell cannot run it continuously. So on-device learning is not merely inference plus a little bookkeeping; it is a harder problem than the one MCUNet solved, and the course treats it as its own topic.
Quick check
Why does the slide 8 figure cross out the arrow from the edge device to the cloud?
Recall
Give three reasons training is more expensive than inference on a device, and the four benefits of doing it anyway.
Recap
If you remember nothing else
- Machine learning and deep learning are everywhere and computationally expensive; the course asks how to make them lightweight and fast without losing accuracy.
- Progress rides on three pillars, algorithm, hardware and data; efficiency work in this course lives mainly in the first two.
- ImageNet top-5 error fell from 28.2% (2010) to 2.3% (2017); AlexNet cut 9.4 points in 2012; ResNet (3.57%) was the first winner below the 5.1% human estimate.
- Top-5 error and top-1 accuracy are different metrics: slide 4 uses the first, slides 5 and 6 the second.
- MACs count multiply-accumulates per input, a hardware-neutral cost; parameters count storage. More of both buys accuracy with diminishing returns (ResNet-101 doubles the MACs of ResNet-50 for about 1 point).
- Once-for-All (595M MACs, 80.0% top-1) beats Xception with 14x less computation, shifting the Pareto frontier to the upper left.
- MCUNet runs mask and person detection on a Cortex-M7 camera board; its reference MCU has 320 kB SRAM and 1 MB Flash, three to four orders of magnitude below a phone.
- On-device learning gives privacy, lower cost, customization and life-long learning, but a training step costs roughly three times the compute of an inference pass plus stored activations and optimizer state, on limited memory and power.
Sources
- ImageNet Large Scale Visual Recognition ChallengePaperInternational Journal of Computer Vision, Russakovsky et al., 2015Top-5 definition (Eq. 1), winners 2010 to 2014, human 5.1% (Sec. 6.4)(opens in a new tab)
- Deep Residual Learning for Image RecognitionPaperCVPR 2016, He, Zhang, Ren, Sun3.57% top-5 ensemble; Table 1 multiply-adds for ResNet-50 and ResNet-101(opens in a new tab)
- ImageNet Classification with Deep Convolutional Neural NetworksPaperNeurIPS 2012, Krizhevsky, Sutskever, HintonAlexNet: 1.2 million training images, two GTX 580 GPUs, the prediction panel on slide 4(opens in a new tab)
- Squeeze-and-Excitation NetworksPaperCVPR 2018, Hu, Shen, Sun2.251% top-5, ILSVRC 2017 winner(opens in a new tab)
- ILSVRC 2016 resultsDocsImageNetTrimps-Soushen 2.991% top-5(opens in a new tab)
- MobileNets: Efficient Convolutional Neural Networks for Mobile Vision ApplicationsPaperHoward et al., 2017Table 8: 70.6% top-1, 569 M multiply-adds, 4.2 M parameters(opens in a new tab)
- Once-for-All: Train One Network and Specialize it for Efficient DeploymentPaperICLR 2020, Cai, Gan, Wang, Zhang, Han80.0% top-1 at 595 M MACs, Figure 2 with the 14x arrow, mobile setting under 600 M MACs, CO2 of five cars(opens in a new tab)
- Model Compression and Hardware Acceleration for Neural Networks: A Comprehensive SurveyPaperProceedings of the IEEE 108(4), Deng, Li, Han, Shi, Xie, 2020Credited on slide 5; DOI 10.1109/JPROC.2020.2976475(opens in a new tab)
- Efficient Processing of Deep Neural Networks: A Tutorial and SurveyPaperProceedings of the IEEE, Sze, Chen, Yang, Emer, 2017MAC as the fundamental operation; ResNet-50 25.5 M weights and 3.9 G MACs(opens in a new tab)
- Xception: Deep Learning with Depthwise Separable ConvolutionsPaperCVPR 2017, CholletSame parameter count as Inception V3(opens in a new tab)
- MCUNet: Tiny Deep Learning on IoT DevicesPaperNeurIPS 2020, Lin, Chen, Lin, Cohn, Gan, HanTable 1 tiers, STM32F746 320 kB and 1 MB, 7.2 MB and 6.8 MB peak memory, 100x, 22x and 5.3x overshoots, Table 4 70.7% on H743 and 62.0% on F746, 250 billion MCUs(opens in a new tab)
- OpenMV Cam H7DocsOpenMVSTM32H743 Cortex-M7 at 480 MHz, 1 MB RAM in total (512 kB main SRAM used by MCUNet), 2 MB flash(opens in a new tab)
- On-Device Training Under 256KB MemoryPaperNeurIPS 2022, Lin, Zhu, Chen, Wang, Gan, HanCustomized models without transferring data to the cloud; training under 256 kB SRAM(opens in a new tab)
- Deep Learning, chapter 6: Deep Feedforward NetworksBookMIT Press, Goodfellow, Bengio, Courville, 2016Sec. 6.5.7: the backward multiply by the transposed weights costs the same as the forward one; activations stored until the backward pass returns(opens in a new tab)
- Scaling Laws for Neural Language ModelsPaperKaplan et al., 2020Training compute of about 6N versus 2N for inference per token, the backward-is-twice-forward convention(opens in a new tab)
- Going Deeper with ConvolutionsPaperCVPR 2015, Szegedy et al.GoogLeNet, the 22-layer ILSVRC 2014 winner(opens in a new tab)
- MIT 6.5940: TinyML and Efficient Deep Learning ComputingDocsMIT HAN Lab, Song HanCompanion course whose introduction lecture the deck follows(opens in a new tab)
Part 02: Segmentation, generative models and LLMs
Promptable segmentation, diffusion models, 3D perception and large language models push computation and memory far beyond classification, and each has an efficient counterpart that recovers speed without losing quality.
5 concepts, slides 9-16
Why this part matters
Part 01 measured the price of accuracy on ImageNet. This part follows the same question into the models that define the field today: promptable segmentation, image and video diffusion, 3D perception in a moving car, and large language models. In every case the same move rescues the system: find the block that dominates the cost, then attack that block and only that block.
Every research direction in this course (quantisation, pruning, distillation, efficient attention, distributed inference) is motivated by one of the five cases here, and this is also how you scope a PhD project on embedded ML. Exam questions turn the slide numbers into arithmetic: bytes per parameter, speedup versus MAC ratio, frame budgets in milliseconds. Each concept below ends with that arithmetic worked out so you can do it from memory.
By the end you can
- Name SAM's three blocks, say which one dominates the cost, and explain what EfficientViT-SAM swaps to reach 48.9x.
- Explain why compute follows tokens and denoising steps rather than parameters, and why diffusion cost is super-quadratic in resolution.
- Compare naive patch parallelism with DistriFusion on MACs, latency and artifacts, and account for the gap between 4.0x less work and 3.0x speedup.
- Turn frames per second into a frame time and show which of Fast-LiDARNet's two levers crosses the 30 fps line.
- Convert parameters and precision into bytes and GPU counts, and give the three reasons LLMs must also run at the edge.
Picture a head-mounted camera looking at a door, a small label reading id 27, 52 cm, and a green mask painted over one region. A single click on the door produced that mask. That is what promptable means. The user supplies a hint, a point, a box or a phrase, and the model returns the object the hint refers to. The Segment Anything Model (SAM) from Kirillov et al. was trained on SA-1B, over one billion masks on 11 million images, so it can do this for objects it has never been told about.
The architecture matters more than the demo. SAM is three blocks. An image encoder, a ViT-H pre-trained with masked autoencoding, reads the image once and produces an image embedding. A prompt encoder turns sparse prompts (points, boxes, text) and dense prompts (masks) into prompt embeddings. A lightweight mask decoder combines the two and outputs a valid mask. The paper is explicit about the asymmetry: the image encoder runs once per image, and given a precomputed embedding, the prompt encoder and mask decoder run in a web browser, on a CPU, in about 50 ms. Encode once, expensively; prompt many times, cheaply.
SAM's three blocks
- Image encoder
- ViT-H, 641.1 M parameters, 2973 GMACs per image, runs once per image
- Prompt encoder
- Points, boxes and text (sparse), masks (dense); tiny
- Mask decoder
- Fuses image and prompt embeddings into a valid mask; with the prompt encoder, about 50 ms on a browser CPU
Attack the block that dominates
Once you see that the encoder holds 2973 GMACs and the rest is a 50 ms CPU job, the efficiency strategy writes itself. EfficientViT-SAM (Zhang, Cai and Han) keeps SAM's prompt encoder and mask decoder unchanged and replaces only the image encoder with EfficientViT, the multi-scale linear attention backbone from Cai et al. (ICCV 2023). Training happens in two stages: first the new encoder is distilled from SAM's ViT-H encoder as the teacher, then the whole model is trained end to end on SA-1B. Nothing else in the pipeline moves.
Hover, tap or focus a block to see what it costs and whether EfficientViT-SAM touches it.
Numbers from Table 1 of the EfficientViT-SAM paper. The prompt encoder and mask decoder are identical in every configuration, which is why swapping only the encoder moves the whole bar.
The fair way to judge the swap is accuracy against speed on the same hardware: zero-shot COCO mAP against A100 throughput with TensorRT in FP16. Zero-shot here has a precise meaning: the models were never trained on COCO, and they are evaluated with boxes from a ViTDet detector as prompts. Two speedups get quoted, and they belong to different models. The 16.5x figure is EfficientViT-SAM-XL1, which is faster and more accurate than SAM (47.8 versus 46.5 mAP). The 48.9x headline belongs to EfficientViT-SAM-L2, which matches SAM at 46.6 mAP while running 538 images per second instead of 11. The full table from the paper makes the families visible.
| Model | Encoder params | Encoder MACs | Throughput (img/s) | mAP | Speedup vs SAM-ViT-H |
|---|---|---|---|---|---|
| SAM-ViT-H | 641.1 M | 2973 G | 11 | 46.5 | 1x |
| EfficientViT-SAM-XL1 | 203.3 M | 322 G | 182 | 47.8 | 16.5x |
| EfficientViT-SAM-XL0 | 117.0 M | 185 G | 278 | 47.5 | 25.3x |
| EfficientViT-SAM-L2 | 61.3 M | 69 G | 538 | 46.6 | 48.9x |
| EfficientViT-SAM-L1 | 47.7 M | 49 G | 638 | 46.2 | 58.0x |
| EfficientViT-SAM-L0 | 34.8 M | 35 G | 762 | 45.7 | 69.3x |
| EfficientSAM | 25.3 M | 247 G | 183 | 44.4 | 16.6x |
| EdgeSAM | 9.6 M | 20 G | 449 | 42.1 | 40.8x |
| MobileSAM | 9.8 M | 39 G | 278 | 38.7 | 25.3x |
Worked example
Compute reduction versus measured speedup
MAC ratio
SAM-ViT-H to L2: 2973 / 69 ≈ 43.1x fewer encoder MACs.Throughput ratio
538 / 11 ≈ 48.9x more images per second.Compare
The measured speedup is larger than the MAC ratio. MACs are a hardware-neutral proxy; the real number also depends on memory access patterns and how well TensorRT kernels run linear attention.Result
43x less arithmetic bought 49x more throughput. MACs predict the direction, not the exact size, of a speedup.
The table carries a second lesson. EfficientSAM has 25.3 M encoder parameters, eight times fewer than XL1's 203.3 M, and yet the two run at the same throughput (183 versus 182 img/s), with EfficientSAM losing 3.4 mAP. Model size is about memory; speed is about MACs, memory traffic and kernels. Keep the three apart.
Quick check
Which block of SAM does EfficientViT-SAM replace to get its speedup?
Quick check
What does zero-shot mean for the COCO mAP on slide 10?
Recall
Name SAM's three blocks and say which one runs once per image.
Recall
What does EfficientViT-SAM change, what does it keep, and what are the throughput and mAP of its 48.9x variant against SAM-ViT-H?
Type "teddy bears working as mad scientists", "a bowl of soup as a planet on a 1960s poster" or "an astronaut riding a horse on Mars" into Midjourney and a finished picture comes back. A diffusion model produced each one from a sentence, by starting from noise and removing a little of it at every step until an image appears. The results look effortless. The bill is not. Emad Mostaque, then CEO of Stability AI, said that training Stable Diffusion used 256 A100 GPUs for about 150,000 GPU-hours at a cost of about $600,000, the figure the lecture uses as Stable Diffusion's training cost.
Worked example
What $600,000 of training looks like
Wall-clock time
150,000 GPU-hours / 256 GPUs ≈ 586 hours, which is about 24.4 days with every GPU busy the whole time.Price per GPU-hour
$600,000 / 150,000 GPU-hours = $4.00 per A100-hour.Cross-check
256 GPUs × 24 h × 24.4 days ≈ 149,900 GPU-hours, matching the stated total.Result
One training run: a rack of 256 accelerators for most of a month. Nobody iterates on that budget casually, which is why efficient training and inference are research topics rather than polish.
Stable Diffusion training run, 2022
- GPUs
- 256 × A100
- GPU-hours
- about 150,000
- Wall clock
- about 24 days
- Cost
- about $600,000
- Implied price
- about $4 per GPU-hour
| Run | A100s | GPU-hours | Wall clock | Cost |
|---|---|---|---|---|
| Stable Diffusion, 2022 | 256 | about 150,000 | about 24 days | about $600,000 |
| MosaicML SD2 base, 2023 | 128 | about 21,000 | 6.8 days | under $42,000 |
Why parameters are not the cost
Training is paid once. Inference is paid on every request, so compare what one forward pass costs in MACs across four very different models. The natural expectation is that the biggest model costs the most. The numbers say otherwise, and the reason is the most important idea in this concept.
| Model | Parameters | Workload | MACs | Ratio |
|---|---|---|---|---|
| ViT-H | 0.6 B | 518 x 518 image, one forward pass | 1.02 T | baseline |
| Llama 3 8B | 8 B | 1,024-token context, 512 output tokens | 11.2 T | 11x ViT-H |
| FLUX.1 | 12 B | 1K x 1K image, one denoising step | 37.2 T | 36x ViT-H, 3.3x Llama 3 |
| CogVideoX | 5.6 B | 480 x 720, 49 frames, one denoising step | 332 T | 8.9x FLUX.1, 326x ViT-H |
FLUX.1 has 12 B parameters and CogVideoX has 5.6 B, yet CogVideoX needs 8.9x the MACs per step. Llama 3 8B has more parameters than ViT-H by a factor of thirteen but costs eleven times more, not thirteen, and FLUX.1 with 1.5x the parameters of Llama 3 costs 3.3x as much. Parameters alone predict none of these ratios. What predicts them is how many tokens each model pushes through those parameters. A dense transformer spends roughly one multiply-accumulate (two FLOPs) per parameter per token in its linear layers, and on top of that attention compares every token with every other token.
Now the numbers make sense. ViT-H sees one 518 × 518 image cut into 14-pixel patches, 37 × 37 = 1,369 tokens: 632 M × 1,370 ≈ 0.87 T for the linear layers, and the attention term adds the rest of the 1.02 T. Llama 3 processes about 1,500 tokens. FLUX.1 works on the latent of a 1K × 1K image, about 4,000 tokens. CogVideoX compresses 49 frames of 480 × 720 video into 13 latent frames and denoises them all at once, about 17,500 tokens, roughly four times FLUX.1. Because the attention term grows with the square of that count, the bill grows far more than four times, and the smaller parameter count cannot save it. Read the linear term as the weights each token actually passes through, not the headline parameter count: for FLUX.1 the naive 12 B × 4,096 ≈ 49 T overshoots the 37.2 T bar because image and text tokens use separate weights in its double-stream blocks. One accounting rule explains the ordering of the chart: compute is parameters times tokens, plus attention.
One more multiplier hides in the words "single step" under the FLUX.1 and CogVideoX bars. A diffusion model repeats its forward pass once per denoising step. With a 50-step sampler, one 1K FLUX.1 image costs 37.2 T × 50 = 1,860 T MACs, and a CogVideoX clip costs 332 T × 50 = 16,600 T. A classifier pays its bar once; a generator pays it fifty times.
Resolution is worse than quadratic
Now hold the model fixed and vary only the image side length for FLUX.1, from 1024 to 4096. Going four times wider makes the image sixteen times larger in pixels, so a quadratic law would predict sixteen times the MACs. From the slide's left chart, one step at 1K x 1K costs 37.2 T, and the curve on the right ends near 1,950 T at 4096: a factor of about 52, far above the 16x a quadratic law predicts. This is what the lecture calls super-quadratic scaling, and the formula above explains it. Tokens grow with pixels (16x), the linear term grows with tokens (16x), and the attention term grows with tokens squared (256x). The blend lands at about 52x.
The solid curve is 31.6 (s/1024)^2 + 5.6 (s/1024)^4 trillion MACs, fitted to the two end points of the slide chart. It is a teaching model of the slide curve, not a profile of FLUX.1 itself.
FLUX.1 MACs per step read off the slide chart, by image side
- 1024
- about 37 T
- 1536
- about 94 T
- 2048
- about 207 T
- 2560
- about 406 T
- 3072
- about 728 T
- 3584
- about 1,226 T
- 4096
- about 1,950 T
Worked example
Fitting the slide curve
Model
Let r = side / 1024 and write MACs(r) = A r² + B r⁴: a token-linear part and an attention part.Fit the end points
A + B = 37.2 at r = 1 and 16A + 256B = 1950 at r = 4, so B ≈ 5.6 T and A ≈ 31.6 T.Check the middle
At 2048: 4 × 31.6 + 16 × 5.6 ≈ 216 T (chart about 207 T). At 3072: 9 × 31.6 + 81 × 5.6 ≈ 741 T (chart about 728 T).Result
At 1024 attention is about 15% of the cost. At 4096 it is about three quarters. This is why efficient attention (the EfficientViT backbone from the previous concept, FlashAttention, linear attention) is a research area of its own.
Quick check
Why does one CogVideoX step cost more MACs than one FLUX.1 step?
Quick check
FLUX.1 MACs rise from about 37 T at 1024 to about 1,950 T at 4096, roughly 52x, while pixels grow 16x. What best explains that?
Recall
256 A100s for 150,000 GPU-hours: how many days is that, and what price per GPU-hour does $600,000 imply?
Recall
Why does CogVideoX with 5.6 B parameters need 8.9x the MACs of FLUX.1 with 12 B parameters?
Recall
From 1024 to 4096, how much do pixels grow and how much do FLUX.1 MACs grow, and why the difference?
Ask SDXL for a "Romantic painting of a ship sailing in a stormy sea" at high resolution. One GPU paints one ship in 12.3 s. The obvious way to go faster is to cut the canvas into four vertical strips, hand each strip to its own GPU, and let them work without talking. The result is 3.9x faster and wrong: four strips, four ships, four different skies. Each patch generated its own picture because no patch could see the others.
DistriFusion (Li et al., CVPR 2024) keeps the split and restores the context. The trick rests on a property of diffusion: consecutive denoising steps produce similar activations, because each step removes only a little noise. So a patch can attend to its neighbours' activations from the previous step instead of waiting for the current one. The paper calls this displaced patch parallelism. The first few denoising steps (the warm-up: the first step plus four more in the paper) run synchronous patch parallelism so everyone starts from the same picture; after that, communication runs asynchronously and hides behind computation. No retraining is needed. The latency drops to 4.16 s, 3.0x faster than one GPU, and the ship is one ship.
| Setup | MACs per device | Work per device | Latency | Speedup | Quality |
|---|---|---|---|---|---|
| Original, 1 GPU | 907 T | 1x | 12.3 s | 1x | reference image |
| Naive patches, 4 GPUs | 190 T | 4.8x less | 3.14 s | 3.9x | duplicated subjects |
| DistriFusion, 4 GPUs | 227 T | 4.0x less | 4.16 s | 3.0x | no artifacts |
| DistriFusion, 8 GPUs (paper, not on the slide) | 113 T | 8.0x less | 2.74 s | 4.5x | no artifacts |
Worked example
Where the work went
Naive total
190 T × 4 = 760 T, less than the original 907 T. Naive patches skip all cross-patch attention, so the total work drops. The missing 147 T is exactly the missing context.DistriFusion total
227 T × 4 = 908 T ≈ 907 T. The full computation is preserved and simply divided by four.Ideal latency
12.3 s / 4 ≈ 3.08 s if four GPUs were perfectly parallel. Naive lands at 3.14 s, DistriFusion at 4.16 s.Result
DistriFusion does 4.0x less work per GPU but runs only 3.0x faster. The difference is the cost of exchanging activations between GPUs and of the synchronous warm-up steps.
The pattern is general in distributed systems: splitting work across machines helps only when the compute you save exceeds the communication you add. Here the saving is large because a high-resolution diffusion step is enormous (MACs in the hundreds of trillions), and the communication is hidden behind it. The paper also runs a scaling study on a larger image, 3840 × 3840, shown in the table below. Read down the efficiency column: every added GPU still helps, but each device contributes less than the last, because the communication grows while the per-device work shrinks.
| A100s | Speedup over one GPU | Marginal speedup | Parallel efficiency |
|---|---|---|---|
| 1 | 1x | reference | 100% |
| 2 | 1.8x | 1.8x | 90% |
| 4 | 3.4x | 1.9x | 85% |
| 8 | 6.1x | 1.8x | 76% |
Quick check
DistriFusion cuts MACs per GPU 4.0x but latency only 3.0x. What explains the gap?
Quick check
Where does a DistriFusion patch get context about its neighbours?
Recall
What artifact does naive patch parallelism produce, and why?
Recall
Why is 190 T times 4 less than the original 907 T?
A 2015 Toyota Prius V with a roof-mounted Velodyne LiDAR drives a wooded test track. A network reads raw 3D point clouds and produces steering. A car does not care how elegant the network is; it cares whether the answer arrives before the deadline the system sets. Three measurements tell the story: MinkowskiNet at 5 fps is "too slow to drive", the same network with optimised kernels reaches 18 fps, and Fast-LiDARNet reaches 47 fps, above the 30 fps line the slide marks as real time.
The most useful way to read fps is to invert it into a frame time. A stream at 30 fps gives you 33.3 ms per frame, and everything the model does must fit inside that budget.
Frame times behind the bars
- Budget at 30 fps
- 33.3 ms
- MinkowskiNet, 5 fps
- 200 ms, 167 ms over budget
- Optimised kernels, 18 fps
- 55.6 ms, 22 ms over budget
- Fast-LiDARNet, 47 fps
- 21.3 ms, 12 ms to spare
The paper (Liu, Amini, Zhu, Karaman, Han and Rus, ICRA 2021) is explicit about the two levers. Their optimised sparse convolution kernel gives a 3.6x acceleration, and their hardware-aware model design reduces latency by another 2.6x. The two multiply: 3.6 × 2.6 ≈ 9.4, which is 47 / 5. The first lever is pure systems work: the same network, the same accuracy, better code for the sparse operations point clouds need. The second is algorithmic: a smaller architecture chosen with the hardware in mind. This pairing is what the lecture means by algorithm and system co-design. Neither lever alone reaches the line. Kernels take the network from 200 ms to 55.6 ms and still miss by 22 ms; the redesign brings it to 21.3 ms.
| Configuration | Rate | Frame time | Lever | Inside 33.3 ms? |
|---|---|---|---|---|
| MinkowskiNet | 5 fps | 200 ms | none | no, 167 ms over |
| MinkowskiNet, optimised sparse kernels | 18 fps | 55.6 ms | system: 3.6x | no, 22 ms over |
| Fast-LiDARNet | 47 fps | 21.3 ms | algorithm: 2.6x more, 9.4x total | yes, 12 ms to spare |
Quick check
Kernel optimisation lifts MinkowskiNet to 18 fps. Why is that still not enough?
Recall
Name Fast-LiDARNet's two levers with their multipliers and the resulting frame rates.
Recall
What is the frame budget at 30 fps, and what is MinkowskiNet's frame time at 5 fps?
MT-NLG, the largest model on the lecture's chart, has 530 billion parameters. Store each one in FP16, two bytes, and the weights alone occupy 530 × 10⁹ × 2 = 1,060 GB. The largest GPU of that period, an A100 with 80 GB, holds 40 billion FP16 parameters. The gap between the two is 1,060 / 80 = 13.25, so 14 GPUs of weights before a single activation is computed.
To compare a model with a chip, put both on one log axis of model size by converting GPU bytes into a parameter count at FP16, which is what the lecture's assumption "data are FP16" means. 16 GB becomes 8 B parameters, 32 GB becomes 16 B, 80 GB becomes 40 B. On that shared axis the two curves tell the story of the large language model era: model size climbs from 0.05 B to 530 B, about 10,000x in roughly four years, while GPU memory climbs from 16 GB to 80 GB, 5x. Models have outgrown the chips they run on, and the distance keeps widening.
| Model | Year | Parameters | FP16 weights | A100 80 GB GPUs |
|---|---|---|---|---|
| Transformer | 2017 | 0.05 B | 0.1 GB | 1 |
| GPT | 2018 | 0.11 B | 0.22 GB | 1 |
| BERT-Large | 2018 | 0.34 B | 0.68 GB | 1 |
| GPT-2 | 2019 | 1.5 B | 3 GB | 1 |
| Megatron-LM | 2019 | 8.3 B | 16.6 GB | 1 |
| T-NLG | 2020 | 17 B | 34 GB | 1 |
| GPT-3 | 2020 | 175 B | 350 GB | 5 |
| MT-NLG | 2021 (paper 2022) | 530 B | 1,060 GB | 14 |
| Accelerator | Memory | FP16 parameters it holds |
|---|---|---|
| TPU v2 | 16 GB | 8 B |
| V100 | 32 GB | 16 B |
| TPU v3 | 32 GB | 16 B |
| A100 | 40 GB | 20 B |
| A100 | 80 GB | 40 B |
Parameters to bytes to GPUs
Every memory question in this course starts with one multiplication. Parameters times bytes per parameter gives the weight memory; divide by the memory of one device and round up to get the device count. The bytes per parameter depend on the numeric format: 4 for FP32, 2 for FP16 or BF16, 1 for INT8, 0.5 for INT4. Quantisation, which later lectures cover in depth, is simply the art of moving down that list without losing accuracy.
Worked example
MT-NLG on A100 80 GB GPUs
FP16
530 B × 2 bytes = 1,060 GB; 1,060 / 80 = 13.25, so 14 GPUs for the weights alone.INT8
530 B × 1 byte = 530 GB; 530 / 80 = 6.6, so 7 GPUs.INT4
530 B × 0.5 byte = 265 GB; 265 / 80 = 3.3, so 4 GPUs.Result
Every halving of precision halves the shelf. The same rule says an 80 GB card holds at most 40 B FP16 parameters, and that leaves zero room for anything else.
Weights only. Activations and the KV cache add memory that grows with batch size and context length, so a model that just fits here does not run. GB means 10^9 bytes. The 4 GB is the RAM slide 23 gives mobile AI (its activation-memory row), which holds weights and activations together; the 1 MB is the flash weight storage it gives a microcontroller.
Try Llama 3 8B in the calculator. In FP16 it needs 16 GB, four times the 4 GB of RAM slide 23 gives a phone. Slide 23 lists that 4 GB as activation memory and 256 GB as weight storage; in practice LLM inference loads the weights into that same RAM, so the 4 GB is the binding limit. In INT4 the model needs 4 GB, exactly at the line, with nothing left for activations. Now try the 2017 Transformer at 0.05 B against a microcontroller's 1 MB of weight storage: 100 MB in FP16, a hundred times over. The gap between what models need and what edge hardware has is the subject of part 03.
Why run them at the edge anyway
If LLMs barely fit in a rack of cloud GPUs, why does the lecture insist on running them on laptops, cars and robots? Three reasons, each one a research direction in this course.
- Copilot services, such as code completion, office assistants and in-game chat, running locally on the machine that uses them. Latency drops, and the service works in a car or a robot far from any data center.
- Resource-constrained, low-power devices that are not always connected. An edge LLM must work when the link is slow or absent.
- Privacy of user data. Prompts contain code, documents and conversations, and a local model never uploads them.
This is the design space for an on-device assistant, and it is why the rest of the course is about shrinking the memory (quantisation, pruning), the compute (efficient attention, distillation) and the deployment (compilers, kernels) of exactly the models on this chart. For a PhD project on embedded ML, the two-slope chart is the problem statement.
Quick check
A 175 B parameter model is stored in INT8. What is its weight memory?
Quick check
Why can 16 GB of GPU memory be drawn as 8 B parameters?
Recall
What is the FP16 weight memory of MT-NLG, and how many A100 80 GB GPUs does it need for weights alone?
Recall
How many FP16 parameters fit in 16 GB, and how much did model size and GPU memory grow over the chart?
Recall
Give the three reasons on slide 16 for running LLMs at the edge.
Recap
If you remember nothing else
- SAM is an image encoder that runs once per image and dominates the cost, plus a prompt encoder and a lightweight mask decoder that together run in about 50 ms on a CPU.
- EfficientViT-SAM replaces only the image encoder: 538 versus 11 img/s (48.9x) at 46.6 versus 46.5 zero-shot COCO mAP.
- Training Stable Diffusion took 256 A100s for 150k GPU-hours, about 24 days and about $600,000, so about $4 per GPU-hour.
- Compute follows tokens times steps: CogVideoX with 5.6 B parameters needs 332 T MACs per step, 8.9x FLUX.1's 37.2 T with 12 B parameters.
- FLUX.1 MACs grow about 52x from 1024 to 4096 while pixels grow 16x, because attention is quadratic in token count.
- DistriFusion on 4 GPUs: 227 T MACs per device (4.0x less), 4.16 s (3.0x faster), no duplicated subjects. Naive patches are 3.9x faster but fragment the image.
- Fast-LiDARNet: kernel optimisation 3.6x, model redesign 2.6x, 5 to 47 fps against a 30 fps (33.3 ms) budget.
- Model size grew about 10,000x in four years while GPU memory grew about 5x; 530 B FP16 parameters are 1,060 GB, or 14 A100 80 GB GPUs for weights alone.
- Edge LLMs exist for local copilots on laptops, cars and robots, for low-power devices that are not always connected, and for privacy.
Sources
- Segment AnythingPaperKirillov et al., ICCV 2023Three components, SA-1B (1 B masks on 11 M images), prompt encoder and decoder in about 50 ms on a browser CPU(opens in a new tab)
- EfficientViT-SAM: Accelerated Segment Anything Model Without Accuracy LossPaperZhang, Cai and Han, arXiv 2024Table 1: params, MACs, A100 TensorRT FP16 throughput and zero-shot COCO mAP; 48.9x(opens in a new tab)
- EfficientViT-SAM demoDocsMIT HAN LabThe link printed on slide 10; the demo host is intermittently offline, the arXiv paper is the durable source(opens in a new tab)
- Training cost for Stable Diffusion was just $600,000ArticleThe Decoder, 8 September 2022Emad Mostaque's 256 A100, 150k GPU-hour, $600k figures(opens in a new tab)
- How We Trained Stable Diffusion for Less than $50k (Part 3)ArticleDatabricks (MosaicML)Measured run: 21,000 A100-hours, 6.79 days on 128 A100s, under $42,000(opens in a new tab)
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScalePaperDosovitskiy et al., ICLR 2021Table 1: ViT-H has 632 M parameters(opens in a new tab)
- FLUX.1 [dev] model cardDocsBlack Forest Labs, Hugging Face12 billion parameter rectified flow transformer(opens in a new tab)
- CogVideoX-5b model cardDocsZhipu AI, Hugging Face720 x 480, 6 s at 8 fps, 49 frames(opens in a new tab)
- CogVideoX: Text-to-Video Diffusion Models with An Expert TransformerPaperYang et al., arXiv 2024(opens in a new tab)
- The Llama 3 Herd of ModelsPaperMeta AI, arXiv 20248B, 70B and 405B models(opens in a new tab)
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessPaperDao et al., NeurIPS 2022Attention time and memory are quadratic in sequence length(opens in a new tab)
- DistriFusion: Distributed Parallel Inference for High-Resolution Diffusion ModelsPaperLi et al., CVPR 2024Displaced patch parallelism; 1.8x, 3.4x and 6.1x on 2, 4 and 8 A100s(opens in a new tab)
- DistriFusion repository and teaser figureDocsMIT HAN Lab, GitHub907 T / 12.3 s, 190 T / 3.14 s, 227 T / 4.16 s, 113 T / 2.74 s; SDXL 1280 x 1920, 50-step Euler(opens in a new tab)
- Efficient and Robust LiDAR-Based End-to-End NavigationPaperLiu, Amini, Zhu, Karaman, Han and Rus, ICRA 20213.6x from kernels, 2.6x from model design, 47 fps on GTX 1080Ti, 11 fps on Jetson AGX Xavier(opens in a new tab)
- Using DeepSpeed and Megatron to Train Megatron-Turing NLG 530BPaperSmith et al., arXiv 2022530 billion parameters(opens in a new tab)
- Language Models are Few-Shot LearnersPaperBrown et al., NeurIPS 2020GPT-3, 175 B parameters(opens in a new tab)
- Megatron-LM: Training Multi-Billion Parameter Language Models Using Model ParallelismPaperShoeybi et al., arXiv 2019Up to 8.3 billion parameters(opens in a new tab)
- BERT: Pre-training of Deep Bidirectional TransformersPaperDevlin et al., NAACL 2019BERT-Large, 340 M parameters(opens in a new tab)
- Turing-NLG: A 17-billion-parameter language model by MicrosoftArticleMicrosoft Research Blog, 13 February 2020(opens in a new tab)
- NVIDIA A100 Tensor Core GPUDocsNVIDIA40 GB and 80 GB variants(opens in a new tab)
- NVIDIA V100 datasheetDocsNVIDIA32 GB or 16 GB HBM2(opens in a new tab)
- TPU v3DocsGoogle Cloud documentation32 GiB HBM2 per chip(opens in a new tab)
- MIT 6.5940 TinyML and Efficient Deep Learning Computing, Lecture 1DocsMIT HAN LabOrigin of the MAC comparison, resolution curve and model-size charts on slides 12 and 15(opens in a new tab)
Part 03: Cloud and edge AI hardware, and the gap between them
How NVIDIA data center GPUs, mobile NPUs, Jetson modules and microcontrollers compare in performance, power and memory, and why the orders-of-magnitude gap from cloud to tiny devices demands efficient models.
4 concepts, slides 17-24
Why this part matters
Part 02 measured demand: models grew from 0.05B to 530B parameters and diffusion cost rises faster than the square of resolution. This part measures supply. What can a cloud GPU, a phone, a robot module and a microcontroller actually hold and compute, and how far apart are they?
The answer is a set of numbers you will use twice. In the exam, they appear as short computations: TOPS per watt for a given GPU, or the ratio between two memory tiers. In your research project, they are the sizing step that comes before any model is designed: the target tier fixes the memory and power budget, and the budget decides which of the techniques in the rest of this course you will need. By the end of the part the phrase "six orders of magnitude" should feel concrete rather than rhetorical.
By the end you can
- Read a GPU spec sheet: define TOPS (dense versus sparse), memory bandwidth and TDP, and compute TOPS per watt for any of the five NVIDIA generations.
- Explain the memory wall: why 94x more compute on 2.8x more power and 12x more memory makes data movement, not arithmetic, the bottleneck.
- Contrast edge accelerator families: a fixed power envelope (Snapdragon, Apple) versus a power ladder (Jetson), and say why TOPS across vendors are not comparable.
- Describe a microcontroller, read DMIPS correctly, and state the 320 kB and 1 MB budgets of the STM32F746.
- Compute the cloud, mobile and tiny AI ratios, separate activation memory from weight storage, and decide whether a given model fits each tier.
A single NVIDIA A100 from 2020 performs 312 trillion dense FP16 operations per second and draws 400 W. Four years earlier the P100 managed 18.7 trillion at 250 W. That is a 17x jump in throughput. How much of it came from simply burning more power? Only 1.6x (400 / 250). The other 10x came from architecture: Tensor Cores, faster HBM2e and a 7 nm process node. That single observation is the whole story of the cloud tier, and the rest of this concept just extends it across five generations.
Slide 17 repeats the three pillars from part 01 to mark the pivot: algorithm and data were the first two, and now we ask whether the third, hardware, can absorb the demand growth by itself. Slide 18 answers with four charts for the NVIDIA data center GPU line: P100, V100, A100, H100 and B100: the P100 as a PCIe card (as the errata below explains) and V100 to B100 in the SXM mezzanine form factor used in HGX and DGX servers, which allows a higher power budget than a PCIe card. The four series are performance, memory bandwidth, power and memory capacity, and the lesson lives in how differently they grow.
Reading the vertical axis: what a TOPS is
TOPS stands for trillions of operations per second. The unit hides two conventions you must know. First, one multiply-accumulate counts as two operations (one multiply, one add), so the MAC counts from part 01 convert with a factor of two. Second, NVIDIA quotes Tensor Core throughput at a specific precision, here FP16, and its spec sheets list two numbers: a dense figure and a figure "with sparsity" that is exactly double. The doubled number applies only when the weights have been pruned to a 2:4 structured pattern (two of every four values zero). The slide uses the dense figures, and so should you when comparing chips. The A100 page reads 312 TFLOPS dense and 624 TFLOPS with sparsity; the H100 SXM lists 1,979 sparse, which is 989 dense, rounded to 990 on the slide (NVIDIA A100 and H100 pages).
Five generations, four very different slopes
| Part | Dense FP16 TOPS | Bandwidth GB/s | Power W | Memory GB | TOPS/W |
|---|---|---|---|---|---|
| P100 (2016), PCIe | 18.7 | 732 | 250 | 16 | 0.075 |
| V100 SXM (2017) | 125 | 900 | 300 | 32 | 0.42 |
| A100 SXM (2020) | 312 | 2,039 | 400 | 80 | 0.78 |
| H100 SXM (2022) | 990 | 3,430 | 700 | 96 | 1.41 |
| B100 SXM (2024) | 1,750 | 8,192 | 700 | 192 | 2.5 |
Growth from P100 (2016) to B100 (2024)
- Performance, dense FP16
- 18.7 to 1,750 TOPS, about 94x
- Board power
- 250 to 700 W, 2.8x
- Memory capacity
- 16 to 192 GB, 12x
- Memory bandwidth
- 732 to 8,192 GB/s, about 11x
- TOPS per watt
- 0.075 to 2.5, about 33x
Read the table as a race between four quantities. Compute ran 94x. Efficiency ran 33x, which is why compute could run so far on so little extra power. Capacity and bandwidth ran only about 12x. So every generation, the arithmetic units can chew through data faster than the memory can deliver it, by a margin that widens each time.
Two-decade growth rates of the three resources (Gholami et al., 2024)
- Peak server FLOPS
- 3.0x every two years
- DRAM bandwidth
- 1.6x every two years
- Interconnect bandwidth
- 1.4x every two years
Gholami and colleagues measured those three rates over two decades of FLOPS, DRAM bandwidth and interconnect bandwidth, and they conclude that memory, not compute, is now the primary bottleneck for AI serving (Gholami et al., 2024). They call it the memory wall.
Why bandwidth matters: the memory wall
Every inference streams weights and activations from the GPU's high-bandwidth memory (HBM) into the compute units. Memory bandwidth is the rate of that stream. If the chip can do 990 trillion operations per second but fetch only 3.35 trillion bytes per second, then it must perform about 295 operations on every byte it fetches to stay busy. A layer that does less arithmetic per byte than that sits idle, waiting for memory. The threshold is called the arithmetic intensity a workload needs to be compute bound.
Worked example
Compute versus bandwidth on an H100
Operations available per second
990 × 10^12 dense FP16 operations per second (NVIDIA H100 page, dense half of 1,979).Bytes available per second
3.35 × 10^12 bytes per second from HBM3 (NVIDIA's figure for the 80 GB part; the slide plots 3,430).Break-even intensity
990 / 3.35 ≈ 295 operations per byte. Below this, memory bounds the chip; above it, compute does.Compare with LLM decoding
Generating one token of an LLM touches every weight once. Each FP16 weight is 2 bytes and does one MAC, so about 2 operations per 2 bytes, roughly 1 operation per byte at batch size one.Result
About 1 operation per byte against a 295 threshold. Single-stream decoding uses well under one percent of the H100's arithmetic; bandwidth sets the token rate. This is a simplified roofline argument that ignores caches and batching, but the conclusion holds for serving.
Tie back to the LLM curve: capacity, not TOPS, sets the minimum machine
Part 02 ended with model size outrunning GPU memory. Put the two lines together. Megatron-Turing NLG has 530 billion parameters (Smith et al., 2022). GPU memory grew 12x over the eight years from 2016 to 2024; in roughly half that time, from the Transformer of 2017 to MT-NLG in 2021, LLM size grew from 0.05B to 530B, about 10,000x. The hardware pillar cannot close that by itself.
Worked example
How many GPUs hold MT-NLG's weights
Bytes of weights at FP16
530 × 10^9 parameters × 2 bytes = 1.06 × 10^12 bytes = 1.06 TB.A100 80 GB cards
1.06 TB / 80 GB = 13.25, so 14 cards before a single activation is stored.B100 192 GB cards
1.06 TB / 192 GB = 5.5, so 6 cards. Four years of hardware progress cut the count by about 2.4x; the model side must do the rest.Result
Memory capacity, not TOPS, decides the smallest machine that can even load the model.
Recall
Compute TOPS per watt for the A100 and the B100 from the slide values. How much did efficiency improve?
Recall
Performance grew 94x from P100 to B100. By how much did power and memory grow, and what does that imply?
Quick check
From P100 (2016) to B100 (2024), dense FP16 performance grew about 94x. By roughly how much did board power grow?
Quick check
An H100 is rated 990 dense FP16 TOPS, but single-stream LLM token decoding runs far below that. What is the most likely limiter?
Quick check
What does the word dense mean in NVIDIA's dense FP16 TOPS figure?
The Snapdragon 845 of 2018 delivered 3 TOPS at about 9 W. The Snapdragon 8 Gen 1 of 2022 delivers 52 TOPS at about 10 W. Seventeen times the performance, essentially no extra power. Why is the power line flat when the cloud line climbed to 700 W? Because a phone is a sealed slab held against skin with no fan. Its sustained power is capped by heat, not by engineering ambition, so every gain must come from efficiency. That is the rule for the whole edge tier: the power envelope is the constraint, and performance per watt is the design metric.
Slides 19 to 21 show three families that each obey this rule in their own way. The Qualcomm Hexagon DSP and the Apple Neural Engine live inside phones and share a lid near 10 W. NVIDIA Jetson modules live in robots and industrial boxes that have a fan and a battery budget, so their power is allowed to climb with each tier. Explore all three, and the cloud and microcontroller tiers, before reading on.
NVIDIA data center, dense FP16 TOPS (slide 18)
Values are the slide figures. Compare within one family only: cloud numbers are dense FP16, Jetson Xavier and Orin are INT8 (Orin sparse) while Nano and TX2 are FP16 FLOPS, Qualcomm sums INT8 across CPU, GPU and Hexagon, Apple states no precision, and MCUs are rated in integer DMIPS, which is not an operations-per-second figure at all.
Qualcomm Hexagon: seventeen times the work under the same lid
Hexagon began as a digital signal processor for audio and camera pipelines. Qualcomm turned it into what its Snapdragon 888 brief calls a "fused AI-accelerator architecture": a tensor accelerator, vector extensions and a scalar unit sharing memory, supporting INT8, INT16 and FP16. The brief claims 26 TOPS for the whole AI Engine and "up to 3 times performance per watt improvement" over the 865; the 8 Gen 1 brief claims "up to 4x faster" and "best performance-per-watt in Snapdragon history" (Qualcomm product briefs). Notice the vendor language: every headline is a ratio to power. The products on the slide are the Qualcomm Robotics RB5 platform (865 class, 15 TOPS), the Galaxy Tab with the 888+ and the Galaxy Z Fold with the 8+ Gen 1.
| Part | TOPS | Power W | Memory GB | TOPS/W |
|---|---|---|---|---|
| Snapdragon 845 | 3 | 9 | 4 | 0.33 |
| Snapdragon 855 | 7 | 10 | 8 | 0.70 |
| Snapdragon 865 | 15 | 10 | 12 | 1.5 |
| Snapdragon 888 | 26 | 10 | 16 | 2.6 |
| Snapdragon 8 Gen 1 | 52 | 10 | 16 | 5.2 |
Worked example
Why the phone line is flat
Thermal budget
A fanless phone can sustain roughly 10 W before the case gets too hot to hold, so that number is fixed by physics, not by the chip roadmap.Efficiency of the endpoints
Snapdragon 845: 3 / 9 = 0.33 TOPS/W. Snapdragon 8 Gen 1: 52 / 10 = 5.2 TOPS/W.Ratio
5.2 / 0.33 ≈ 16x efficiency, which is 17x performance divided by 1.1x power.Result
All of the gain is efficiency. Under a fixed lid, TOPS per watt is the only lever.
Apple Neural Engine: the same lesson from a different vendor
Apple describes the Neural Engine as an energy-efficient, high-throughput engine for ML inference on its own silicon. Its newsroom gives the per-generation numbers the slide plots: 600 billion operations per second for the A11 in 2017, 5 trillion for the A12, 11 trillion for the 16-core A14, 15.8 trillion for the A15 and "nearly 17 trillion" for the A16 (Apple Newsroom). The A17 Pro's 35 TOPS comes from Apple's 2023 event rather than the newsroom text, which only says "up to 2x faster". The products on the slide span an iPhone (A14), an iPad (A15) and an iMac with the M1 Max, the same engine design scaled up.
| Chip | TOPS | Power W | Memory GB | TOPS/W |
|---|---|---|---|---|
| A11 (2017) | 0.6 | 8 | 3 | 0.075 |
| A12 (2018) | 5 | 6 | 4 | 0.83 |
| A13 (2019) | 6 | 6 | 4 | 1.0 |
| A14 (2020) | 11 | 6 | 6 | 1.83 |
| A15 (2021) | 15.8 | 6 | 6 | 2.63 |
| A16 (2022) | 17 | 8 | 6 | 2.13 |
| A17 Pro (2023) | 35 | not plotted | 8 | not computable |
From A11 to A17 the engine gained about 58x in throughput while the estimated power sat between 6 and 8 W. Two vendors, two architectures, one shape: a rising performance line under a flat power line.
NVIDIA Jetson: a ladder instead of a lid
A Jetson is a complete system on module: GPU, CPU, memory, power management and high-speed interfaces on one board that plugs into a carrier. It targets robots, drones and industrial edge boxes, and those have what a phone lacks: a fan and a battery or wall power. So NVIDIA sells a ladder of tiers, each with a configurable power range, and the slide plots the top of each range: Nano at 5 to 10 W, TX2 at 7.5 to 15 W, Xavier NX at 10 to 20 W, AGX Xavier at up to 30 W, AGX Orin 32GB at 15 to 40 W and AGX Orin 64GB at 15 to 60 W (NVIDIA Jetson pages, Connect Tech comparison).
| Module | TOPS | Power W | Memory GB | TOPS/W |
|---|---|---|---|---|
| Nano | 0.5 | 10 | 4 | 0.05 |
| TX2 | 1.3 | 15 | 4 | 0.087 |
| Xavier NX | 21 | 20 | 8 | 1.05 |
| AGX Xavier | 32 | 30 | 16 | 1.07 |
| AGX Orin 32GB | 200 | 40 | 32 | 5.0 |
| AGX Orin 64GB | 275 | 60 | 64 | 4.6 |
Here performance grew about 550x (0.5 to 275 TOPS) while power grew 6x, so efficiency still rose about 90x. The difference from the phone families is not the efficiency trend but the freedom to spend more watts when the application can afford them. A warehouse robot on a 60 W budget gets a different chip than a drone on 10 W.
Three families, one lesson
- Snapdragon 845 to 8 Gen 1
- 17x performance, 1.1x power, fixed lid
- Apple A11 to A17
- 58x performance, about 1x power, fixed lid
- Jetson Nano to AGX Orin 64GB
- 550x performance, 6x power, ladder of tiers
The trap: TOPS from different vendors are not one axis
It is tempting to line up the A17 Pro at 35, the Snapdragon 888 at 26 and the Jetson AGX Orin at 275 and rank them. Do not. NVIDIA's Xavier and Orin figures are INT8 (Orin sparse INT8), while Nano and TX2 are FP16 FLOPS (NVIDIA Jetson pages). The cloud numbers on slide 18 are dense FP16. Qualcomm sums INT8 throughput across the CPU, GPU and Hexagon together. Apple does not state a precision at all. Sze, Chen, Yang and Emer titled a whole paper on this: "TOPS/W (Alone) Considered Harmful". Their point is that peak numbers say nothing about utilization on a real network; a fair comparison needs the same precision, the same workload and a measured, not theoretical, throughput (Sze et al., 2020).
Recall
The Snapdragon 845 and the 8 Gen 1 both run near 10 W. What changed between them, and by how much?
Recall
How does the Jetson family differ from phone chips in the power column, and why?
Recall
Why can you not rank a 35 TOPS Apple A17 Pro against a 26 TOPS Snapdragon 888 from those numbers alone?
Quick check
Across Snapdragon 845 to 8 Gen 1, performance rose about 17x while power stayed near 10 W. What forced that pattern?
Quick check
Which family on slides 19 to 21 shows power scaling up together with performance?
Quick check
Why are TOPS figures from different vendors not directly comparable?
The STM32F746NG is one chip with a Cortex-M7 core at 216 MHz, 1 MB of flash and 320 kB of SRAM, drawing about 360 mW. It is the "off-the-shelf commercial microcontroller" on which MCUNet ran ImageNet-class vision in part 01 (slide 7). Against the smallest Jetson, the Nano at 10 W and 4 GB, it has 28x less power and 12,500x less memory. This is the tier that TinyML is named for.
A microcontroller is a compact integrated circuit designed for embedded systems, integrating a processor, memory and input/output peripherals on a single chip. The MCUNet paper adds what the definition implies: these are "bare-metal devices that do not have an operating system, nor do they have DRAM" (Lin et al., 2020). Everything a model needs, weights and activations alike, must live in the on-chip flash and SRAM, because there is nothing else.
The units drop two prefixes
Slide 22 quietly changes the axes. Power is in milliwatts, not watts. Memory is in kilobytes, not gigabytes. Performance is in DMIPS, not TOPS. Each change is a signal that this tier is a different world, and the last one deserves the most care.
| Board | Core | Clock MHz | DMIPS | Power mW | SRAM kB | Flash | DMIPS/mW |
|---|---|---|---|---|---|---|---|
| Arduino Zero | Cortex-M0+ | 48 | 45 | 6 | 32 | 256 kB | 7.5 |
| Arduino Due | Cortex-M3 | 84 | 158 | 26 | 96 | 512 kB | 6.1 |
| STM32F407VG | Cortex-M4 | 168 | 210 | 132 | 192 (slide says 196) | 1 MB | 1.6 |
| STM32F746NG | Cortex-M7 | 216 | 462 | 360 | 320 | 1 MB | 1.3 |
The core data come from the vendors: the Arduino Zero's SAMD21 is a Cortex-M0+ at 48 MHz with 32 kB SRAM and 256 kB flash; the Due's SAM3X8E is a Cortex-M3 at 84 MHz with 96 kB SRAM; the STM32F407VG is a Cortex-M4 at 168 MHz rated 210 DMIPS with 192 kB SRAM plus 4 kB backup and 1 MB flash; the STM32F746NG is a Cortex-M7 at 216 MHz rated 462 DMIPS with 320 kB SRAM and 1 MB flash (Arduino, Keil and ST documentation).
What DMIPS measures, and what it does not
Dhrystone is a synthetic benchmark that Reinhold Weicker published in 1984 to exercise typical systems code: integer arithmetic, string handling, pointer chasing, no floating point (Weicker, 1984). A DMIPS is Dhrystones per second divided by 1757, the score of a VAX 11/780, which was nominally a one-MIPS machine. Arm publishes DMIPS per MHz for each core so that a clock frequency turns into a rating: Cortex-M0+ 0.95, Cortex-M3 and M4 1.25, Cortex-M7 2.14 (Arm Cortex-M comparison table).
Worked example
Rebuilding the slide's DMIPS from Arm's table
STM32F746, Cortex-M7
2.14 × 216 = 462.2, matching the slide's 462.STM32F407, Cortex-M4
1.25 × 168 = 210, matching the slide.Arduino Zero, Cortex-M0+
0.95 × 48 = 45.6, matching the slide's 45.Arduino Due, Cortex-M3
1.25 × 84 = 105, but the slide says 158, which implies about 1.88 DMIPS/MHz. That is an optimized-compiler score; Arm notes that Dhrystone results depend heavily on compiler switches.Result
DMIPS is a core property times a clock. It says nothing about multiply-accumulate throughput.
So why can you not convert DMIPS into a small TOPS? Because the benchmark contains no MACs, and a neural network is almost nothing but MACs. You can only bound the MCU from above by counting what its SIMD unit could do at best.
Worked example
An upper bound on microcontroller TOPS
Best-case MAC rate
A Cortex-M7 can issue at most two 16-bit MACs per cycle with its SIMD instructions: 216 × 10^6 × 2 = 4.3 × 10^8 MACs per second.Convert to operations
4.3 × 10^8 × 2 = 8.6 × 10^8 operations per second, about 0.0009 TOPS.Compare with the edge tier
Jetson Nano at 0.5 TOPS is about 580x higher; Snapdragon 8 Gen 1 at 52 TOPS about 60,000x.Result
Even after a generous conversion, the MCU sits three to five orders of magnitude below the accelerators. The design goal at this tier is fitting the workload in memory, not maximizing TOPS.
One more pattern in the table is worth noticing: DMIPS per milliwatt falls as the boards get faster, from 7.5 on the Zero to 1.3 on the F746. The faster core pays more energy per instruction. At this tier nobody buys the F746 for efficiency; they buy it because 320 kB is the smallest SRAM in which a useful vision model can breathe.
Recall
Define a microcontroller in one sentence and give the STM32F746's two memory numbers.
Recall
What does DMIPS measure, and why can it not be compared with TOPS?
Recall
Compute the DMIPS of a Cortex-M7 at 216 MHz using Arm's 2.14 DMIPS/MHz, and the ratio of a phone's 4 GB to the F746's 320 kB.
Quick check
What does the DMIPS figure on slide 22 measure?
Quick check
Which of the four boards is the Cortex-M7 device that MCUNet targeted in part 01?
Take ResNet-50, the workhorse image classifier from part 01, with 25,557,032 parameters (torchvision). At FP32 its weights are 102 MB; at FP16, 51 MB; at INT8, 25.6 MB. A cloud GPU holds the FP32 version 783 times over in its HBM. A phone stores it in 256 GB of flash with room for thousands of copies. A microcontroller's 1 MB flash cannot hold even the INT8 version, which is 25.6x too big. Slide 23 turns this into three tiers with two numbers each, and the ratios between them are the thesis of the course.
The lecture calls the tiers cloud AI, mobile AI and tiny AI, and gives each tier two budgets. Activation memory is the working memory that holds intermediate results during computation: 80 GB of HBM on an A100-class cloud GPU, 4 GB of DRAM on a phone, 320 kB of SRAM on the STM32F746. Weight storage is the persistent memory that holds the model: terabytes to petabytes in a data center, 256 GB of phone flash, 1 MB of on-chip flash.
| Tier | Example device | Activation memory | Weight storage | Memory vs tiny | Storage vs tiny |
|---|---|---|---|---|---|
| Cloud AI | A100-class GPU | 80 GB | about 1 TB or more | 250,000x | about 1,000,000x |
| Mobile AI | flagship phone | 4 GB | 256 GB | 12,500x | 256,000x |
| Tiny AI | STM32F746 | 320 kB | 1 MB | 1x | 1x |
Adjacent ratios worth memorizing
- Cloud to mobile, activation
- 80 GB / 4 GB = 20x
- Mobile to tiny, activation
- 4 GB / 320 kB = 12,500x
- Cloud to tiny, activation
- 20 × 12,500 = 250,000x
- Cloud to mobile, storage
- about 1 TB / 256 GB ≈ 4x (taking the low end of TB/PB)
- Mobile to tiny, storage
- 256 GB / 1 MB = 256,000x
MCUNet states the same gap in words: microcontroller memory is "3 orders of magnitude smaller than mobile devices, and 5-6 orders of magnitude smaller than cloud GPUs" (Lin et al., 2020). Its 2020 table used a V100 with 16 GB and an iPhone 11 with more than 64 GB; the slide updates the cloud and mobile columns to an 80 GB A100 and a 256 GB phone, while the tiny column is unchanged at 320 kB and 1 MB. The top tiers moved; the bottom did not.
Two budgets, not one
The two rows on slide 23 are not interchangeable, and confusing them is the most common mistake in sizing a TinyML deployment. Storage holds the weights persistently, so what matters is the total model size, and on an MCU that budget is the read-only flash. Activation memory is the read-write scratch space used while a layer runs, so what matters is the peak across layers, because a layer's input and output tensors must coexist at the moment it executes. MCUNet puts it in one line: "SRAM constrains the activation size (read and write); Flash constrains the model size (read-only)". A model can fit in flash and still crash at runtime because one wide early layer's activations exceed SRAM, and a model with small activations can still be unloadable because its weights exceed flash.
| Quantity | Size | Cloud, 80 GB HBM | Mobile, 256 GB flash and 4 GB DRAM | Tiny, 1 MB flash and 320 kB SRAM |
|---|---|---|---|---|
| FP32 weights | 102.2 MB | yes, 783x headroom | yes | no, 102x over |
| FP16 weights | 51.1 MB | yes | yes | no, 51x over |
| INT8 weights | 25.6 MB | yes | yes | no, 25.6x over |
| Peak activation (MCUNet) | 7.2 MB | yes | yes | no, 22.5x over 320 kB SRAM |
Worked example
Two budgets, one model: MobileNetV2 at INT8 on the STM32F746
Storage check
MobileNetV2 INT8 weights are 3.4 MB (MCUNet Table 1). Against 1 MB of flash that is 3.4x over.Activation check
Its peak activation is 1.7 MB. Against 320 kB of SRAM that is 5.3x over.What MCUNet did
Co-designed the network (TinyNAS, a memory-aware architecture search) with the runtime (TinyEngine), cutting SRAM use by 3.5x and flash by 5.7x versus quantized MobileNetV2 (Lin et al., 2020).Result
Both budgets had to be satisfied separately. Quantization alone (4x from FP32 to INT8) closes neither gap; the architecture and the runtime had to change too.
Why the rest of the course exists
Put the two halves of this lecture side by side. The largest model in part 02, MT-NLG at 530B parameters, needs 1.06 TB of FP16 weights. The smallest tier here offers 1 MB. That is a factor of about one million, six orders of magnitude. GPU memory grew 12x in eight years, and phone memory grew 4x across the Snapdragon generations on slide 19. No hardware trend closes six orders of magnitude on any timescale that matters. So the model must change.
Worked example
530B at FP16 against each tier
Cloud
1.06 TB / 80 GB = 13.25: fourteen A100s just for the weights, as computed in the first concept.Mobile
1.06 TB / 256 GB = 4.1: does not fit even the phone's storage, let alone its 4 GB of working memory.Tiny
1.06 TB / 1 MB = 1,060,000: a million times over.Result
Every tier below the cloud rejects the model. Compression is not optional; it is the subject.
Each later lecture is one lever on the model side of this gap. Pruning removes weights; quantization shrinks each remaining weight from 4 bytes to 1 or fewer; neural architecture search, including Once-for-All from part 01, designs networks under an explicit memory budget; knowledge distillation transfers a large model's accuracy into a small one; and algorithm and system co-design, as in TinyEngine, makes the runtime spend the budget wisely. Slide 24 credits the source of this framing: the deck follows Prof. Song Han's MIT 6.5940 course, TinyML and Efficient Deep Learning Computing, whose introductory lecture carries the same charts (MIT HAN Lab).
Recall
Give the six numbers on slide 23.
Recall
Distinguish activation memory from weight storage and name the microcontroller component for each.
Recall
Does INT8 ResNet-50 fit the tiny AI tier? Check both budgets.
Quick check
Using 1 GB = 1,000,000 kB, what is the ratio of cloud AI activation memory (80 GB) to tiny AI (320 kB)?
Quick check
A model's INT8 weights fit in an MCU's 1 MB flash, yet inference crashes. What is the most likely reason?
Quick check
On slide 23, which budget does the 256 GB figure for mobile AI describe?
Quick check
Why does the course turn to compression, quantization and NAS rather than waiting for hardware?
Recap
If you remember nothing else
- Slide 17 repeats the three pillars. Part 01 covered algorithm and data; this part is the hardware pillar.
- P100 to B100: dense FP16 18.7 to 1750 TOPS (94x), power 250 to 700 W (2.8x), memory 16 to 192 GB (12x), bandwidth 732 to 8192 GB/s (11x). TOPS/W: 0.075, 0.42, 0.78, 1.41, 2.5.
- TOPS counts two operations per MAC. NVIDIA headline numbers double with 2:4 sparsity; the slide and this part use dense figures.
- The memory wall: peak compute grows about 3x every two years while DRAM bandwidth grows about 1.6x, so bandwidth and capacity, not TOPS, bound LLM serving.
- Phones are capped near 10 W by heat. Snapdragon 845 to 8 Gen 1 went 3 to 52 TOPS (17x) at flat power; Apple A11 to A17 went 0.6 to 35 TOPS at 6 to 8 W.
- Jetson is a system on module whose power scales with tier: 0.5 TOPS at 10 W (Nano) to 275 TOPS at 60 W (AGX Orin 64GB).
- TOPS figures depend on precision, sparsity and workload. Compare only within a family at the same precision.
- A microcontroller puts processor, memory and I/O on one chip. STM32F746: Cortex-M7, 216 MHz, 462 DMIPS, 320 kB SRAM, 1 MB flash, about 360 mW.
- DMIPS is an integer benchmark (Dhrystones per second divided by 1757), not a neural network throughput. MCU compute is on the order of 0.001 TOPS.
- Cloud, mobile, tiny: 80 GB, 4 GB, 320 kB of activation memory (20x and 12,500x steps, 250,000x end to end); about 1 TB, 256 GB, 1 MB of weight storage (256,000x mobile to tiny).
- Activation memory (SRAM, peak per layer) and weight storage (flash, total size) are separate budgets. ResNet-50 fails both on an MCU, by about 100x and 22x.
- A 530B FP16 model (1.06 TB) is a million times a 1 MB flash. The course closes the gap on the model side: pruning, quantization, NAS, distillation and co-design.
- The deck follows Prof. Song Han's MIT 6.5940 TinyML and Efficient Deep Learning Computing.
Sources
- MIT 6.5940: TinyML and Efficient Deep Learning Computing, Fall 2024DocsMIT HAN Lab, Song HanSchedule with Lecture 1 Introduction slides; the source the deck credits on slide 24(opens in a new tab)
- TinyML and Efficient AI Computing, course landing pageDocsMIT HAN LabCurrent course page (efficientml.ai redirects here)(opens in a new tab)
- MCUNet: Tiny Deep Learning on IoT DevicesPaperNeurIPS 2020, Lin, Chen, Lin, Cohn, Gan, HanTable 1 (cloud, mobile, tiny budgets; ResNet-50 and MobileNetV2 sizes), SRAM versus flash constraint, no DRAM and no OS(opens in a new tab)
- AI and Memory WallPaperIEEE Micro 2024, Gholami, Yao, Kim, Hooper, Mahoney, KeutzerPeak FLOPS 3.0x per two years versus DRAM bandwidth 1.6x and interconnect 1.4x(opens in a new tab)
- How to Evaluate Deep Neural Network Processors: TOPS/W (Alone) Considered HarmfulPaperIEEE Solid-State Circuits Magazine 2020, Sze, Chen, Yang, EmerWhy peak TOPS and TOPS/W are not comparable across chips without workload and utilization(opens in a new tab)
- Efficient Processing of Deep Neural Networks: A Tutorial and SurveyPaperProceedings of the IEEE 2017, Sze, Chen, Yang, EmerMetrics beyond peak throughput for evaluating accelerators(opens in a new tab)
- Using DeepSpeed and Megatron to Train Megatron-Turing NLG 530BPaperSmith et al., 2022530 billion parameters(opens in a new tab)
- torchvision resnet50 weightsDocsPyTorch25,557,032 parameters, 4.09 GFLOPS(opens in a new tab)
- Deep Residual Learning for Image RecognitionPaperHe, Zhang, Ren, Sun, 2015ResNet-50(opens in a new tab)
- NVIDIA Tesla P100 PCIe datasheetDocsNVIDIA18.7 TFLOPS FP16, 16 GB HBM2 at 732 GB/s, 250 W(opens in a new tab)
- NVIDIA V100 Tensor Core GPUDocsNVIDIA125 TFLOPS Tensor, 900 GB/s, 300 W(opens in a new tab)
- NVIDIA A100 Tensor Core GPUDocsNVIDIA312 TFLOPS dense and 624 with sparsity, 80 GB, 2,039 GB/s, 400 W(opens in a new tab)
- NVIDIA H100 Tensor Core GPUDocsNVIDIA1,979 TFLOPS with sparsity, 80 GB, 3.35 TB/s, up to 700 W; NVL variant 94 GB(opens in a new tab)
- NVIDIA Blackwell Platform Arrives to Power a New Era of ComputingArticleNVIDIA Newsroom, 18 March 2024Blackwell announcement, availability later in 2024(opens in a new tab)
- NVIDIA Blackwell deployments: HGX B100 and B200 specificationsArticleExxactSecondary source reproducing NVIDIA's HGX table: 192 GB, 8 TB/s, 700 W, 3.5 PFLOPS FP16 sparse per GPU(opens in a new tab)
- Snapdragon 888 5G Mobile Platform product briefDocsQualcommFused AI accelerator, 26 TOPS, up to 3x performance per watt, up to 16 GB(opens in a new tab)
- Snapdragon 8 Gen 1 Mobile Platform product briefDocsQualcommUp to 4x faster, best performance per watt, INT8, INT16 and FP16(opens in a new tab)
- Qualcomm Robotics RB5 Platform product briefDocsQualcomm15 TOPS robotics platform pictured on slide 19(opens in a new tab)
- List of Qualcomm Snapdragon processorsArticleWikipediaSlide 19's stated source; the TOPS and power figures are community-compiled, not Qualcomm statements(opens in a new tab)
- The future is here: iPhone XDocsApple NewsroomA11 Neural Engine, 600 billion operations per second(opens in a new tab)
- iPhone XS and iPhone XS MaxDocsApple NewsroomA12 Neural Engine, 5 trillion operations per second(opens in a new tab)
- Apple unveils all-new iPad Air with A14 BionicDocsApple NewsroomA14 16-core Neural Engine, 11 trillion operations per second(opens in a new tab)
- Apple unveils iPhone 13 Pro and iPhone 13 Pro MaxDocsApple NewsroomA15 Neural Engine, 15.8 trillion operations per second(opens in a new tab)
- Apple debuts iPhone 14 Pro and iPhone 14 Pro MaxDocsApple NewsroomA16 Neural Engine, nearly 17 trillion operations per second(opens in a new tab)
- Apple unveils iPhone 15 Pro and iPhone 15 Pro MaxDocsApple NewsroomA17 Pro Neural Engine up to 2x faster; the 35 TOPS figure is from the event, not this text(opens in a new tab)
- Jetson ModulesDocsNVIDIA DeveloperSystem on module family overview(opens in a new tab)
- Jetson Nano Developer KitDocsNVIDIA472 GFLOPS, 4 GB, 5 to 10 W(opens in a new tab)
- Jetson TX2 ModuleDocsNVIDIA1.33 TFLOPS, 8 GB, 7.5 to 15 W(opens in a new tab)
- Jetson Xavier NXDocsNVIDIA21 TOPS, 8 or 16 GB, 10 to 20 W(opens in a new tab)
- Jetson AGX XavierDocsNVIDIA32 TOPS; 16 GB on the original module, later 32 GB and 64 GB; 10, 15 or 30 W modes(opens in a new tab)
- Jetson OrinDocsNVIDIAAI performance stated as sparse INT8 TOPS; current JetPack figures differ from the 2022 values on the slide(opens in a new tab)
- Jetson Module ComparisonArticleConnect TechSlide 21's source: AGX Orin 32GB 200 TOPS at 15 to 40 W, AGX Orin 64GB 275 TOPS at 15 to 60 W(opens in a new tab)
- STM32F746NGDocsSTMicroelectronicsCortex-M7 at 216 MHz, 462 DMIPS and 2.14 DMIPS/MHz, 1 MB flash, 320 KB SRAM; verified via the search index because ST blocks automated fetches(opens in a new tab)
- STM32F407VG device dataDocsKeilCortex-M4 at 168 MHz, 210 DMIPS and 1.25 DMIPS/MHz, 1 MB flash, 192 plus 4 KB SRAM(opens in a new tab)
- Arduino ZeroDocsArduinoSAMD21 Cortex-M0+ at 48 MHz, 256 KB flash, 32 KB SRAM(opens in a new tab)
- Arduino Due documentationDocsArduinoSAM3X8E Cortex-M3 at 84 MHz, 96 KB SRAM(opens in a new tab)
- Arm Cortex-M Processor Comparison TableDocsArmDMIPS/MHz: Cortex-M0+ 0.95, M3 1.25, M4 1.25, M7 2.14(opens in a new tab)
- Dhrystone Benchmarking for ARM Cortex ProcessorsDocsArmDMIPS is Dhrystones per second divided by 1757; small integer benchmark; results depend on compiler switches(opens in a new tab)
- Dhrystone: a synthetic systems programming benchmarkPaperCommunications of the ACM 27(10), 1984, Reinhold WeickerThe original benchmark; bibliographic record confirmed via search since the ACM DL blocked direct fetches(opens in a new tab)