Majid Al-RaimiFull guide

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
Understood
0/15 concepts

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

  1. State the course challenge and name the three pillars, with one efficiency lever per pillar.
  2. Define top-5 error and top-1 accuracy precisely and explain why they cannot be compared directly.
  3. Read a bubble chart of top-1 accuracy versus MACs and parameters, and quantify diminishing returns.
  4. Compute a computation reduction ratio and explain the Pareto frontier shift produced by architecture search.
  5. 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.

maxθ, A Acc(θ,A)s.t.MACsC,  MemoryM,  LatencyT,  EnergyE\max_{\theta,\ \mathcal{A}}\ \text{Acc}(\theta, \mathcal{A}) \quad \text{s.t.}\quad \text{MACs} \le C,\ \ \text{Memory} \le M,\ \ \text{Latency} \le T,\ \ \text{Energy} \le E
Efficient deep learning as a budgeted problem: weights and architecture are chosen under compute, memory, latency and energy limits

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).

PillarContribution to AlexNet in 2012Efficiency lever in this course
AlgorithmA deep CNN with ReLU units and dropout, trained with SGD on two GPUsPruning, quantization, distillation, neural architecture search (pruning starts in lecture 04)
HardwareTwo GTX 580 GPUs, 3 GB each, running the convolutions for about six daysAccelerators from cloud GPUs to phone NPUs and microcontrollers (part 03)
DataImageNet: about 1.2 million labeled training images in 1000 classesData that stays on the device and drives local, private learning (slide 8)
The three pillars, what each contributed to the 2012 break, and what efficient deep learning does with it

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.

Algorithm (pruning, quantization, distillation or neural architecture search), hardware (accelerators such as the Hexagon DSP, the Apple Neural Engine or NVIDIA Jetson), data (locally collected data that enables on-device learning; historically, larger datasets such as ImageNet raised accuracy).

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.

errtop-5=1Ni=1Nminj{1,,5}1[cijCi]\text{err}_{\text{top-5}} = \frac{1}{N}\sum_{i=1}^{N} \min_{j \in \{1,\dots,5\}} \mathbb{1}\big[c_{ij} \ne C_i\big]
Top-5 error: image i counts as wrong only if none of its five returned labels c_ij equals the true label C_i

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.

Winning top-5 error by year. The 2012 bar marks the deep learning break (9.4 points below 2011), and from 2015 the winners sit under the 5.1% human line.
YearWinnerTop-5 error (%)Source
2010NEC28.2Russakovsky et al., Table 5
2011XRCE25.8Russakovsky et al., Table 5
2012SuperVision (AlexNet)16.4Russakovsky et al., Table 5
2013Clarifai11.7Russakovsky et al., Table 6
2014GoogLeNet6.7Russakovsky et al., Table 7
2015ResNet (ensemble of six models, deepest 152 layers)3.6 (3.57)He et al., 2016
2016Trimps-Soushen3.0 (2.99)ILSVRC 2016 results
2017SENet (WMW)2.3 (2.25)Hu et al., 2018
HumanOne trained annotator5.1Russakovsky et al., Sec. 6.4
ILSVRC winning entries, top-5 error on the test set

Worked example

Reading the drop

  1. 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.
  2. 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).
  3. 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.
  4. 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?

Top-5 error is the fraction of test images whose true label does not appear among the five highest-scoring predicted classes. The mushroom is a top-5 hit (and a top-1 miss). The cherry is a miss under both rules, because cherry is not among its five labels.

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.

MACsconv=HoutWoutCoutCinkhkw\text{MACs}_{\text{conv}} = H_{\text{out}} \cdot W_{\text{out}} \cdot C_{\text{out}} \cdot C_{\text{in}} \cdot k_h \cdot k_w
Every output value needs one MAC per input channel per kernel position

Worked example

