System Design Principles
Designing edge AI systems requires balancing competing constraints: computational power, memory, energy consumption, latency, and model accuracy. Unlike cloud-based systems with virtually unlimited resources, edge architectures must operate within strict hardware boundaries while delivering responsive, reliable AI capabilities.
The Resource Triangle
Every edge AI system navigates three fundamental constraints:
- Computational Budget: Available FLOPS (floating-point operations per second) or TOPS (tera operations per second)
- Memory Budget: RAM for model weights and activations, storage for the model file
- Power Budget: Energy consumption, critical for battery-powered devices
Optimizing for one dimension often requires trade-offs in others. A highly accurate model may demand more computation and memory, increasing power draw. The art of edge AI architecture lies in finding the optimal balance for your specific use case.
Layered Architecture
Application Layer
The application layer provides the user-facing interface and orchestrates AI functionality. On mobile devices, this might be a native iOS/Android app. On embedded systems, it could be custom firmware. This layer:
- Captures input data (camera frames, audio, sensor readings)
- Preprocesses data (resizing, normalization, feature extraction)
- Invokes the inference engine
- Postprocesses results (non-max suppression, filtering, formatting)
- Presents outputs to users or downstream systems
// TypeScript example: Application layer inference workflow
import { EdgeAIClient } from '@wia/edge-ai';
const client = new EdgeAIClient({
model: 'object_detector_v2',
backend: 'gpu',
optimizations: ['fp16', 'pruning']
});
async function processFrame(imageData: ImageData): Promise {
// Preprocess
const tensor = await preprocessImage(imageData, {
resize: [300, 300],
normalize: true,
colorSpace: 'RGB'
});
// Inference
const outputs = await client.infer(tensor);
// Postprocess
const detections = await postprocessDetections(outputs, {
confidenceThreshold: 0.6,
nmsThreshold: 0.4,
maxDetections: 10
});
return detections;
}
Inference Engine Layer
The inference engine executes neural network computations. Popular frameworks include:
- TensorFlow Lite: Google's cross-platform mobile/embedded ML framework
- ONNX Runtime: Microsoft's high-performance cross-platform inference engine
- Core ML: Apple's optimized framework for iOS/macOS
- PyTorch Mobile: Facebook's mobile deployment solution
- TensorRT: NVIDIA's high-performance deep learning inference optimizer
The inference engine handles:
- Loading and parsing model files
- Graph optimization (operator fusion, constant folding)
- Memory management for tensors and activations
- Scheduling operations across available hardware
- Quantization and precision management
Hardware Abstraction Layer (HAL)
The HAL provides a uniform interface to diverse hardware accelerators. This allows the same model to run efficiently on different devices without application code changes. The HAL manages:
- Detecting available accelerators (CPU, GPU, NPU, DSP)
- Translating operations to hardware-specific instructions
- Managing data movement between processors
- Power management and thermal throttling
Hardware Components
Central Processing Unit (CPU)
General-purpose processors handle non-parallelizable tasks and coordinate system operations. While not optimized for neural network math, modern CPUs include:
- SIMD Instructions: AVX-512 (x86), NEON (ARM) for vectorized operations
- Multi-core Architecture: Parallel processing across multiple cores
- Cache Hierarchy: Fast L1/L2/L3 caches reduce memory latency
CPU inference is suitable for small models or when specialized accelerators aren't available. Performance typically ranges from 1-10 GFLOPS.
Graphics Processing Unit (GPU)
Originally designed for graphics rendering, GPUs excel at parallel matrix operations—the core of neural network inference. Mobile GPUs like Adreno (Qualcomm), Mali (ARM), and Apple GPU provide:
- Hundreds of parallel cores
- Optimized matrix multiplication units
- 10-100x speedup over CPU for large models
- FP16 (half-precision) support for efficiency
GPU inference works well for medium-to-large convolutional and transformer models where parallelism can be fully exploited.
Neural Processing Unit (NPU)
Also called AI accelerators or neural engines, NPUs are purpose-built for neural network inference. Examples include:
- Apple Neural Engine: 15.8 TOPS on A17 Pro, optimized for Core ML
- Google Tensor G3: Custom TPU for Pixel devices
- Qualcomm AI Engine: Hexagon DSP + NPU, up to 45 TOPS
- Samsung Exynos NPU: Integrated AI accelerator
NPUs offer:
- 10-100x better performance per watt than GPUs
- Specialized operations (convolution, pooling, activation)
- Low-precision arithmetic (INT8, INT4) support
- Always-on capability for continuous sensing
Digital Signal Processor (DSP)
DSPs specialize in signal processing—audio, video, and sensor data. Qualcomm's Hexagon DSP can run AI workloads efficiently, particularly for:
- Audio processing (speech recognition, noise cancellation)
- Always-on sensor processing (step counting, keyword detection)
- Low-power inference (1-2 watts)
Software Stack
Operating System Integration
Edge AI frameworks integrate deeply with mobile and embedded operating systems:
| Platform | Framework | Hardware Support |
|---|---|---|
| iOS / macOS | Core ML | CPU, GPU, Neural Engine |
| Android | TensorFlow Lite, NNAPI | CPU, GPU, NPU, DSP |
| Linux Embedded | TensorFlow Lite, ONNX Runtime | CPU, GPU (OpenCL/Vulkan) |
| RTOS | TensorFlow Lite Micro | CPU (Cortex-M) |
Model Deployment Pipeline
Getting a trained model from the training environment to edge devices involves several steps:
1. Train Model (PyTorch/TensorFlow)
↓
2. Export to Intermediate Format (ONNX, SavedModel)
↓
3. Convert to Edge Format (TFLite, CoreML, ONNX)
↓
4. Optimize (Quantization, Pruning, Layer Fusion)
↓
5. Benchmark on Target Hardware
↓
6. Package for Deployment
↓
7. Deploy via OTA Update or App Bundle
↓
8. Runtime Inference on Device
Deployment Patterns
Fully On-Device Deployment
The entire AI pipeline runs locally with zero cloud dependency. Ideal for:
- Privacy-sensitive applications (health, biometrics)
- Offline-first use cases (rural areas, aircraft)
- Low-latency requirements (AR/VR, robotics)
Pros: Maximum privacy, lowest latency, no bandwidth costs, works offline
Cons: Limited to what device hardware can run, no centralized learning
Edge-Cloud Hybrid
Simple tasks run on-device, complex processing falls back to cloud. For example:
- Face detection on-device, face recognition in cloud
- Wake word detection on-device, full speech-to-text in cloud
- Basic image classification on-device, detailed scene understanding in cloud
Pros: Balance of performance and privacy, graceful degradation
Cons: Still requires connectivity for advanced features
Federated Edge Architecture
Models train collaboratively across edge devices. Each device:
- Downloads the current global model
- Trains on local data
- Uploads only model updates (gradients) to server
- Server aggregates updates from many devices
- Broadcasts improved global model
Pros: Privacy-preserving learning, models improve from collective data
Cons: Communication overhead, requires coordination infrastructure
Edge Mesh Networks
Edge devices collaborate directly without central servers. Useful in:
- Swarm robotics (drones, warehouse robots)
- Distributed sensor networks
- Vehicle-to-vehicle communication
Memory Management
Model Storage
Models are stored compressed on disk and loaded into RAM for execution. Techniques to reduce footprint:
- Weight Sharing: Reuse weights across layers
- Quantization: INT8 uses 1/4 the space of FP32
- Pruning: Remove zero or near-zero weights
- Compression: Huffman coding, CSR sparse formats
Activation Memory
During inference, intermediate layer outputs (activations) require temporary memory. For a ResNet-50 processing a 224x224 image:
// Activation memory calculation
Input: 224 × 224 × 3 = 150,528 values
Conv layers: ~10 MB peak activation memory
Output: 1000-class probabilities
Total peak memory: ~15 MB (with FP32)
Optimized (FP16): ~7.5 MB
Further optimized (INT8): ~4 MB
Memory optimization strategies:
- In-place Operations: Reuse input buffer for output
- Gradient Checkpointing: Recompute activations instead of storing
- Memory Planning: Reuse memory buffers across non-overlapping layers
Power Management
Power Consumption Sources
Edge AI power draw comes from:
- Computation: FLOPs executed by CPU/GPU/NPU
- Memory Access: Reading weights and activations from RAM
- Data Movement: Transferring data between processors
- Peripheral Activity: Sensors, cameras, radios
Energy-Efficient Design
Strategies to minimize power consumption:
- Use Specialized Accelerators: NPUs achieve 50-100x better TOPS/W than CPUs
- Quantize Models: INT8 inference uses ~4x less energy than FP32
- Adaptive Inference: Run lightweight models by default, heavier models only when needed
- Duty Cycling: Inference only at specified intervals, not continuously
- Early Exit Networks: Stop computation early when confident
// Adaptive inference example
async function adaptiveInference(image: Tensor): Promise {
// Try lightweight model first (10ms, 50mW)
const quickResult = await lightModel.infer(image);
if (quickResult.confidence > 0.95) {
return quickResult; // High confidence, use quick result
}
// Fall back to heavy model for uncertain cases (50ms, 200mW)
return await heavyModel.infer(image);
}
Performance Optimization
Model Architecture Selection
Some architectures are inherently more edge-friendly:
| Architecture | Edge Suitability | Use Case |
|---|---|---|
| MobileNet | Excellent | Image classification, detection |
| EfficientNet | Excellent | High-accuracy image tasks |
| SqueezeNet | Good | Ultra-low footprint imaging |
| BERT-Tiny | Good | Language understanding |
| ResNet-50 | Moderate | Requires optimization for edge |
| GPT-3 | Poor | Too large for edge deployment |
Operator Optimization
Inference engines optimize neural network operations through:
- Operator Fusion: Combine sequential ops (Conv + BatchNorm + ReLU) into single kernel
- Constant Folding: Pre-compute operations with constant inputs
- Layout Optimization: Reorder tensor dimensions for hardware efficiency
- Kernel Selection: Choose fastest implementation for target hardware
Benchmarking and Profiling
Key Metrics
When evaluating edge AI systems, measure:
- Latency: Time from input to output (P50, P95, P99)
- Throughput: Inferences per second (fps for vision, queries/s for NLP)
- Memory Usage: Peak RAM consumption during inference
- Model Size: Disk space required for model file
- Power Consumption: Watts or mAh per inference
- Accuracy: Model quality (mAP, top-1/top-5, F1 score)
Profiling Tools
- TensorFlow Lite Benchmark Tool: Measure latency and throughput
- Xcode Instruments: Profile iOS/macOS apps
- Android Profiler: CPU, memory, energy profiling
- NVIDIA Nsight: Deep profiling for CUDA/TensorRT
弘益人間 Architecture Principle:
Design edge AI systems that empower users while respecting their privacy, device resources, and autonomy. Optimize for efficiency not just performance—every milliwatt saved extends battery life, every megabyte saved makes models accessible to more devices.
Summary
Edge AI architecture balances computational constraints, memory limits, and power budgets to deliver responsive, efficient AI on resource-constrained devices. Key architectural components include:
- Layered software stack (application, inference engine, HAL)
- Specialized hardware accelerators (NPU, GPU, DSP)
- Optimized inference frameworks (TensorFlow Lite, Core ML, ONNX Runtime)
- Memory-efficient model deployment and activation management
- Power-conscious design leveraging hardware acceleration and quantization
Deployment patterns range from fully on-device (maximum privacy, offline capability) to edge-cloud hybrid (balancing performance and resource constraints) to federated edge (collaborative learning while preserving privacy).
Success in edge AI requires holistic optimization—selecting appropriate model architectures, leveraging hardware accelerators, optimizing memory usage, and measuring performance across latency, throughput, power, and accuracy dimensions.
Review Questions
- What are the three fundamental constraints in the "resource triangle" of edge AI?
- Describe the responsibilities of each layer in the edge AI software stack.
- Compare and contrast CPU, GPU, and NPU for edge AI inference.
- What advantages do NPUs provide over GPUs for neural network inference?
- Explain the model deployment pipeline from training to edge device.
- What are the pros and cons of fully on-device deployment versus edge-cloud hybrid?
- How does federated edge architecture preserve privacy while enabling model improvement?
- What techniques reduce activation memory consumption during inference?
- Why do specialized accelerators (NPUs) achieve better energy efficiency than general-purpose processors?
- Name five key metrics for benchmarking edge AI systems.