Coder Social home page Coder Social logo

cliu0013 / qlth Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 29.34 MB

QLTH is a 2-step model compression scheme that applies Post-Training Quantization on the ”winning tickets” or ”matching” derived by iterative magnitude prunning.

License: Apache License 2.0

Python 28.11% CSS 0.01% Jupyter Notebook 71.89%

qlth's Introduction

Quantizing Lottery Tickets

This is the code for QLTH, a 2-step model compression scheme that applies Post-Training Quantization on the subnetworks derived by iterative magnitude prunning used in finding ”winning tickets” or ”matching”.

LTH Experiments

All LTH experiments are conducted using the OpenLTH framework, which is located in the folder open_lth.

First do cd open_lth, then:

the Lottery Ticket without Rewinding experiment results could be reproduced with the following commands:

python open_lth.py lottery --model_name cifar_resnet_20 --default_hparams=cifar_resnet_20 --levels=10
python open_lth.py lottery --model_name cifar_resnet_56 --default_hparams=cifar_resnet_20 --levels=10
python open_lth.py lottery --model_name mnist_lenet_300_100 --default_hparams=mnist_lenet_300_100 --levels=15

and the Lottery Ticket with Rewinding experiment results could be reproduced with the following commands:

python open_lth.py lottery --model_name cifar_resnet_20 --default_hparams=cifar_resnet_20 --levels=10 --rewinding_steps=2000it
python open_lth.py lottery --model_name cifar_resnet_56 --default_hparams=cifar_resnet_20 --levels=10 --rewinding_steps=2000it

Quantization Experiments

After deriving the checkpoints for LTH experiments, the quantization experiments could be performed using the Neural Network Distiller library. The experiment scripts are located in the folder examples/classifier_compression.

First do cd examples/classifier_compression, then adjust the following command to run experiments for different settings:

python compress_classifier.py -a [MODEL_ARCH] [DATASET_PATH] \
                --resume [LOTTERY_MODEL_CHECKPOINT_PATH] \
                --evaluate --lth --pruned -mp [LOTTERY_MASK_PATH] \
                --qe --qebw [QE_NUM_BITS_WTS] --qeba [QE_NUM_BITS_ACTS] --qem [QE_MODE]

For example, the following command will run a quantization experiment on a trained ResNet 20 model with 90% of parameters pruned, using 8 bits for weights and activation quantization, and asymmetric quanzation mode:

python compress_classifier.py -a resnet20_cifar ../../../data.cifar10 \
                --resume ~/open_lth_data/lottery_6a3f90a482a5e73fa0473f151fe64163/replicate_1/level_10/main/model_best.pth \
                --evaluate --lth --pruned -mp ~/open_lth_data/lottery_6a3f90a482a5e73fa0473f151fe64163/replicate_1/level_10/main/mask.pth \
                --qe --qebw 8 --qeba 8 --qem asym_u

Some Results

This section includes parts of the results provided in the report.

LeNet 300-100 on MNIST dataset using our IMP-quantization pipeline

ResNet 20 on CIFAR10 dataset using our IMP-quantization pipeline (with rewinding in IMP)

ResNet 56 on CIFAR10 dataset using our IMP-quantization pipeline (with rewinding in IMP)

qlth's People

Contributors

xiuyu-li avatar

Watchers

James Cloos 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.