One 3 by 3 layer

  1. Shape

    A 3 x 3 convolution with 64 input and 64 output channels producing a 56 x 56 map.
  2. Multiply out

    56 x 56 x 64 x 64 x 9 = 115,605,504 MACs.
  3. 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.

Slide 5 as geometry: handcrafted bubbles sized by parameters. The staircase is the best accuracy available at each MAC budget; the stars and the second staircase preview slide 6.
ModelMACs (B)Top-1 (%)ParametersWhere the number comes from
MobileNetV10.5770.64.2 Mpaper (Howard et al.)
IGCV3-D0.372.3about 3.5 Mchart
InceptionV22.074.8about 11 Mchart
DenseNet-1212.975.0about 8 Mchart
DenseNet-1693.476.2about 14 Mchart
ResNet-503.975.325.5 MMACs and params from Sze et al., accuracy from the chart
ResNeXt-504.277.8about 25 Mchart
DenseNet-2645.777.8about 33 Mchart
InceptionV35.778.8about 24 Mchart
DPN-926.579.3about 38 Mchart
ResNet-1017.676.444.5 MMACs from He et al. (Table 1); parameters from torchvision
ResNeXt-1018.078.9about 44 Mchart
Xception8.479.0about 23 Mparams from Chollet
The handcrafted models on slide 5 (values marked chart are read from the figure and approximate)

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.

points per billion=Top-1newTop-1oldMACsnewMACsold\text{points per billion} = \frac{\text{Top-1}_{\text{new}} - \text{Top-1}_{\text{old}}}{\text{MACs}_{\text{new}} - \text{MACs}_{\text{old}}}
The marginal accuracy bought by each extra billion MACs
UpgradeExtra MACs (B)Extra top-1 (points)Points per billion MACs
MobileNetV1 to ResNet-503.9 - 0.57 = 3.3375.3 - 70.6 = 4.74.7 / 3.33 = 1.41
ResNet-50 to Xception8.4 - 3.9 = 4.579.0 - 75.3 = 3.73.7 / 4.5 = 0.82
ResNet-50 to ResNet-1017.6 - 3.9 = 3.776.4 - 75.3 = 1.11.1 / 3.7 = 0.30
Three upgrades on slide 5, cheapest first

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

  1. Convert to one unit

    Xception 8.4 B = 8400 M MACs; ResNet-50 3.9 B = 3900 M; Once-for-All 595 M.
  2. Divide reference by new

    8400 / 595 = 14.1 and 3900 / 595 = 6.6.
  3. Result

    Once-for-All needs 14x less computation than Xception and 6.6x less than ResNet-50 while being more accurate than both.
ModelMACs (B)Top-1 (%)Reduction relative to OFA
MobileNetV10.56970.60.96x (about the same budget)
ResNet-503.975.36.6x
Xception8.479.014.1x
Once-for-All0.59580.01x (reference)
Once-for-All against three handcrafted references (reduction is reference MACs divided by 595 M)

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.

AB    AccAAccB  MACsAMACsB, with at least one strictA \succ B \iff \text{Acc}_A \ge \text{Acc}_B \ \wedge\ \text{MACs}_A \le \text{MACs}_B,\ \text{with at least one strict}
Dominance on the accuracy versus MACs plane; the frontier is the set of undominated models
ExplorerAccuracy versus MACs
Show
012345678969717375777981MACs (billion), lower is bettertop-1 (%), higher is betterIGCV3-D
Reduction ratio13xless3.900 ÷ 0.300 B MACs
Accuracy change-3.0points72.3 minus 75.3
Points per extra B MACs+0.83accuracy change divided by MACs change
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.

3900 / 595 = 6.6x and 8400 / 595 = 14.1x.

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.

