Skip to content
Tactiverge

Textbooks/Computer Architecture/Chapter 7Lite (plain text) version

7Energy and reduced precision

Version 1 · Technically checked (automated checks only) · 4 source lessons · 8 practice items

Text
All chapters and search
  1. 1. Instruction-set design
  2. 2. The performance equation
  3. 3. Pipelining and hazards
  4. 4. Caches and the memory hierarchy
  5. 5. Input, output and the hardware–software boundary
  6. 6. Parallelism and acceleration
  7. 7. Energy and reduced precision
  8. 8. Measuring performance honestly

Introduction

For a battery-powered device, the number that matters is energy per useful operation, not speed. This chapter computes energy per operation and battery life, compares racing to finish then sleeping with running slowly, and shows the biggest lever of all: using fewer bits. Fixed-point formats and 8-bit quantised models shrink memory, data movement and energy, provided the accuracy requirement was written down first and checked honestly afterwards.

signed Q4.4 in 8 bits00101011integer (with sign)fractionstep = 2^−4 = 0.0625range = -8 to 7.93752.7 ÷ 0.0625 = 43.2 → code 43stored value = 43 × 0.0625 = 2.6875rounding error = 0.0125 (at most half a step)
Figure 7.1. Fixed point: a step and a range. A signed fixed-point number with 4 integer bits and 4 fraction bits. The step is 0.0625 and the range is −8 to 7.9375. The value 2.7 is stored as code 43, bit pattern 00101011, which means 2.6875: a rounding error of 0.0125, within half a step.

Explanation

This chapter is built from 4 School lessons. Each part below is the lesson's own explanation; open the lesson for its predict-and-discover activities.

7.1 Energy per operation: the number that decides battery life

Chip A is twice as fast as chip B but draws three times the power. Which one empties a rover's battery first doing the same job?

The unit that matters

Energy per operation = power ÷ operations per second. A 0.3 W microcontroller doing 100 million operations a second spends 3 nJ per operation; a 12 W accelerator doing 2 trillion spends 6 pJ. For the same job, the accelerator uses 500 times less energy, even though it draws 40 times more power.

System energy, not chip energy

While the processor works, other parts stay awake: memory, sensors, voltage regulators, the radio. If they draw 2 W regardless, a slow chip keeps them awake longer. Total job energy = (P_chip + P_rest) × time + sleep energy. This is why 'race to idle' (finish fast, then put everything to sleep) often wins in real systems.

Memory moves cost more than maths

On modern chips, fetching a number from off-chip memory can cost hundreds of times the energy of adding it. Energy-efficient designs keep data close: small local memories, data reuse, fewer transfers. This is a hardware–software co-design question: the algorithm's data movement decides the energy.

Duty cycling

Many sensors spend 99% of their life asleep. Average power = d·P_active + (1 − d)·P_sleep. At low duty cycles the sleep current dominates: a 10 mW sleep draw can matter more than a 2 W active draw at 0.1% duty. Battery life = energy capacity ÷ average power.

Common mix-ups

  • The lowest-power chip always gives the longest battery life.
    ✓ Battery life depends on energy for the job, including everything kept awake while it runs, and on sleep power.
  • Computation is what costs energy.
    ✓ Moving data, especially off-chip, often costs far more energy than the arithmetic itself.

Open the full lesson: Energy per operation: the number that decides battery life →

7.2 Energy budgets and duty cycling

A soil sensor must run for two years on two AA batteries. It can only be awake about one second in every hundred. How do you design for that?

Energy, not power

Batteries store energy (joules, or watt-hours). A task's cost is power × time, so a fast, power-hungry processor that finishes quickly and sleeps can use less energy than a slow, frugal one. Always compare energy per task.

Know your states

Real nodes have more than two states: deep sleep, wake-up (oscillator start, can be costly), sensing, computing, and radio transmit (often the most expensive per second). Measure or look up each, build a timeline, and add up the energy. The biggest slice is where design effort should go.

Computing less, or locally

Sending raw data by radio can cost far more energy than processing it locally and sending a short result. This is a key argument for embedded ML: a tiny on-device classifier that transmits only 'event detected' can extend battery life enormously, provided its own energy and false alarms are counted.

