Edge AI Deployment: TensorRT, CoreML & Quantized ONNX
What is Edge AI Deployment?
Edge AI deployment runs inference directly on end-user devices—smartphones, IoT sensors, embedded systems, and edge servers—rather than in the cloud. This paradigm shift reduces latency (from 100ms round-trips to <10ms local inference), eliminates network dependency, preserves data privacy, and critically, reduces energy consumption by eliminating data center overhead (cooling, networking, redundant power).
The energy advantage of edge AI is substantial. Cloud inference requires: (1) energy to run the GPU (typically 250-400W per A100), (2) energy for cooling (PUE ~1.2-1.6×), (3) energy for networking (transmitting data to/from the cloud), and (4) energy for data storage and preprocessing. Total cloud inference energy is 3-5× the raw GPU consumption. Edge devices eliminate items (2)-(4), running inference at device TDP (3-15W typically) with no additional overhead.
However, edge devices have strict computational and memory constraints. A smartphone has 4-8 GB RAM versus 80 GB on an A100 GPU; mobile GPUs deliver ~1 TFLOPS versus 312 TFLOPS on A100. This necessitates model optimization: quantization (FP32→INT8/INT4), pruning (removing redundant parameters), and architecture search for efficient designs. The goal is achieving acceptable accuracy on resource-constrained hardware while consuming 10-100× less energy than cloud inference.
TensorRT (NVIDIA), CoreML (Apple), and ONNX Runtime (cross-platform) are the primary deployment frameworks. TensorRT optimizes models for NVIDIA GPUs through kernel fusion, layer optimization, and precision calibration, achieving 2-5× speedup over raw PyTorch. CoreML compiles models for Apple's Neural Engine, achieving 3-8× speedup with <1W power consumption. ONNX Runtime provides cross-platform optimization with execution providers for CPU, GPU, and NPU hardware.
The deployment pipeline typically follows: train in PyTorch/TensorFlow → export to ONNX → apply quantization (PTQ or QAT) → optimize for target hardware (TensorRT/CoreML/ONNX Runtime) → validate accuracy → deploy. Each step must balance accuracy retention against efficiency gains, with the final model meeting both performance requirements and energy budgets.
Project Architecture
Tools & Setup
| Tool | Version | Purpose |
|---|---|---|
| Python | 3.11+ | Core language |
| torch | 2.1+ | Model training |
| onnx | 1.15+ | Model export |
| onnxruntime-gpu | 1.17+ | Optimized inference |
| tensorrt | 8.6+ | NVIDIA GPU optimization |
| coremltools | 7.1+ | Apple CoreML conversion |
| tensorrt | - | Hardware-specific engine |
| numpy | 1.26+ | Numerical operations |
Step 1: Environment Setup
pip install torch onnx onnxruntime-gpu numpy
# For TensorRT (NVIDIA)
pip install tensorrt
# For CoreML (macOS)
pip install coremltools
# For quantization
pip install onnxruntime-training
Step 2: Model Export to ONNX
Quantization Pipeline
TensorRT Optimization
CoreML Conversion
Results & Impact
| Model | Size | Latency | Energy/inference | Accuracy |
|---|---|---|---|---|
| PyTorch FP32 (Cloud) | 25 MB | 45 ms | 0.015 Wh | 94.2% |
| TensorRT FP16 | 13 MB | 8 ms | 0.003 Wh | 94.1% |
| TensorRT INT8 | 6.5 MB | 5 ms | 0.002 Wh | 93.8% |
| ONNX RT INT8 | 7 MB | 12 ms | 0.004 Wh | 93.5% |
| CoreML FP16 (iOS) | 12 MB | 3 ms | 0.001 Wh | 94.0% |
Real-World Case Study
Apple's on-device Siri uses CoreML models quantized to INT8 running on the Neural Engine, processing 100+ million requests daily at <1W power consumption per inference. Compared to cloud-based processing, this saves approximately 50 GWh of data center energy annually while providing <10ms latency versus 100ms+ cloud round-trips. The models achieve 95% of cloud accuracy while using 50× less energy per query.
Common Pitfalls
- INT8 Calibration Data Mismatch: Using training data instead of representative deployment data for calibration causes 3-5% accuracy drop
- Ignoring Memory Bandwidth: Edge inference is often memory-bound; quantization helps more than compute optimization
- Dynamic Shapes on Edge: Dynamic batch sizes waste memory on edge devices; use fixed batch sizes
- Missing Hardware Validation: Models optimized for GPU may perform poorly on NPU; always validate on target hardware
- Forgetting Energy Profiling: Latency benchmarks don't capture energy; measure actual power consumption on device
Summary with Key Takeaways
Edge AI deployment reduces inference energy by 5-50× compared to cloud inference through quantization, pruning, and hardware-specific optimization. TensorRT, CoreML, and ONNX Runtime provide production-grade deployment pipelines that maintain >95% of original accuracy while achieving 2-10× latency reduction.
Key considerations include choosing the right precision (FP16 for accuracy, INT8 for efficiency), calibrating quantization on representative data, and validating on actual target hardware. The resulting edge deployments enable privacy-preserving, low-latency, energy-efficient AI that scales to billions of devices without proportional energy increases.