TierMemoryStorageGap from the tier above
Cloud AI (NVIDIA V100)16 GBTB to PBreference
Mobile AI (iPhone 11)4 GBmore than 64 GB4x less memory, 1000x less storage
Tiny AI (STM32F746)320 kB1 MBtable prints 3100x less memory, 64000x less storage
MCUNet Table 1: memory and storage across three tiers of AI hardware
Memory on a log scale: 16 GB, 4 GB and 320 kB. Even an int8 MobileNetV2 at 1.7 MB overshoots the microcontroller's SRAM by 5.3x.

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?

  1. Weights in FP32

    25.5 M parameters times 4 bytes is 102 MB, matching the paper.
  2. Against 1 MB of flash

    102 / 1 = 102x too large.
  3. Even at 8 bits

    25.5 MB, still 25x too large; quantization alone cannot save it.
  4. 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?

320 kB SRAM and 1 MB flash. A V100 has 16 GB of memory, five orders of magnitude more, and terabytes to petabytes of storage; the paper prints the tiers as 4x then 3100x for memory and 1000x then 64000x for storage.

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.

Data reaches the device and stops. The update loop closes locally; the arrow to the cloud is drawn and then crossed out.

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.

ResourceInferenceTraining
Compute per exampleOne forward passForward plus backward, about 3x the multiply-adds (backward is about 2x forward)
ActivationsFreed layer by layer as the input flows throughEvery layer's activations kept until the backward pass returns
Extra stateWeights onlyWeights, gradients and optimizer state (momentum, Adam moments)
Memory scalingLargest single layerGrows with depth and batch size
What inference and training each have to pay

Worked example

Training MobileNetV1 on a microcontroller, naively

  1. Weights

    4.2 M parameters in FP32 is 16.8 MB.
  2. Gradients and momentum

    One gradient per weight and one momentum value per weight: two more copies, another 33.6 MB.
  3. Total before activations

    50.4 MB of state, against 320 kB of SRAM.
  4. 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.

Costs: the backward pass costs about twice the forward pass, so a training step is roughly three times an inference pass; every layer's activations must be stored until the backward pass returns, scaling with batch size and depth; optimizer state adds extra copies of every parameter. Plus limited power. Benefits: better privacy, lower cost, customization, life-long learning.

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

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

  1. Name SAM's three blocks, say which one dominates the cost, and explain what EfficientViT-SAM swaps to reach 48.9x.
  2. Explain why compute follows tokens and denoising steps rather than parameters, and why diffusion cost is super-quadratic in resolution.
  3. 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.
  4. Turn frames per second into a frame time and show which of Fast-LiDARNet's two levers crosses the 30 fps line.
  5. 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.

The image encoder is the big block. It fills once per image, then the prompt encoder and decoder answer any number of prompts at almost no cost

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.

SimulatorSwap the block that dominates
Image encoder

Hover, tap or focus a block to see what it costs and whether EfficientViT-SAM touches it.

A100 TensorRT FP16 throughput11 img/s
SAM-ViT-H baseline 11 img/sscale to 800 img/s
Speedup1.0x11 ÷ 11 img/s
Encoder MACs cut1.0x2973 GMACs divided by the new encoder
Zero-shot COCO mAP46.5the baseline

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.

ModelEncoder paramsEncoder MACsThroughput (img/s)mAPSpeedup vs SAM-ViT-H
SAM-ViT-H641.1 M2973 G1146.51x
EfficientViT-SAM-XL1203.3 M322 G18247.816.5x
EfficientViT-SAM-XL0117.0 M185 G27847.525.3x
EfficientViT-SAM-L261.3 M69 G53846.648.9x
EfficientViT-SAM-L147.7 M49 G63846.258.0x
EfficientViT-SAM-L034.8 M35 G76245.769.3x
EfficientSAM25.3 M247 G18344.416.6x
EdgeSAM9.6 M20 G44942.140.8x
MobileSAM9.8 M39 G27838.725.3x
Zero-shot COCO instance segmentation, A100 with TensorRT FP16 (EfficientViT-SAM, Table 1)

Worked example

