Concepts / Memory Hierarchy for Deep Learning Workloads

Memory Hierarchy for Deep Learning Workloads

A utilization of one would mean the workload delivers the full peak rate; a lower value means that part of the chip's capacity is going unused.

  • Programming

A Product Page Number

Imagine a product page that advertises an accelerator capable of several hundred trillion operations every second. It is tempting to read that figure as the speed at which your model will run. That reading is usually too optimistic. To judge an AI accelerator sensibly, you need to answer three questions: what the advertised number actually measures, how it changes when you change the number format your model uses, and what else the chip needs in order to keep its processing units busy. This lesson follows those three questions in order, and along the way it traces what happens to a piece of data as it travels from memory to the arithmetic units.

Counting Operations per Second

Definition

The computational capability of an accelerator is measured by counting how many operations the chip can complete in a given span of time. The unit is FLOP/s, also written FLOPS. Each FLOP is one floating-point operation, such as a single addition or multiplication on fractional numbers, and FLOP/s tells you how many of them the chip can finish each second.

Because FLOP/s is a rate, a larger value means the chip can, in principle, push through more arithmetic in the same amount of time. A rating of this kind describes a ceiling. It says what the hardware could do under ideal conditions, not what a particular program will do on a particular day.

Key point

Teraflop figures are written in units of one trillion operations per second. A chip advertised at several hundred teraFLOP/s is therefore claiming several hundred trillion floating-point operations every second.

Why the Peak Is Rarely Reached

The peak figure is a theoretical maximum, and the gap between that ceiling and real performance matters a great deal. An application rarely reaches the peak because real workloads spend time waiting for data, moving results around, and handling steps that are not pure arithmetic. Every time a processing unit sits idle while it waits for its next operand, the achieved rate falls below the peak.

What do you think happens?

A chip's specification sheet quotes a peak FLOP/s rating. Will a real deep learning workload on that chip usually run at exactly that rate?

  • Yes, the workload reaches the peak as long as the code is correct

  • No, real workloads usually fall short of the peak

Reveal answer
Answer:

No, real workloads usually fall short of the peak.

Real workloads spend time waiting for data, moving results, and running steps that are not pure arithmetic, so the throughput an application actually achieves is typically below the theoretical peak.

The ratio of the throughput an application actually achieves to the theoretical peak is a useful utilization measure. It tells you what fraction of the chip's capacity your workload is really using. A utilization of one would mean the workload delivers the full peak rate; a lower value means that part of the chip's capacity is going unused.

Worked example

Computing Utilization for a Hypothetical Chip

A hypothetical accelerator has a peak rating of 800 teraFLOP/s. A training job is measured at an achieved throughput of 200 teraFLOP/s. What is the utilization?

  1. 1
    Identify the achieved and peak values

    Achieved throughput is 200 teraFLOP/s and the peak is 800 teraFLOP/s. Both use the same unit, so the ratio is unitless.

  2. 2
    Divide achieved by peak

    Utilization is $\frac{200}{800} = 0.25$, which is the achieved rate divided by the peak rate.

  3. 3
    Interpret the result

    A utilization of 0.25 means the job uses about one quarter of the chip's theoretical capacity. The remaining three quarters are unused, which is typically where waiting for data or non-arithmetic work shows up.

Result

Utilization is 0.25, or 25 percent of the peak rating.

Peak FLOP/stheoretical ceilingUtilizationachieved divided by peakAchieved FLOP/smeasured in practicedenominatornumerator
How much of the chip's theoretical peak does a real workload actually deliver once memory stalls and other overheads are included? The two bars show the ceiling and the achieved rate for a hypothetical chip.

Precision and Operations per Second

The number of operations a chip can complete per second depends on the precision of the numbers it works with. Precision here refers to how finely a number is represented. A format that stores more detail for each value requires more work for each operation, so fewer operations fit into each second. Consider adding two 32-bit values compared with adding two 16-bit values: the wider format involves more work per addition.

Key point

Lower numerical precision generally allows more operations per second. This is the main trend to carry forward from the precision specifications for NVIDIA H100 SXM chips, which list peak ratings across several reduced-precision tensor formats.

The relationship is not a clean proportion. The count does not simply double each time the width is halved, because chips are optimized differently for each format. The specific ratings in the H100 SXM specification table are quoted in teraFLOP/s with sparsity, and they should be read directly from that table rather than estimated from the bit width. The lesson for practice is that switching to a narrower format can raise the advertised peak substantially, but the gain is a property of the chip's design for that format, not a simple arithmetic consequence of fewer bits.

Precision FormatEffect on Work per OperationEffect on Operations per Second
Wider format, such as 32-bitMore detail, so more work per operationGenerally fewer operations per second
Narrower format, such as 16-bitLess detail, so less work per operationGenerally more operations per second
Narrowest formats in the H100 tableLeast detail of the formats listedGenerally the highest peak rating listed

How precision changes the peak operations-per-second rating. The relationship is a general trend, not a fixed proportion.

Feeding the Compute Units

A GPU contains many cores that operate in parallel. Those cores can only do useful work when the data they need arrives in time, so the speed at which data moves from memory to the cores becomes a limiting factor. AI workloads make this worse, because they involve very large weight matrices and training datasets that must be moved quickly to keep the cores fed. An accelerator that can perform many operations per second will sit partly idle if its memory cannot supply operands fast enough.

