GithubHelp home page GithubHelp logo

mbv1_brevitas's Introduction

CIFAR10 MB1 Brevitas Quantization Training Framework

This Framework supports CIFAR10 MobileNetV1(MB1) PACT, LSQ Quantization aware Training based on FINN Brevitas. Below in the table is a list of CIFAR10 Quantized MB1 Performances.

Clip Value Quantization Method  A4W4 A2W2
Per Channel Brevitas 91.53 -
Per Layer Brevitas 91.29 -
Per Layer PACT_SAWB 91.37 85.78
Per Layer PACT_LSQ 91.44 87.42

Quantization Setting

Before Quantization Aware Trainig, We initialized model weight using Full Preicision MB1 model file.

CIFAR10 Full Precision MB1 Accuracy is 91.6.
(We trained Full Precision MB1 model using this code. you can use your own Full Precision MB1 Model)

Bit Width

  • AXWX means Quantization Bit-Width Set. (eg. AWBW : Activation X bit, Weight X bit Quantization)

Clipping Value

  • Per Channel : Per channel means that for each dimension, typically the channel dimension of a tensor, the values in the tensor are scaled and offset by a different value

  • Per Tensor(Per Layer) : Per tensor means that all the values within the tensor are scaled the same way.

  • PACT Activation Quantization's clipping initial value is constant. Our A2W2 MB1 PACT_LSQ model has its best performace when PACT activation Quantization's initial value was 3, Clipping Weight decay was 0.0005

Quantization Method

  • Brevitas : Brevitas is a PyTorch research library for quantization-aware training (QAT). It supports FINN Compile
  • PACT_SAWB : This means that Quantizing Activation uses PACT Algorithm, Quantizing Weight uses LSQ Algorithm.

Quantization Alogorithm You can find more detailed information about Quantization in this link.

Traininig

  • You can try Quantization Aware Training with this command.

  • Your Pretrained Full Precision Model file's directory shoulb be specified in cfg/quant_mobilenet_v1_cifar10_2b.ini, PRETRAINED_DIR

    python imagenet_train.py --network quant_mobilenet_v1_cifar10_2b --experiments ./experiments --optim SGD --scheduler STEP --pretrained --gpus 0 --lr 0.01 --weight_decay 0.003 
    

Accelerator Deploy Results

After Training QNN using Brevitas, you can export onnx file for finn compiler (refer to onnx_make.py) https://github.com/xilinx/finn Using finn compiler, you can make bitfile for 2bit Quantized CIFAR10 MobileNetv1 Inference on Alveo FPGA Board.

FPGA Board Inference time and Hardware Usage results are followed.

Hardware Unit Usage

  PACT A4W4 PACT A2W2
Date 20211216 20211220
Dataset CIFAR10 CIFAR10
Total LUTs 514905 275234
LUTRAM 24269 17495
Flip-Flop 564244 374026
BRAM36 703 490
BRAM18 135 41
URAM 32 22
DSP 103 103

FPGA Board Inference Performance

  Date Dataset Pytorch ACC HW Acc Full Validation Time (per loop) (ms) Runtime (ms) Throughput [images/s] DRAM in BW DRAM out BW fclk (mhz) batch_size fold_input (ms) pack_input (ms) copy_input_data_to_device (ms) copy_output_data_to_device (ms) unpack_output (ms) unfold_output (ms)
PACT A4W4 20211216 CIFAR10 91.44 91.34 535 51.72 19333.93 59.39 0.02 245 1000 0.04 0.026 1.21 0.167 0.31 0.014
PACT A2W2 20211220 CIFAR10 87.40 87.45 635.00 61.85 16,169.31 49.67 0.02 209.00 1,000.00 0.02 0.02 1.26 0.13 0.23 0.03

mbv1_brevitas's People

Contributors

marsjacobs avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.