Compute reduction versus measured speedup

  1. MAC ratio

    SAM-ViT-H to L2: 2973 / 69 ≈ 43.1x fewer encoder MACs.
  2. Throughput ratio

    538 / 11 ≈ 48.9x more images per second.
  3. 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.
  4. 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.

Image encoder (runs once per image and dominates the cost), prompt encoder, lightweight mask decoder.

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?

It replaces only the image encoder with EfficientViT and keeps the prompt encoder and mask decoder. L2 runs at 538 versus 11 img/s with 46.6 versus 46.5 zero-shot COCO mAP.

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

  1. Wall-clock time

    150,000 GPU-hours / 256 GPUs ≈ 586 hours, which is about 24.4 days with every GPU busy the whole time.
  2. Price per GPU-hour

    $600,000 / 150,000 GPU-hours = $4.00 per A100-hour.
  3. Cross-check

    256 GPUs × 24 h × 24.4 days ≈ 149,900 GPU-hours, matching the stated total.
  4. 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
RunA100sGPU-hoursWall clockCost
Stable Diffusion, 2022256about 150,000about 24 daysabout $600,000
MosaicML SD2 base, 2023128about 21,0006.8 daysunder $42,000
The original run next to MosaicML's SD2 base run

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.

ModelParametersWorkloadMACsRatio
ViT-H0.6 B518 x 518 image, one forward pass1.02 Tbaseline
Llama 3 8B8 B1,024-token context, 512 output tokens11.2 T11x ViT-H
FLUX.112 B1K x 1K image, one denoising step37.2 T36x ViT-H, 3.3x Llama 3
CogVideoX5.6 B480 x 720, 49 frames, one denoising step332 T8.9x FLUX.1, 326x ViT-H
MACs for one pass, from slide 12 (log axis on the slide)

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.

MACs per passNparamsNtokens+cNtokens2d\text{MACs per pass} \approx N_{\text{params}}\,N_{\text{tokens}} + c\,N_{\text{tokens}}^{2}\,d
Why tokens, not parameters, set the bill: a linear term and a quadratic attention term

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.

SimulatorFLUX.1 cost versus resolution
1024 × 1024
05001000150020001024153620482560307235844096MACs (T), one denoising stepdashed: quadratic in side lengthsolid: fit to the slide, dots: slide readings
Pixels1,048,5761024 squared, 1.0x the 1024 image
Latent tokens4,096(side ÷ 16) squared, typical latent patching
MACs per step37.2T1.0x the 1024 cost
Quadratic reference37.2Tif cost only followed pixel count
Token-linear share31.6Tlinear layers, grows with tokens
Attention share5.6Tgrows with tokens squared
50-step image1,860Tper-step MACs times sampler steps

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

  1. Model

    Let r = side / 1024 and write MACs(r) = A r² + B r⁴: a token-linear part and an attention part.
  2. 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.
  3. 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).
  4. 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?

150,000 / 256 ≈ 586 hours, about 24 days. $600,000 / 150,000 = $4 per GPU-hour.

Recall

Why does CogVideoX with 5.6 B parameters need 8.9x the MACs of FLUX.1 with 12 B parameters?

It denoises a stack of latent frames per step, about four times FLUX.1's token count. Compute follows tokens (and tokens squared for attention), not parameter count.

Recall

From 1024 to 4096, how much do pixels grow and how much do FLUX.1 MACs grow, and why the difference?

Pixels grow 16x, MACs about 52x. The linear layers scale with tokens, but attention scales with tokens squared, so the total is super-quadratic in side length.

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.

Four isolated patches each paint their own ship. Let each patch read its neighbours' activations from the previous step and one ship spans the frame

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.

SetupMACs per deviceWork per deviceLatencySpeedupQuality
Original, 1 GPU907 T1x12.3 s1xreference image
Naive patches, 4 GPUs190 T4.8x less3.14 s3.9xduplicated subjects
DistriFusion, 4 GPUs227 T4.0x less4.16 s3.0xno artifacts
DistriFusion, 8 GPUs (paper, not on the slide)113 T8.0x less2.74 s4.5xno artifacts
SDXL at 1280 x 1920, 50-step Euler sampler, A100 GPUs (DistriFusion teaser; slide 13 shows the first three rows)

