AOSSIE-Org / AOSSIE-Org/EduAid

Add Quantization Support to Backend for Efficient Model Loading on Smaller GPUs

オープン
#106 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
171
フォーク
425
PR マージ指標
30日以内にマージされた PR はありません

説明

### Description

Currently, the backend service loads models onto the GPU for inference. However, the models are too large for smaller GPUs like NVIDIA 3050 Ti, NVIDIA 1080 which are present on laptops or low-end devices, leading memory overflows i.e CUDA Error. To improve the service's compatibility and efficiency on these devices, I propose adding quantization to the backend.

The error occurred due to the fact that the model is larger than the GPU's VRAM limit

![cuda_out_of_memory](https://github.com/user-attachments/assets/1b51a125-7762-4aae-9814-c080545b76cf)

The GPU usage on NVIDIA 3050 Ti after loading only 2 models out of the Bunch.

![gpu_usage](https://github.com/user-attachments/assets/58424454-f60b-4f01-99db-fb538ed85b15)

### Proposed Solution

**Integrate Model Quantization:**

Add support for model quantization (8bit or 4bit) to the backend service.
Utilize available quantization libraries/frameworks like _bitsandbytes / accelerate_ to lower the GPU usage.

**Dynamic Quantization Option:**

Allows the system to make the decision whether quantization of model is required or not on the basis of the size of the user's GPU. Also allows users to manually enable or disable quantization through a configuration parameter.

### Advantages of Quantization:

**Reduced GPU Usage**
The Quantization reduces the Model's size. And allows it to be loaded on devices which were earlier incapable of loading the model, due to memory constraint

Terminal Output due to quantization

![quantization_model_warning](https://github.com/user-attachments/assets/a603c09f-e918-4748-b572-b884392b3e26)

The GPU usage after quantizing all the models in the backend

![after quantization](https://github.com/user-attachments/assets/22014968-628b-43f2-a5bd-5b47f2079913)

Since this leaves plenty of space empty in the GPU, hence, it allows for larger loads that can be handled by the GPU.

**Faster Inference**

Since Quantization works at the bit level of each parameter of the model, it reduces the size of each parameter, and thus allows more operations to done in a single cycle. Hence making the inference faster.

The link for the mathematical insights of Quantization, for better understanding
https://chautuankien.medium.com/quantization-technique-part-1-d8ab5c0379e9

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。