Memory is not a single pool. The accelerator interacts with several tiers of memory. The tiers closest to the compute units are the smallest and fastest, such as registers and on-chip caches. Larger and slower tiers sit further away, and high bandwidth memory, usually called HBM, is the large off-chip store that holds the weights and data a model needs. Data moves down the hierarchy when it is stored and back up toward the cores when it is needed for arithmetic.

Compute unitsperform the arithmeticRegistersclosest, smallest, fastestShared memory and L2cachelarger, slower thanregistersHBMlargest, slowest tieroperands inspills and refillsspills and refills
Which memory levels sit closest to the compute units, which are larger but slower, and how does data move down and back up through them? The closest tier is smallest and fastest; the outermost tier is largest and slowest.
Weight in HBMstored off-chipL2 cacheon-chip stagingRegistersnext to the coresArithmetic unitsconsume the operandlimited by bandwidthfetchoperand delivered
What path does a weight or activation travel from memory to the arithmetic units, and where does the transfer become the bottleneck? The slowest link in the path limits how fast operands arrive.

Bandwidth Versus Latency

Two numbers describe an accelerator's memory: its size and its bandwidth. For the feeding problem, there is a second property that matters just as much, which is latency. Bandwidth is how many bytes can be moved per second. Latency is how long a single access has to wait before its data starts to arrive. The two are different properties, and an accelerator needs both.

Accelerator memory must deliver high bandwidth and low latency. High bandwidth lets large weight matrices and datasets stream to many cores at once. Low latency keeps each individual request from stalling the cores while they wait. Meeting both demands requires advanced memory technology such as HBM.

High bandwidthmany bytes moved per secondLarge streamsweights and datasetsLow latencyshort wait per accessIndividual requestsavoid stalling the coresservesserves
How do high bandwidth (many bytes per second) and low latency (short wait per access) differ, and why does an accelerator need both? The two columns describe the same memory from different angles.

Why GPU Memory Costs More

Meeting the demands of high bandwidth and low latency requires more advanced memory technology, and that technology costs more. This is one reason GPU memory is more expensive than the memory attached to a CPU. The contrast between the two designs is easiest to see side by side, with the caveat that the source material describes the cost difference qualitatively rather than giving per-byte prices.

PropertyGPU accelerator memoryCPU main memory
Primary demandHigh bandwidth and low latency for many parallel coresServes general-purpose processing
TechnologyAdvanced technology such as HBMConventional memory attached to the CPU
Cost per byteHigher, because of the advanced technology requiredLower, because the design demands are different

GPU memory and CPU memory are designed for different demands, and the difference in demands drives the difference in cost.

Mistakes Beginners Make with Peak Ratings

  • Common mistake

    Treating the advertised FLOP/s rating as the speed a model will run at

    What it looks like

    Assuming a chip rated at several hundred teraFLOP/s will train a model at that rate.

    Why it fails

    The peak is a theoretical ceiling. Real workloads wait for data, move results, and run non-arithmetic steps, so they usually achieve less.

    Do this instead

    Treat the peak as an upper bound and estimate achieved throughput from measured utilization.

  • Common mistake

    Assuming halving the bit width exactly doubles the operations per second

    What it looks like

    Reasoning that a 16-bit format must give twice the operations of a 32-bit format.

    Why it fails

    The relationship is not a clean proportion, because chips are optimized differently for each format.

    Do this instead

    Read the actual peak ratings for each format from the chip's specification table.

  • Common mistake

    Judging memory by capacity alone

    Why it fails

    A large memory with low bandwidth can still starve the cores, and high bandwidth with high latency can still stall them.

    Do this instead

    Evaluate size, bandwidth, and latency together, in the context of the whole system.

  • Common mistake

    Confusing bandwidth with latency when reading a memory specification

Checking Your Reasoning

EASY

A hypothetical accelerator has a peak rating of 600 teraFLOP/s. A workload runs at an achieved rate of 150 teraFLOP/s. Compute the utilization, then explain in one sentence what the unused capacity most likely reflects.

Hints
  • Utilization is the achieved rate divided by the peak rate.
  • Think about what keeps processing units idle: waiting for data, moving results, or non-arithmetic steps.
MEDIUM

A colleague says that moving from a 32-bit format to a 16-bit format will exactly double the peak operations per second, so the job will finish in half the time. Explain what is wrong with this reasoning, using the ideas of precision, peak rating, and utilization.

Hints
  • Consider whether the relationship between format width and operations per second is a clean proportion.
  • Even with a higher peak, what determines how much of that peak the job actually achieves?

Key Takeaways

  • An accelerator's FLOP/s rating is a peak theoretical figure, and the ratio of achieved to peak FLOP/s is a practical utilization measure.
  • Lower numerical precision generally allows more operations per second, but the gain is not a simple proportion and must be read from the chip's specification.
  • Data must reach the cores in time, so accelerator memory needs high bandwidth and low latency, which is why HBM-class technology is needed and why GPU memory costs more than CPU memory.
  • Memory size and bandwidth only make sense within the full system an accelerator belongs to.

Related concepts

More concepts starting with M