Worked example

Where the work went

  1. 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.
  2. DistriFusion total

    227 T × 4 = 908 T ≈ 907 T. The full computation is preserved and simply divided by four.
  3. 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.
  4. 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.
parallel efficiency=speedupdevices=3.04=75%\text{parallel efficiency} = \frac{\text{speedup}}{\text{devices}} = \frac{3.0}{4} = 75\%
Naive patches reach 3.9 / 4 = 98% by skipping work; DistriFusion pays 25% for keeping the picture whole

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.

A100sSpeedup over one GPUMarginal speedupParallel efficiency
11xreference100%
21.8x1.8x90%
43.4x1.9x85%
86.1x1.8x76%
DistriFusion on SDXL at 3840 x 3840, A100s (paper; same 50-step Euler sampler as the table above, a larger image). Marginal column divides each speedup by the one above it

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?

Duplicated subjects (four ships for one prompt), because the patches never see each other and each generates its own composition.

Recall

Why is 190 T times 4 less than the original 907 T?

Naive patches skip the cross-patch attention, so they do less total work. DistriFusion's 227 T × 4 = 908 T preserves the whole computation.

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.

Kernel optimisation lifts 5 fps to 18 fps and still misses the 30 fps line. Only the redesigned model crosses it

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.

tframe=1000 msfpst_{\text{frame}} = \frac{1000\ \text{ms}}{\text{fps}}
Frame time from frame rate

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.

ConfigurationRateFrame timeLeverInside 33.3 ms?
MinkowskiNet5 fps200 msnoneno, 167 ms over
MinkowskiNet, optimised sparse kernels18 fps55.6 mssystem: 3.6xno, 22 ms over
Fast-LiDARNet47 fps21.3 msalgorithm: 2.6x more, 9.4x totalyes, 12 ms to spare
Three configurations from slide 14

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.

Sparse-convolution kernel optimisation, 3.6x (5 to 18 fps), and hardware-aware model design, 2.6x (18 to 47 fps), 9.4x in total.

Recall

What is the frame budget at 30 fps, and what is MinkowskiNet's frame time at 5 fps?

1000 / 30 ≈ 33.3 ms budget; 1000 / 5 = 200 ms per frame.

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 parameters climb about 10,000x while GPU memory climbs about 5x on the same FP16 axis. The gap at 2022 is 13x
ModelYearParametersFP16 weightsA100 80 GB GPUs
Transformer20170.05 B0.1 GB1
GPT20180.11 B0.22 GB1
BERT-Large20180.34 B0.68 GB1
GPT-220191.5 B3 GB1
Megatron-LM20198.3 B16.6 GB1
T-NLG202017 B34 GB1
GPT-32020175 B350 GB5
MT-NLG2021 (paper 2022)530 B1,060 GB14
Models on the chart, FP16 weight memory and A100 80 GB count for weights alone
AcceleratorMemoryFP16 parameters it holds
TPU v216 GB8 B
V10032 GB16 B
TPU v332 GB16 B
A10040 GB20 B
A10080 GB40 B
Accelerators on the chart

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.

weight bytes=Nparams×bytes per param,GPUs=weight bytesGPU bytes\text{weight bytes} = N_{\text{params}} \times \text{bytes per param}, \qquad \text{GPUs} = \left\lceil \frac{\text{weight bytes}}{\text{GPU bytes}} \right\rceil
Weights only; activations and the KV cache come on top

Worked example

MT-NLG on A100 80 GB GPUs

  1. FP16

    530 B × 2 bytes = 1,060 GB; 1,060 / 80 = 13.25, so 14 GPUs for the weights alone.
  2. INT8

    530 B × 1 byte = 530 GB; 530 / 80 = 6.6, so 7 GPUs.
  3. INT4

    530 B × 0.5 byte = 265 GB; 265 / 80 = 3.3, so 4 GPUs.
  4. 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.
