TactivergeLite

Lite / Textbooks / Computer Architecture / Chapter 7

7. Energy and reduced precision

Version 1 · Technically checked (automated checks only) · 4 source lessons · Full interactive version

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.

Figure 7.1. Fixed point: a step and a range (described in words)

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

Built from 4 School lessons. Each part is the lesson's own explanation.

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

Open the Lite 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

Open the Lite 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

Open the Lite 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

Open the Lite 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, in words

Figure 7.2 from Quantisation: fewer bits, smaller models

Sweep 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?

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.

The interactive versions are in the full chapter.

Laboratory

These run in a browser on the full site (they need a faster connection). Simulations are simplified educational models.

Practice

Each question links to its Lite lesson, where your answer is checked on our server and a wrong answer gets a hint. Answers are never sent to your device.

  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?
    Answer it in “Energy per operation: the number that decides battery life”
  2. An accelerator delivers 4 × 10¹² operations per second at 8 W. What is its energy per operation, in pJ?
    Answer it in “Energy per operation: the number that decides battery life”
  3. A device averages 50 µW from a battery storing 10,000 J. Ignoring self-discharge, how many days will it last?
    Answer it in “Energy budgets and duty cycling”
  4. A node's average is 200 µW active + 3 µW sleep. Which change helps most?
    Answer it in “Energy budgets and duty cycling”
  5. What is the step size (resolution) of a signed Q4.12 number?
    Answer it in “Reduced precision: range, resolution and error”
  6. Multiplying two Q1.15 numbers gives a 32-bit result in which format?
    Answer it in “Reduced precision: range, resolution and error”
  7. With scale 0.02, what integer does w = −0.537 quantise to (round to nearest)?
    Answer it in “Quantisation: fewer bits, smaller models”
  8. Which evaluation of an int8 model is fair?
    Answer it in “Quantisation: fewer bits, smaller models”

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)

Streaming video uses a lot of data. Everything you need is in the text.

Summary

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. Field Guide
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. Field Guide
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. Field Guide
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. 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

Write it up on paper or in your own notes. Lite never stores what you write.

References

← 6. Parallelism and acceleration8. Measuring performance honestly →