Add support for QLoRA/ QAdapter training via bitsandbytes #663
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for wrapping bitsandbytes'
Linear4bit
andLinear8bitLt
quantization layers with our LoRA implementation, enabling training LoRA adapters on quantized models in QLoRA style.Implementation is loosely similar to HF peft's approach, which can be found here: https://github.com/huggingface/peft/blob/v0.10.0/src/peft/tuners/lora/bnb.py.
Demo
I've added a new notebook here: https://github.com/calpt/adapter-transformers/blob/dev/qlora/notebooks/QLoRA_Llama_Finetuning.ipynb.
The notebook showcases this feature by finetuning a 4bit-quantized Llama 2 7B on an instruction tuning dataset (similar to Guanaco in the QLoRA paper).
Tested that it runs without errors in the provided notebook, other setups are not extensively tested yet.
Pre-trained checkpoints
Adapters trained with the notebook code can be found here:
Llama-2 7B: https://huggingface.co/AdapterHub/llama2-7b-qlora-openassistant
Llama-2 13B: https://huggingface.co/AdapterHub/llama2-13b-qlora-openassistant
Current limitations