SimulatorParameters to bytes to GPUs
Precision
Weight memory1,060 GB530 B × 2 bytes per parameter
A100 80 GB GPUs14ceil of GB ÷ 80, weights only
A100 40 GB GPUs27ceil of GB ÷ 40, weights only
One A100 80 GBDoes not fit
needs 1,060 GBof 80 GB
Phone, 4 GB RAM: 265 phonesDoes not fit
Microcontroller, 1 MB weight storageDoes not fit

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.

  1. 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.
  2. Resource-constrained, low-power devices that are not always connected. An edge LLM must work when the link is slow or absent.
  3. 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?

530 B × 2 bytes = 1,060 GB; 1,060 / 80 = 13.25, so 14 GPUs before activations or the KV cache.

Recall

How many FP16 parameters fit in 16 GB, and how much did model size and GPU memory grow over the chart?

8 B parameters. Model size grew about 10,000x and GPU memory about 5x.

Recall

Give the three reasons on slide 16 for running LLMs at the edge.

Local copilot services on laptops, cars and robots; resource-constrained low-power devices that are not always connected; privacy of personal data that should not be uploaded.

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

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

  1. 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.
  2. Explain the memory wall: why 94x more compute on 2.8x more power and 12x more memory makes data movement, not arithmetic, the bottleneck.
  3. Contrast edge accelerator families: a fixed power envelope (Snapdragon, Apple) versus a power ladder (Jetson), and say why TOPS across vendors are not comparable.
  4. Describe a microcontroller, read DMIPS correctly, and state the 320 kB and 1 MB budgets of the STM32F746.
  5. 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).

TOPS=2×MACs per second1012\text{TOPS} = \frac{2 \times \text{MACs per second}}{10^{12}}
One MAC is a multiply plus an add, so two operations
TOPS/W=peak TOPSboard power (W)\text{TOPS/W} = \frac{\text{peak TOPS}}{\text{board power (W)}}
Efficiency, not speed

Five generations, four very different slopes

PartDense FP16 TOPSBandwidth GB/sPower WMemory GBTOPS/W
P100 (2016), PCIe18.7732250160.075
V100 SXM (2017)125900300320.42
A100 SXM (2020)3122,039400800.78
H100 SXM (2022)9903,430700961.41
B100 SXM (2024)1,7508,1927001922.5
Five NVIDIA data center GPUs (slide 18 values, TOPS per watt computed)
TOPS bars climb a log scale by 94x while the watt bars beside them rise only 2.8x on a linear scale

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

  1. Operations available per second

    990 × 10^12 dense FP16 operations per second (NVIDIA H100 page, dense half of 1,979).
  2. 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).
  3. Break-even intensity

    990 / 3.35 ≈ 295 operations per byte. Below this, memory bounds the chip; above it, compute does.
  4. 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.
  5. 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

  1. Bytes of weights at FP16

    530 × 10^9 parameters × 2 bytes = 1.06 × 10^12 bytes = 1.06 TB.
  2. A100 80 GB cards

    1.06 TB / 80 GB = 13.25, so 14 cards before a single activation is stored.
  3. 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.
  4. 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?

A100: 312 / 400 = 0.78 TOPS/W. B100: 1,750 / 700 = 2.5 TOPS/W. About 3.2x better efficiency in four years.

Recall

Performance grew 94x from P100 to B100. By how much did power and memory grow, and what does that imply?

Power 2.8x (250 to 700 W) and memory 12x (16 to 192 GB). Compute outran both, so the cost of moving data to the compute units (the memory wall) becomes the limit, especially for memory-bound work such as LLM decoding.

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.

SimulatorDevice picker: performance, power and memory by tier

