"I could be accurate, cheap, fast, and private all at once. Pick three, and even three is me being generous with myself."
A Budget-Conscious AI Agent
The Big Picture
Textbooks tend to design the model first and worry about deployment last: pick the architecture, chase accuracy, then discover the target device cannot hold the weights, the radio cannot carry the data, or the legal team will not let the raw signal leave the wearer's wrist. That ordering is backwards. Sampling rate, latency, bandwidth, power, cost, and privacy are not deployment paperwork you fill in at the end. They are coupled forces that decide, on the very first day, what class of solution is even reachable. This section argues that these six constraints form a tension web: pull on one and the others move. Once you internalize the coupling, the deployment target stops being a constraint you fight and becomes the thing that chooses your method for you.
What lets one sensing system run for years on a coin cell while another needs a wall socket to answer the very same question? Almost never the cleverness of the algorithm, and almost always the budget it has to fit inside. Section 1.5 walked the sensing chain from raw signal to decision as a sequence of stages; this section reads that same chain along a different axis: not what each stage does, but what each stage costs. We are deliberately not doing sampling theory here (that is the job of Chapter 3, Signals, Sampling, Time, and Synchronization); we are treating the sampling rate as one knob in a budget you cannot overspend. The only prerequisite is the notation from Section 1.3: a continuous signal \(x(t)\), its sampled form \(x[n]\), a hidden world state \(s\) we want to estimate as \(\hat{s}\), and the measurement model \(x = h(s) + \eta\). In short: fix the budget first and the deployment target hands you the model that fits inside it; accuracy only ranks what survives.
Common Misconception
The most common misconception is that these six constraints are deployment paperwork: build the most accurate model first, then "optimize" it for power, bandwidth, and the rest at the very end. In reality the fixed constraints delete whole families of models before training begins, so a model designed in ignorance of them is frequently not merely slow or power-hungry but simply infeasible, unable to run at all on the only hardware the fleet can afford.
The six-constraint tension web
What the web contains: six quantities that every sensory-AI system spends. Sampling rate \(f_s\) sets how finely you observe \(x(t)\) in time and how many bits per second you generate. Latency is the delay from a physical event \(e\) at time \(t\) to the action \(a\) it triggers. Bandwidth is what your link (Bluetooth Low Energy or BLE, LoRa for Long Range, cellular, Controller Area Network or CAN bus) can actually carry off the node. Power is the energy budget, which on a coin cell or a harvested microwatt (energy scavenged from ambient light, vibration, or heat rather than drawn from a battery) is brutally finite. Cost is the per-node bill of materials (the total price of every component in one unit) and compute, multiplied by fleet size. Privacy is how much of the raw signal, and the identity latent inside it, ever leaves the sensor.
Checkpoint
So far: the web holds six quantities every sensory-AI system spends (sampling rate, latency, bandwidth, power, cost, and privacy). The rest of the section shows they are coupled, so anything you spend on one is repaid out of another.
Latency, the term most often confused with bandwidth, is worth pinning down precisely: it is the wall-clock delay along the entire path from a physical event to the resulting action. That path sums sensing time, on-node compute, any transmission and queueing on the link, and remote compute plus the return trip. It matters because a control loop that acts too late acts on stale world state, so a fast-but-late estimate can be worse than useless (a braking decision that lands at 300 ms is a crash, not a slow success). Mechanically the delays add along the pipeline, whereas bandwidth only sets the transmission term. That is why a high-throughput link can still deliver painfully high latency. Budget by the tail (the 99th-percentile delay) rather than the mean whenever a missed deadline is unsafe. Reserve mean latency for soft, best-effort tasks such as background logging.
Engineers who treat these six as a checklist ship prototypes that pass on the bench and then flatten the battery or flood the radio the week they scale to the field, because the mechanism below was quietly linking every knob to every other one the whole time. Why they are a web and not a checklist: they are physically and economically coupled, so improving one degrades at least one other. Raising \(f_s\) improves your chance of catching a fast transient, but the raw data rate for a single channel is
$$ R = f_s \cdot b \cdot C \quad\text{bits per second,} $$where \(b\) is bits per sample and \(C\) is the channel count. Double \(f_s\) and you double the bytes the radio must send (bandwidth up), the energy per second the radio spends (power up), and, if you cannot afford to stream it all, the compute you must add on the node to summarize it (cost up). Every arrow in Figure 1 is a coupling of this kind. There is no operating point that maximizes all six; there are only Pareto-efficient trades (where a Pareto-efficient operating point is one you cannot improve on any constraint without giving up ground on at least one other), and picking one is a design decision, not a tuning afterthought.
Step-Through: Computing the Raw Data Rate
Trace the coupling formula \(R = f_s \cdot b \cdot C\) with a real accelerometer window and watch each knob move the bytes. Start with a single-axis logger, then turn the knobs one at a time so the coupling is visible as arithmetic, not assertion.
- Baseline. One axis, \(f_s = 100\) Hz, \(b = 16\) bits per sample, \(C = 1\). Then \(R = 100 \times 16 \times 1 = 1{,}600\) bits per second, which is \(200\) bytes per second.
- Add channels. Move to a six-axis inertial measurement unit (IMU) (accelerometer plus gyroscope), so \(C = 6\). Now \(R = 100 \times 16 \times 6 = 9{,}600\) bits per second, which is \(1{,}200\) bytes per second. Six times the payload, same sampling rate.
- Raise the sampling rate. Bump \(f_s\) from \(100\) to \(200\) Hz to catch a faster transient. Now \(R = 200 \times 16 \times 6 = 19{,}200\) bits per second, which is \(2{,}400\) bytes per second. Doubling \(f_s\) exactly doubled the bytes, the radio energy per second, and the on-node buffer.
- Read the budget. A BLE link with a comfortable \(20\) kbit/s effective throughput carries the baseline (\(1.6\) kbit/s) and the six-axis case (\(9.6\) kbit/s) with room to spare, but the \(200\) Hz six-axis stream (\(19.2\) kbit/s) is now riding the ceiling: one retransmission storm and the queue backs up, latency climbs, and the coupling you traced in arithmetic becomes a missed deadline in the field.
The formula never changed; only the numbers moved. That is exactly the point of the web: every quantity you raise here reappears as spent bandwidth, power, or buffer somewhere else.
Mental Model
Picture a too-short blanket on a cold night. The blanket has a fixed size (your total budget), and you can slide it wherever you like, but you cannot cover everything at once: pull it up to warm your shoulders and your feet poke out into the cold; drag it down over your feet and your shoulders are bared. You never get to choose whether some part is cold, only which part. The six constraints share one blanket in exactly this way: spend sampling rate to catch a fast transient and you leave power, bandwidth, or cost uncovered. Good design is not eliminating the cold spot, which is impossible; it is deciding which part you can afford to leave exposed.
How you reason with the web: fix the two constraints that are truly non-negotiable for your application first, then let the web tell you what the other four are allowed to be. A car's collision-braking system fixes latency and safety, so it accepts high cost and power. A soil-moisture sensor in a field fixes power and cost, so it accepts coarse sampling and long latency. When this matters most: at the very first architecture sketch, before a single line of model code, because the fixed constraints eliminate whole families of methods before you ever compare their accuracy.
Key Insight
Accuracy is not a seventh free axis floating above the web; it is bought with the other six. A bigger model, a higher sampling rate, or a longer temporal context each buys accuracy by spending power, bandwidth, latency, or cost. The right question is never "what is the most accurate model" but "what is the most accurate model that fits inside the budget the deployment already fixed." The budget comes first; the model is what remains.
No free lunch: accuracy, power, latency, and privacy trade against each other
If the budget chooses the model, its first and most consequential entry is a question of geography. The sharpest four-way tension lives in a single decision: where does the computation happen? Send raw \(x[n]\) to the cloud and a large model produces a high-accuracy \(\hat{s}\), but you have paid in bandwidth, in round-trip latency, in radio power, and, most consequentially, in privacy, because the raw signal (a face, a voice, a gait, a heartbeat) has now left the device and become someone else's liability. Run a compressed model on the node and you keep the raw signal local (privacy up), cut the round trip (latency down), and stop streaming (bandwidth and radio power down), but the smaller model is usually less accurate. That is the no-free-lunch structure: the same lever moves accuracy one way and moves privacy, latency, and power the other way. You do not get to opt out of the trade; you only get to choose where on the curve to sit.
The short script below makes the trade concrete for one wearable design choice. It scores three placements of the same inference, cloud, edge, and a tiny on-device model, on a common latency and energy model, and reports which one respects a 100 ms latency budget while keeping the raw signal on the wrist. Figure 1.6.1 illustrates compute placement across the sensor-to-cloud boundary (tiny on-device vs edge vs cloud) and how each placement trades latency, energy, accuracy, bandwidth, and privacy.
import numpy as np
# One 6-axis IMU window: 200 Hz, 2 s, float32
fs, seconds, channels, bytes_per = 200, 2.0, 6, 4
payload_bytes = int(fs * seconds * channels * bytes_per) # raw window
# Simple, defensible per-option models (latency ms, energy mJ, keeps raw local?)
def cloud():
tx_ms = payload_bytes * 8 / 1e6 * 1e3 # 1 Mbit/s effective uplink
return dict(latency=tx_ms + 60, energy=payload_bytes * 8 * 5e-6 + 20,
local=False, acc=0.94)
def edge():
return dict(latency=18, energy=9.0, local=True, acc=0.91) # NPU on-node
def tiny():
return dict(latency=6, energy=1.2, local=True, acc=0.86) # MCU model
BUDGET_MS = 100
for name, opt in [("cloud", cloud()), ("edge", edge()), ("tiny", tiny())]:
ok = "PASS" if opt["latency"] <= BUDGET_MS and opt["local"] else "fail"
print(f"{name:5s} lat={opt['latency']:6.1f} ms "
f"E={opt['energy']:5.1f} mJ acc={opt['acc']:.2f} "
f"local={str(opt['local']):5s} [{ok}]")
Read Listing 1 as a decision, not a benchmark. The cloud model is the most accurate at \(0.94\), yet it fails the actual requirements: its round trip blows the latency budget and it ships the raw signal off-wrist. Between the two survivors, the choice is a pure trade of five accuracy points for a roughly \(7\times\) energy saving, which on a coin cell can mean weeks of extra battery life. The constraint did not rank the models by accuracy; it deleted the most accurate one and handed you a smaller menu.
Real-World Application: Always-On Voice Wake Words
Google's "Hey Google" and Apple's "Hey Siri" resolve exactly this tension web by splitting inference across the boundary. A tiny always-on detector runs on a dedicated low-power core (Apple's Always On Processor), keeping the raw microphone stream on-device at microwatt draw and firing only when the wake phrase scores above threshold, at which point the full request goes to the cloud. That placement keeps ambient audio private, respects a sub-\(200\) ms latency budget for the trigger, and lets the coin-cell-class power envelope survive continuous listening, precisely the fixed-two-constraints reasoning this section prescribes.
Right Tool
You will not hand-write energy models to shrink a network for the edge. Post-training quantization to 8-bit integers, the workhorse that makes on-device inference feasible, is a few lines with modern tooling:
import tensorflow as tf
conv = tf.lite.TFLiteConverter.from_saved_model("model/")
conv.optimizations = [tf.lite.Optimize.DEFAULT] # int8 quantization
open("model_int8.tflite", "wb").write(conv.convert())
.tflite file, standing in for a hand-written calibration and integer-kernel pipeline.Four lines replace what would otherwise be a few hundred lines of calibration, per-tensor scale estimation, and integer kernel bookkeeping. The library handles the calibration pass, chooses per-channel scales, and emits integer kernels, typically a \(4\times\) smaller model and \(2\) to \(4\times\) faster inference for a small accuracy cost. (As of 2024, Google rebranded TensorFlow Lite as LiteRT; the tf.lite converter API shown here still works, and the standalone ai-edge-litert package is now the current entry point for new projects.) The mechanics of that shrink are the subject of Chapter 59, Edge AI Fundamentals and Model Optimization.
Research Frontier
This section treats the accuracy-versus-compute trade as fixed by your architecture, but recent work is bending the curve itself. Mamba (Gu and Dao, 2023) introduced selective state-space models that process long sequences in linear time and constant memory per step, avoiding the quadratic attention cost that made Transformers hard to run on a streaming node, which is precisely the regime a continuous sensor lives in. On raw-audio and long time-series benchmarks Mamba is reported to match or beat comparable Transformers at a fraction of the inference cost, which means some operating points once outside every node's budget are quietly moving inside it. The tension web does not disappear; where its Pareto frontier sits is itself a moving research target. As of 2024, Mamba-2 (Dao and Gu, 2024) refined the selective state-space formulation and tightened its formal link to attention, continuing to push operating points that were once off-budget onto smaller streaming nodes.
Cost per node dominates at fleet scale and caps model size
Everything so far has weighed a single device; multiply that device by a fleet and a new constraint quietly overtakes the rest. What changes at scale: a single prototype hides the constraint that eventually dominates. When you ship one clever device, you can afford a fast processor and a generous battery. When you ship \(N\) of them, every dollar and every milliwatt is multiplied by \(N\), and the total system cost is roughly
$$ \text{Total} \approx N \cdot \big(c_{\text{hw}} + c_{\text{energy}} + c_{\text{comms}}\big), $$where each per-node term is small but \(N\) is large. Why this caps model size: the cheapest microcontroller that meets the requirement sets the per-node compute budget. At a fleet of a million nodes, a one-dollar processor upgrade becomes a million-dollar line item. That single sourcing decision fixes the flash, the RAM, and the clock, which in turn cap the number of model parameters you can store and the inference you can run per sample. The model does not size the hardware; the fleet economics size the hardware, and the hardware sizes the model.
In Practice: A Predictive-Maintenance Fleet
An industrial vendor instruments 50,000 pump motors with vibration nodes to catch bearing faults before they cause unplanned downtime. The engineering team's first model is an accurate spectrogram network (one that classifies the time-frequency energy image of the vibration) that wants a fault signature streamed continuously. The math kills it immediately: continuous vibration streaming over the plant's constrained wireless would swamp the shared bandwidth and drain the nodes' harvested power in days. The redesign flips the placement. Each node runs a tiny on-board detector that computes band-energy features (the signal's energy summed within a few frequency bands) from the accelerometer's \(x[n]\), stays asleep at microamp draw, and wakes to transmit only when an anomaly score crosses a threshold. Detection accuracy drops a little against the streaming baseline, but bandwidth falls by orders of magnitude, the coin cell lasts years instead of days, and the per-node bill of materials stays under the number that makes 50,000 units viable. The deployment target, 50,000 battery-powered nodes on a shared radio, chose the method: event-triggered on-device detection, not continuous cloud classification.
Privacy as a design constraint that relocates computation
Cost prunes the design tree by economics; privacy prunes it by rule, and the second cut is often the sharper of the two. Privacy is the constraint most often mistaken for a checkbox, a consent form signed after the architecture is frozen. Treated that way, it is powerless. Treated as a first-class engineering constraint, it is one of the strongest forces in the web, because it does something the others cannot: it dictates where computation is allowed to happen. If a rule says the raw signal must never leave the device (a face, a voice print, an electroencephalography (EEG) trace, a continuous heart rhythm), then cloud inference is not a slower option to be weighed on a curve; it is off the table. The privacy constraint has pruned an entire branch of the design tree before accuracy is ever discussed.
This is why privacy foreshadows so much of the book's back half. Keeping the raw signal local forces computation onto the edge (Chapter 59). Learning from a fleet without collecting anyone's raw data forces federated training, where nodes share model updates instead of measurements. Sensing on harvested energy with no persistent store forces batteryless designs that are private almost by construction because there is nothing durable to exfiltrate. In each case privacy did not sit on top of the architecture; it relocated the computation and thereby chose the architecture. The regulatory and ethical framing of that choice, and the standards that increasingly make it mandatory rather than optional, are developed in Chapter 70, Responsible Sensory AI and Regulation.
A Note in Passing
The tidiest privacy guarantee is the one you get by accident. A batteryless node with no flash and no uplink cannot leak the raw signal for the same reason a goldfish cannot spoil a surprise party: it has nowhere to keep the secret and no way to tell anyone. Constraint and virtue, wearing the same hat.
Constraint-driven design: the deployment target chooses the method
Pulling the threads together yields one reorienting habit: do not start from the model and defend it against the constraints; start from the constraints and let them nominate the model. Write down the two constraints your application cannot move (latency and safety for the braking system, power and cost for the soil sensor, privacy and battery life for the wearable electrocardiogram (ECG)). Those two fixed points collapse the tension web to a small feasible region that usually holds one obvious method and a couple of runners-up. Accuracy then ranks only those survivors. That is what "the deployment target chooses the method" means: by the time you compare accuracy numbers, the constraints have already done most of the choosing. Much of this book is a catalog of which methods survive which constraint budgets, which is why we return to this web whenever a new technique promises accuracy without naming its price.
Try It: Measure the Quantization Trade Yourself
Reproduce the accuracy-versus-size trade from Listing 1 on your own laptop in about half an hour, using only TensorFlow, scikit-learn, and NumPy. No sensor hardware and no download are needed; the small 8-by-8 digit images stand in for one sensor window each.
- Load the bundled dataset with
from sklearn.datasets import load_digits, then split it withtrain_test_splitinto train and test arrays scaled to the range 0 to 1. - Build a tiny Keras model (
Flatten, oneDense(32, "relu"), oneDense(10, "softmax")), train for about 20 epochs, and record the float32 test accuracy. - Convert the trained model two ways with
tf.lite.TFLiteConverter: once plain, and once withconverter.optimizations = [tf.lite.Optimize.DEFAULT]for int8, writing each result to a.tflitefile. - Compare the two files with
os.path.getsize; you should see the int8 file land near one quarter the size of the float32 one. - Run both models over the test set through
tf.lite.Interpreter, timing each withtime.perf_counter, and print accuracy, file size, and per-sample latency side by side so the trade is a table you produced, not one you were told.
Exercise
You are asked to build a wearable that detects atrial fibrillation from a wrist photoplethysmography (PPG) signal and must run for one week on a single charge, keeping the raw waveform on-device. Sketch the tension web for this system: name the two constraints you would fix first, then argue which of cloud, edge, or tiny on-device inference the fixed constraints permit. Estimate the raw data rate \(R\) for a single-channel PPG at \(f_s = 100\) Hz and \(b = 16\) bits, and state one design change that would cut that rate by at least \(10\times\) without changing \(f_s\).
Self-Check
1. Why is accuracy described as "bought" rather than as an independent seventh constraint?
2. Give two distinct constraints, other than privacy, that pushing inference from the cloud to the node improves, and one it degrades.
3. At a fleet of one million nodes, explain in one sentence how a per-node processor choice ends up capping the number of parameters in your model.
Lab: Map the Latency-Energy Frontier of a Real Model
Goal. Turn the abstract "accuracy is bought with power and latency" claim into a Pareto curve you plot yourself, by sweeping a single knob (model width) and measuring where each variant lands on the latency-versus-accuracy plane. Budget about 20 to 30 minutes.
Tools. Python with TensorFlow (or PyTorch), NumPy, and Matplotlib; the bundled sklearn.datasets.load_digits set so nothing needs downloading; time.perf_counter for timing.
What to do. Train four versions of the same one-hidden-layer classifier with hidden widths of 8, 32, 128, and 512 units. For each, record test accuracy, then measure median single-sample inference latency by running \(1{,}000\) forward passes and taking the median of perf_counter deltas. Also log each model's parameter count as a stand-in for flash footprint.
What to vary. The hidden width is the primary knob. As a second sweep, quantize each width to int8 with tf.lite.Optimize.DEFAULT and re-measure, so you get two frontiers (float32 and int8) on the same axes.
What to observe. Plot accuracy on the y-axis against latency on the x-axis and connect the points. You should see accuracy climb steeply then flatten while latency and parameter count keep rising, the classic diminishing-returns knee, and the int8 curve should sit to the left of (faster than) the float32 curve at nearly the same accuracy. The knee is the operating point a real deployment would pick; everything to its right is accuracy you are overpaying for. That plot is the tension web of this section, drawn from your own measurements rather than asserted.
What's Next
In Section 1.7, we turn from the constraints that shape any sensory-AI system to the shift reshaping how we build them: the 2023 to 2026 move from bespoke, hand-tuned pipelines toward foundation models and agentic sensing, and what that shift does, and does not, do to the six-constraint web you just met.