Derivation: Average power and battery life
  1. Over one period T, the node is active for t_on and asleep for T − t_on. Duty cycle D = t_on / T.

  2. Energy per period E = P_on·t_on + P_sleep·(T − t_on). Average power P_avg = E / T = D·P_on + (1 − D)·P_sleep.

  3. Battery energy ≈ capacity (Ah) × voltage (V) × 3600 J. Lifetime ≈ E_battery / P_avg (ignoring self-discharge and temperature).

  4. As T grows, D → 0 and P_avg → P_sleep: sleep power sets the ceiling on lifetime.

  5. Example: P_on = 15 mW, t_on = 20 ms, T = 10 s, P_sleep = 3 µW: D = 0.002, P_avg = 30 + 3 ≈ 33 µW. Two AA cells (about 2.5 Ah at 3 V ≈ 27 kJ) last about 26 years by this ideal sum; self-discharge will end them much sooner.

Common mix-ups

  • The lowest-power processor gives the longest battery life.
    ✓ Energy per task decides it: a faster chip that sleeps sooner can win.
  • Battery life = capacity ÷ active current.
    ✓ Use average current over the whole duty cycle, and allow for self-discharge, temperature and ageing.

Open the full lesson: Energy budgets and duty cycling →

7.3 Reduced precision: range, resolution and error

Your filter works perfectly in Python floats. On the 16-bit chip, it slowly drifts and then explodes. What went wrong?

Qm.n formats

A signed Qm.n number has m integer bits (including sign) and n fraction bits: value = integer / 2ⁿ. Range ≈ [−2^(m−1), 2^(m−1)), step 2^(−n). Q1.15 in 16 bits covers [−1, 1) in steps of about 3×10⁻⁵. Choose m from the largest value the signal (and every intermediate result) can reach, then give the rest to n.

Where precision is lost

Rounding each result loses up to half a step. Multiplication doubles the fraction bits (Q1.15 × Q1.15 = Q2.30), so results are shifted back and rounded. Accumulation of many products needs extra headroom bits. Feedback (recursive filters, integrators) can accumulate rounding errors or sustain small oscillations (limit cycles).

Precision is a measured requirement

State the requirement first (for example, 'error under 0.5% of full scale'), then implement at candidate precisions on identical inputs, measure the error and pick the smallest that meets it with margin. The same applies to sample rate: lower rates save energy until aliasing or lag breaks the requirement. This is the method of the term project.

Common mix-ups

  • More fraction bits are always better.
    ✓ In a fixed word, every fraction bit is taken from range: you trade overflow risk for resolution.
  • If the inputs fit, the result fits.
    ✓ Sums and products need more bits than their inputs; size every intermediate, or use a wide accumulator.

Open the full lesson: Reduced precision: range, resolution and error →

7.4 Quantisation: fewer bits, smaller models

Store every weight in 8 bits instead of 32 and the model is four times smaller. How much accuracy do you lose? Sometimes almost none.

Scale and zero point

A quantised tensor stores small integers plus one scale (and sometimes a zero point for asymmetric ranges, useful for ReLU outputs that are never negative). Per-channel scales, one per output channel, often keep accuracy much better than one scale for the whole layer.

Why accuracy often survives

A trained network is robust to small perturbations of its weights; int8 errors are tiny compared with the spread of the weights. Below about 4 bits, errors become comparable to the weights themselves and decisions start to flip. Outliers matter too: one huge weight stretches the scale and wastes resolution on everyone else.

Measure on held-out data

Compare float and quantised accuracy on the same held-out test set, report both with their uncertainty, and look at which inputs changed class. Calibration (choosing scales from representative data) and quantisation-aware training can recover accuracy at low bit widths. The explorer's toy classifier shows the trend only.

Derivation: Symmetric uniform quantisation and its error
  1. Choose a scale s = max|w| / (2^(b−1) − 1), so the largest weight maps to the largest integer.

  2. Quantise: q = round(w / s), clamped to the b-bit range. Dequantise: ŵ = q·s.

  3. The rounding error e = ŵ − w lies in [−s/2, s/2]. If it is roughly uniform, its RMS is s/√12.

  4. Each extra bit halves s, so it halves the error: about 6 dB better signal-to-quantisation-noise per bit.

  5. Integer MACs: Σ wᵢxᵢ ≈ s_w s_x Σ q_w q_x. The sum runs in integers (with a 32-bit accumulator) and one rescale happens at the end.

Common mix-ups

  • Quantisation always destroys accuracy.
    ✓ At 8 bits the loss is often small; it must be measured, and grows quickly below about 4 bits.
  • Quantising to 8 bits makes inference exactly 4× faster.
    ✓ Memory shrinks 4×; speed depends on hardware support for int8 MACs and on memory traffic.