NVIDIA data center, dense FP16 TOPS (slide 18)

PerformanceTOPS
18.71253129901,750
PowerW
250300400700700
MemoryGB
16328096192
Performance18.7TOPS
Power250W
Memory16GB
Efficiency0.075TOPS/Wperformance divided by power
First to last in this family
Performance 93.6xPower 2.8xMemory 12xEfficiency 33.4x

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.

PartTOPSPower WMemory GBTOPS/W
Snapdragon 8453940.33
Snapdragon 85571080.70
Snapdragon 8651510121.5
Snapdragon 8882610162.6
Snapdragon 8 Gen 15210165.2
Snapdragon Hexagon (slide 19 values, TOPS per watt computed)
Five Hexagon generations grow 17x in TOPS while a thermal lid at about 10 W never moves

Worked example

Why the phone line is flat

  1. 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.
  2. Efficiency of the endpoints

    Snapdragon 845: 3 / 9 = 0.33 TOPS/W. Snapdragon 8 Gen 1: 52 / 10 = 5.2 TOPS/W.
  3. Ratio

    5.2 / 0.33 ≈ 16x efficiency, which is 17x performance divided by 1.1x power.
  4. 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.

ChipTOPSPower WMemory GBTOPS/W
A11 (2017)0.6830.075
A12 (2018)5640.83
A13 (2019)6641.0
A14 (2020)11661.83
A15 (2021)15.8662.63
A16 (2022)17862.13
A17 Pro (2023)35not plotted8not computable
Apple Neural Engine (slide 20 values, TOPS per watt computed)

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).

ModuleTOPSPower WMemory GBTOPS/W
Nano0.51040.05
TX21.31540.087
Xavier NX212081.05
AGX Xavier3230161.07
AGX Orin 32GB20040325.0
AGX Orin 64GB27560644.6
NVIDIA Jetson (slide 21 values, TOPS per watt computed)

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?

TOPS went from 3 to 52, about 17x, and efficiency from 0.33 to 5.2 TOPS/W, about 16x. A fanless phone cannot raise its power ceiling, so the gain had to be efficiency.

Recall

How does the Jetson family differ from phone chips in the power column, and why?

Power rises with performance, from 10 W (Nano) to 60 W (AGX Orin 64GB), because robots and industrial boxes have fans and a larger battery or wall power. NVIDIA sells a ladder of tiers rather than one thermal envelope.

Recall

Why can you not rank a 35 TOPS Apple A17 Pro against a 26 TOPS Snapdragon 888 from those numbers alone?

TOPS depend on precision (INT8 versus FP16), whether sparsity is counted, which units are summed and the real utilization on a workload. Apple gives no precision, Qualcomm sums CPU, GPU and DSP, and Jetson Orin counts sparse INT8. Sze et al. call TOPS/W alone harmful for exactly this reason.

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.

Processor, SRAM, flash and I/O share one die. Weights are read from flash into the core; activations are read and written between SRAM and the core.

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.

BoardCoreClock MHzDMIPSPower mWSRAM kBFlashDMIPS/mW
Arduino ZeroCortex-M0+4845632256 kB7.5
Arduino DueCortex-M3841582696512 kB6.1
STM32F407VGCortex-M4168210132192 (slide says 196)1 MB1.6
STM32F746NGCortex-M72164623603201 MB1.3
Four microcontroller boards (slide 22 values plus verified core data, DMIPS per mW computed)

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).

DMIPS=Dhrystones per second1757\text{DMIPS} = \frac{\text{Dhrystones per second}}{1757}
Normalized to the VAX 11/780
DMIPS=(DMIPS/MHz)×fclock\text{DMIPS} = (\text{DMIPS/MHz}) \times f_{\text{clock}}
How the slide's numbers arise

Worked example

