How to Quantize a ResNet from Scratch! Full Coding Tutorial (Eager Mode)

Published: 26 February 2024
on channel: Oscar Savolainen
2,239
81

If you need help with anything quantization or ML related (e.g. debugging code) feel free to book a 30 minute consultation session! https://calendly.com/oscar-savolainen

I'm also available for long-term freelance work, e.g. for training / productionizing models, teaching AI concepts, etc.

Video Summary:
In this first of its kind video, we take a publicly available PyTorch ResNet model, and statistically quantize it entirely from scratch! We go through the coding steps of making architecture changes (QuantStubs/DeQuantStubs, FloatFunctionals), fusing modules, assigning qconfigs, preparing the model for fake-quant, and finally converting the model to a "true" int8 model. We find and squash some nasty bugs, go through some of the important documentation, and gain an understanding of how Eager Mode, Static Quantization works.

Timestamps:
00:00 Intro
03:19 Setting Up
06:35 Step 1: Architecture changes
10:11 Step 2: Fusing modules
31:35 Step 3: Assigning QConfigs
38:13 Step 4: Preparing the model for fake-quant
46:23 Evaluating our models
51:00 Solving the fusing bug
54:50 Static quantization, turning off observers
59:09 Step 5: Converting the model
01:00:38 Solving the conversion bug: adding FloatFunctionals

Links:
See this video for the theory on how to quantize a PyTorch model in Eager mode:    • How to statically quantize a PyTorch model...  
Github for the code from this tutorial: https://github.com/OscarSavolainen/Qu...
Useful PyTorch quantization Github link: https://github.com/pytorch/pytorch/tr...
NVIDIA white paper: https://arxiv.org/abs/2004.09602


On this page of the site you can watch the video online How to Quantize a ResNet from Scratch! Full Coding Tutorial (Eager Mode) with a duration of hours minute second in good quality, which was uploaded by the user Oscar Savolainen 26 February 2024, share the link with friends and acquaintances, this video has already been watched 2,239 times on youtube and it was liked by 81 viewers. Enjoy your viewing!