Open the full lesson: Quantisation: fewer bits, smaller models →

Worked examples

Energy per operation: the number that decides battery life: example 1

A sensor node: 20 Wh battery, active 2% of the time at 1.2 W, asleep otherwise at 5 mW. Battery life?

Solution

P_avg = 0.02 × 1.2 + 0.98 × 0.005 = 0.024 + 0.0049 = 0.0289 W. Life = 20/0.0289 ≈ 692 h ≈ 29 days. Sleep is 17% of the average: worth optimising too.

Energy budgets and duty cycling: example 1

A node wakes every 30 s for 50 ms at 24 mW and sleeps at 4 µW. Average power and life on a 1,000 mAh, 3.6 V cell?

Solution

D = 0.05/30 = 0.00167. Active: 24 mW × 0.00167 = 40 µW. Sleep: 4 µW × 0.998 ≈ 4 µW. P_avg ≈ 44 µW. Energy = 1 Ah × 3.6 V × 3600 = 12,960 J. Life ≈ 12,960/44×10⁻⁶ s ≈ 2.95×10⁸ s ≈ 9.3 years (ideal).

Reduced precision: range, resolution and error: example 1

A gyro reads ±250 °/s and you need 0.01 °/s resolution. Pick a 16-bit signed format.

Solution

Range needs 2^(m−1) ≥ 250, so m − 1 = 8 integer bits plus sign: m = 9. That leaves n = 7 fraction bits: step 1/128 ≈ 0.0078 °/s < 0.01 ✓. Q9.7.

Quantisation: fewer bits, smaller models: example 1

Quantise w = 0.31 with max|w| = 0.8 to int8.

Solution

s = 0.8/127 = 0.0063. q = round(0.31/0.0063) = round(49.2) = 49. ŵ = 49 × 0.0063 = 0.3087. Error −0.0013, within ±s/2 = ±0.0031.

Interactive figures

Figure 7.2 from Quantisation: fewer bits, smaller modelsSweep the bits from 16 down to 2 and read the accuracy curve. Find the smallest bit width that stays within 1 percentage point of float. Then set 1,000,000 parameters and find the smallest width that fits the 256 KB budget. Do the two answers agree?
Can't use the interactive? Read a description instead

The explorer plots accuracy of a toy classifier against bit width: 90.25% in float and at 8, 12 and 16 bits, 90% at 6 bits, about 89% at 3 and 4 bits, and about 74% at 2 bits. Footprint = parameters × bits ÷ 8; one million int8 weights take about 977 KB, so they do not fit a 256 KB budget.

Interactive figure (online). Description: The explorer plots accuracy of a toy classifier against bit width: 90.25% in float and at 8, 12 and 16 bits, 90% at 6 bits, about 89% at 3 and 4 bits, and about 74% at 2 bits. Footprint = parameters × bits ÷ 8; one million int8 weights take about 977 KB, so they do not fit a 256 KB budget.

Laboratory

Everything runs in your browser. No kit, nothing mains-powered. Simulations are simplified educational models.

  • Simulation OS experiment

    Simulation OS: Battery sensor node

    Halve the active time per wake-up, then halve the sleep current, and find which change extends battery life more.

    Open Simulation OS: Battery sensor node →
  • Studio

    Code Lab

    Implement a filter in floating point and in a fixed-point format of your choice, and report the largest output difference over a test signal.

    Open Code Lab →

Guided practice

Answers are checked on the server; wrong answers get a hint and another try. Signed in, solved items also count towards the source lesson.

Practice 1

While the processor works, the rover's radio and sensors must stay on, drawing 4 W. Chip A: 2 W for 1 s. Chip B: 0.5 W for 3 s. Which uses less total energy?

Practice 2

An accelerator delivers 4 × 10¹² operations per second at 8 W. What is its energy per operation, in pJ?

pJ

Practice 3

A device averages 50 µW from a battery storing 10,000 J. Ignoring self-discharge, how many days will it last?

days

Practice 4

A node's average is 200 µW active + 3 µW sleep. Which change helps most?

Practice 5

What is the step size (resolution) of a signed Q4.12 number?

Practice 6

Multiplying two Q1.15 numbers gives a 32-bit result in which format?

Practice 7

With scale 0.02, what integer does w = −0.537 quantise to (round to nearest)?

Practice 8