Rebuilding the slide's DMIPS from Arm's table

  1. STM32F746, Cortex-M7

    2.14 × 216 = 462.2, matching the slide's 462.
  2. STM32F407, Cortex-M4

    1.25 × 168 = 210, matching the slide.
  3. Arduino Zero, Cortex-M0+

    0.95 × 48 = 45.6, matching the slide's 45.
  4. 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.
  5. 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

  1. 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.
  2. Convert to operations

    4.3 × 10^8 × 2 = 8.6 × 10^8 operations per second, about 0.0009 TOPS.
  3. 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.
  4. 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.

A compact integrated circuit for embedded systems that puts a processor, memory and I/O peripherals on a single chip. The STM32F746 has 320 kB of SRAM and 1 MB of flash.

Recall

What does DMIPS measure, and why can it not be compared with TOPS?

Dhrystone MIPS: a synthetic integer benchmark normalized to the VAX 11/780 (Dhrystones per second divided by 1757). It contains no floating point and no MACs, so it is not a neural network throughput figure.

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.

2.14 × 216 ≈ 462 DMIPS. 4 GB / 320 kB = 4,000,000 / 320 = 12,500x, about four orders of magnitude.

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.

TierExample deviceActivation memoryWeight storageMemory vs tinyStorage vs tiny
Cloud AIA100-class GPU80 GBabout 1 TB or more250,000xabout 1,000,000x
Mobile AIflagship phone4 GB256 GB12,500x256,000x
Tiny AISTM32F746320 kB1 MB1x1x
Three tiers on slide 23, with ratios to the tiny tier
Three activation-memory squares whose side lengths follow log size; ResNet-50's 7.2 MB peak activation fits inside the mobile square but spills 22.5x past the tiny SRAM. The flash check for its weights is in the fit table below.
80 GB320 kB=80×106 kB320 kB=250,000\frac{80\ \text{GB}}{320\ \text{kB}} = \frac{80 \times 10^{6}\ \text{kB}}{320\ \text{kB}} = 250{,}000
Cloud to tiny activation memory, with 1 GB = 1,000,000 kB

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.

QuantitySizeCloud, 80 GB HBMMobile, 256 GB flash and 4 GB DRAMTiny, 1 MB flash and 320 kB SRAM
FP32 weights102.2 MByes, 783x headroomyesno, 102x over
FP16 weights51.1 MByesyesno, 51x over
INT8 weights25.6 MByesyesno, 25.6x over
Peak activation (MCUNet)7.2 MByesyesno, 22.5x over 320 kB SRAM
Does ResNet-50 fit? (25,557,032 parameters; peak activation from MCUNet Table 1)

Worked example

Two budgets, one model: MobileNetV2 at INT8 on the STM32F746

  1. Storage check

    MobileNetV2 INT8 weights are 3.4 MB (MCUNet Table 1). Against 1 MB of flash that is 3.4x over.
  2. Activation check

    Its peak activation is 1.7 MB. Against 320 kB of SRAM that is 5.3x over.
  3. 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).
  4. 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

  1. Cloud

    1.06 TB / 80 GB = 13.25: fourteen A100s just for the weights, as computed in the first concept.
  2. Mobile

    1.06 TB / 256 GB = 4.1: does not fit even the phone's storage, let alone its 4 GB of working memory.
  3. Tiny

    1.06 TB / 1 MB = 1,060,000: a million times over.
  4. 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.

Activation memory: 80 GB, 4 GB, 320 kB. Weight storage: about TB to PB, 256 GB, 1 MB.

Recall

Distinguish activation memory from weight storage and name the microcontroller component for each.

Activation memory is the read-write working memory during inference; its peak across layers matters; on an MCU it is SRAM. Weight storage holds the read-only weights; the total model size matters; on an MCU it is flash.

Recall

Does INT8 ResNet-50 fit the tiny AI tier? Check both budgets.

No. Its 25.6 MB of weights is 25.6x the 1 MB flash, and its 7.2 MB peak activation (MCUNet) is about 22x the 320 kB SRAM. It fails both.

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