This project was originally concieved as a hackday project for Deep Hack Mar 2023, but has since been extended to be a way to introduce people to Quantization. The corresponding talk was done at GenerativeAI Apr Meetup.
Updated: 2023-04-27 10:05pm IST
Basics
Demo
Uniform Quantization (INT8)
Distribution of weights:
We ran out of time to cover other slides in the talk, but you can refer to some minor comments in the presented notes of those slides.
In this demo, we use @hila-chefer's work on Transformer Explainability to empirically study the effect of reduced precision at inference time. The rather successful recent efforts to deploy llama.cpp on hardware as weak as a Raspberry Pi was a major factor to explore this.
IEEE 754 standard for floating point precision describes a float32 as 1-bit (sign); 8-bits (exponent); 23-bits (fraction). We take a rather crude approach to simulating precision by simply truncating the least n significant bits of the fractional part to zero. We do this for all the parameters of the model.
Important caveats: * While the model's precision was varied, computations were still being done as float32. * Exponent part was not touched, so the range of the model weights remained the same.
pip install -r requirements.txtstreamlit run app.pyFor every image we tested, the model was able to be resilient at inference time to about 3-bits of fractional precision (translating roughly to a single decimal point).
6 commits
Python
100.0%
This project was originally concieved as a hackday project for Deep Hack Mar 2023, but has since been extended to be a way to introduce people to Quantization. The corresponding talk was done at GenerativeAI Apr Meetup.
Updated: 2023-04-27 10:05pm IST
Basics
Demo
Uniform Quantization (INT8)
Distribution of weights:
We ran out of time to cover other slides in the talk, but you can refer to some minor comments in the presented notes of those slides.
In this demo, we use @hila-chefer's work on Transformer Explainability to empirically study the effect of reduced precision at inference time. The rather successful recent efforts to deploy llama.cpp on hardware as weak as a Raspberry Pi was a major factor to explore this.
IEEE 754 standard for floating point precision describes a float32 as 1-bit (sign); 8-bits (exponent); 23-bits (fraction). We take a rather crude approach to simulating precision by simply truncating the least n significant bits of the fractional part to zero. We do this for all the parameters of the model.
Important caveats: * While the model's precision was varied, computations were still being done as float32. * Exponent part was not touched, so the range of the model weights remained the same.
pip install -r requirements.txtstreamlit run app.pyFor every image we tested, the model was able to be resilient at inference time to about 3-bits of fractional precision (translating roughly to a single decimal point).
6 commits
Python
100.0%