Giter Site home page Giter Site logo

akimoto-cris / niti Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wangmaolin/niti

0.0 1.0 0.0 61.49 MB

Implementation of "NITI: Training Integer Neural Networks Using Integer-only Arithmetic" on arxiv

Home Page: https://arxiv.org/abs/2009.13108

License: BSD 2-Clause "Simplified" License

Python 0.84% Cuda 1.26% C++ 96.47% Shell 0.01% Dockerfile 0.01% Makefile 0.02% C 1.35% CMake 0.04%

niti's Introduction

Neural networks Training and Inference using Integer-only arithmetic

Update(Nov 2021)

I've made some improvments recently:

  • Pure int8 training has no accuracy degradation on CIFAR10 comparing with fp32 now.
  • Implementation of faster native int8 convolution forward pass and backward pass based on NVIDIA's cutlass
  • Update CUDA versoin to 11.1 to support RTX 3090(sm86). Please update driver and change the dockerfile pytorch version if you want to use it.
  • The arxiv paper will be updated to discuss the improvements soon.

Introduction

NITI is a training framework which uses 8 bits signed integer exclusively to train neural network. It's currently implemented on Nvidia GPU with tensor cores(like V100, RTX 2080Ti, T4, RTX 8000, and RTX 3090). The major computation flow of the convolution and fully connected layer are shown below:

Int flow

Usage

Step 1: Update NVIDIA driver and install NVIDIA docker

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html

Step 2: Download NITI

git clone https://github.com/wangmaolin/niti.git

Step 3: Modify the path in docker_run.sh

Change NITI_PATH in docker_run.sh to the location where you download NITI.

Step 4: Launch the docker at $NITI_PATH

docker_run.sh

Step 5: Install the tensor core extension

Inside the docker, run:

make

Examples of training int8 VGG on CIFAR10

./train_vgg_cifar10.sh

Visualize training results

Example results of training VGG-small-7, VGG-small-8 and VGG-small-9 with integer arithmetic are located at ./results. Comparing with floating point, there is no accuracy degradation for these 3 networks.

For example, this is the training curves for VGG-small-9: Int flow

If you want to to check detailed training information, run:

tensorboard --logdir results/int-vgg-small-8/runs

Notes

Current implementation utilizes cuBLAS and CUTLASS to run int8 matrix multiply and convolution operations directly on tensor cores.

Some key codes

ti_torch.py

Implementation of convolution, fully connected layer with int8 forward pass and backward pass

pytorch/cutlass-extension

CUDA extension doing 8 bits integer convolution forward pass and backward pass

pytorch/tcint8mm-extension

CUDA extension using tensor core to accelerate 8 bit signed integer matrix multiply

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.