Which evaluation of an int8 model is fair?

  1. While the processor works, the rover's radio and sensors must stay on, drawing 4 W. Chip A: 2 W for 1 s. Chip B: 0.5 W for 3 s. Which uses less total energy?
    • B (lower power)
    • A: (2 + 4) × 1 = 6 J against B's (0.5 + 4) × 3 = 13.5 J
    • They are equal
    • Only the chip's energy matters
  2. An accelerator delivers 4 × 10¹² operations per second at 8 W. What is its energy per operation, in pJ? (pJ)
  3. A device averages 50 µW from a battery storing 10,000 J. Ignoring self-discharge, how many days will it last? (days)
  4. A node's average is 200 µW active + 3 µW sleep. Which change helps most?
    • Halve the sleep current
    • Halve the awake time per cycle
    • Use a bigger enclosure
    • Double the clock but keep awake time the same
  5. What is the step size (resolution) of a signed Q4.12 number?
  6. Multiplying two Q1.15 numbers gives a 32-bit result in which format?
    • Q1.15
    • Q2.30
    • Q1.31
    • Q16.16
  7. With scale 0.02, what integer does w = −0.537 quantise to (round to nearest)?
  8. Which evaluation of an int8 model is fair?
    • Accuracy on the training set
    • Accuracy of float and int8 models on the same held-out test set, with uncertainty
    • Accuracy on whichever test examples int8 gets right
    • Model size only

Engineering applications

  • Wearables

    A fitness band spends almost all its life asleep. Its battery life is set by the sleep current and how often, and for how long, it wakes, far more than by its processor's top speed.

  • On-device models

    Storing a model's weights as 8-bit integers instead of 32-bit floats cuts its memory by four and its data movement with it; the accuracy loss must be measured on held-out data.

Watch

Optional verified videos. Nothing loads from YouTube until you press play.

Dynamic, short-circuit and leakage power in one place, the physics behind every power–performance–area trade.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

Explains how many transistors came to be printed on one die, and why shrinking them brought speed and cost benefits for decades.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

  • Three Ways Your Chip Burns Power | CMOS Power Dissipation Explained (Abhijit Pethe)
  • Integrated Circuits & Moore's Law: Crash Course Computer Science #17 (CrashCourse)

Chapter summary

  • Energy per operation = power ÷ operation rate; data movement often costs more than arithmetic.
  • Average power of a duty-cycled device = Σ (power × fraction of time) over its states.
  • A fixed-point format trades range against resolution; the step is 2^(−fraction bits).
  • Quantisation saves memory and energy; judge it against a written accuracy requirement on fair test data.

Glossary

Battery capacity and runtime
A battery's capacity in ampere-hours says how long it can supply a current; multiplied by its voltage it gives stored energy in watt-hours.
Electrical power
The power transferred in a component is the voltage across it multiplied by the current through it. For a resistor this can also be written I²R or V²/R.
Bits and bytes
A bit is a single binary digit, 0 or 1. A byte is 8 bits. n bits can represent 2^n different values.
Two's complement (signed integers)
Two's complement represents negative integers so that ordinary binary addition still works: the top bit has a negative place value, so an n-bit number ranges from −2^(n−1) to 2^(n−1) − 1.

Definitions from the Field Guide.

Project: A year on a coin cell?

Design the duty cycle of a sensor node that must report every minute for a year on a coin cell. Choose the active time, sleep current and data precision, compute the average power and battery life, and state the margin.

Deliverables

  • The energy budget per state
  • Battery-life calculation with margin
  • The chosen data format and its worst-case error

Keep your work in your Engineering Journal; it stays private unless you choose to share it.

References

  • John L. Hennessy and David A. Patterson (2017). Computer Architecture: A Quantitative Approach, 6th edition. Morgan Kaufmann.
  • Randal E. Bryant and David R. O'Hallaron (2016). Computer Systems: A Programmer's Perspective, 3rd edition. Pearson.

Publication record

Version
1
Status
Technically checked (automated checks only)
Technical review
Automated checks only, last run 2026-11-29. No human, educator or mentor review is claimed.src/content/textbooks/textbooks.test.ts: schema, every lesson, diagram, practice item, video, Field Guide entry, lab and reference resolves; figure numbers recomputed; no practice answers in client payloads.
Written by
Compiled and written by the Tactiverge team with AI assistance, from Tactiverge School lessons that were themselves written with AI assistance.
Licence
All rights reserved by the founders unless a licence is approved.
Corrections
None recorded yet.Spotted a mistake? Use “Report a problem” on any chapter, or see the corrections page.