Skip to content

About

Learn model optimization for edge deployment

Resources

Stars

15 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Model Optimization 101

Hands-on exercises for learning the core ideas of model optimization for edge deployment.

The five ideas

# Exercise One line Core to focus on
1 Quantization Use fewer bits to represent numbers quantization scheme & formula, compression ratio
2 Knowledge Distillation A big model teaches a small one distillation loss formula, teacher-student architecture
3 Pruning Remove unused signals granularity, ratio, criteria
4 Neural Architecture Search Search for an optimal architecture search space & strategy
5 Kernel Optimization Make the same math run faster on the GPU tiling, grid layout, memory access

Kernel optimization is more hardware-constrained and usually speeds up the computation without changing the math. Meanwhile, the remaining ideas are more abstract and usually change what the model computes. They are orthogonal in concept and may be coupled in realization. For example, a quantized matmul kernel is entirely possible.

How to run

Google Colab

  1. Open the notebook for an exercise (links above).
  2. Click "Open in Colab" (badge at the top of each notebook), or upload the .ipynb to Colab manually.
  3. Set the runtime to GPU (Runtime -> Change runtime type -> GPU).
  4. Runtime -> Run all.

Local

To run locally instead:

pip install -r requirements.txt
jupyter lab

Reading guide

The core concept is highlighted in every notebook. Everything else - data loading, training loops, plotting - can be skimmed. Every exercise records model size, latency and accuracy before vs. after the optimization so the trade-off can be considered.

Applications

Deploying optimized models on a laptop:

chat

video

About

Learn model optimization for edge deployment

Resources

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages