logo

Brillibits

article cover image

Harnessing the Power of Fine-Tuning HUGE LLMs on Consumer Hardware: A Revolutionary Advancement

article cover image

BlakeSeptember 15, 2023

You no longer need to rent expensive GPUs for LLM training. Two Rtx 3090s are enough to train a 70B model.

Harnessing the Power of Fine-Tuning HUGE LLMs on Consumer Hardware: A Revolutionary Advancement

Hello, fellow tech enthusiasts! Today, I'm excited to share a groundbreaking development in the realm of large language models (LLMs) - specifically, the ability to fine-tune state-of-the-art models like Llama 70b on consumer-grade hardware. This advancement paves the way for more individuals and smaller teams to tailor these powerful models to their specific needs without requiring access to industrial-scale computing resources. Let's dive into the details of this transformative update and explore how it opens new horizons for AI applications.

The Advent of QLora and Flash Attention: A Game Changer

The recent innovations of QLora (introduced in May 2023) and Flash Attention 2 have been pivotal in making this feat achievable. QLora introduces a method where an adapter learns the weight updates, allowing the base model - whether it be a GPT or Llama based model - to remain unchanged. Its approach to quantization, reducing the bit precision of the base model to four bits, significantly lessens memory usage requirements. Similarly, Flash Attention modifies the attention mechanism to transform memory requirements from exponential to a more manageable linear trajectory as sequences lengthen, also accelerating training times on longer sequences. These technologies combined have broken new ground, enabling the fine-tuning of Llama 70b on hardware as accessible as consumer-grade GPUs.

The Practical Steps to Fine-Tuning LLMs at Home

Eager to test out these capabilities, I embarked on a journey to fine-tune a model on my setup, powered by two RTX 3090 GPUs. The process began with cloning the my FineTune LLMs repository, setting up the environment via Conda and pip, and installing the requisite Flash Attention and QLora software. Through a detailed exploration of the flags and parameters specific to fine-tuning with these tools, I meticulously configured the training process to leverage the novel capabilities of QLora and Flash Attention optimally.

The fine-tuning operation was directed toward the instruct dataset, developed from the Databricks Dolly 15K dataset. This process not only involved the creation of training, validation, and test files but also a careful consideration of parameters like block size, LoRa configurations, learning rates, and the ingenious use of a rare unused token as a pad token ID, sidestepping issues related to resizing token embedding layers.

Witnessing the Power: Fine-Tuning in Action

Equipped with a deep understanding of the parameters and setup required, I initiated the fine-tuning process. Despite some initial anticipation around the memory usage and computing power needed, I found that both QLora and Flash Attention dramatically optimized the operation, offering a tangible path toward fine-tuning LLMs in settings that were previously unimaginable for individuals like me without renting out GPUs that cost well over $10,000.

The results were nothing short of astonishing. Not only was I able to fine-tune the model on my dataset, but the performance and efficiency of the process were groundbreaking, validating the immense potential of QLora and Flash Attention to democratize access to cutting-edge AI capabilities applied on custom datasets.

Beyond Fine-Tuning: A Vision for the Future

This experience has not only been a testament to technological advancement but also a clarion call to the broader community. The ability to fine-tune LLMs on consumer-grade hardware opens up unprecedented opportunities for custom model development across various domains. From creating instruct models tailored to specific industries to advancing research in fields where computational resources were a barrier, the implications are vast and exhilarating.

Are You Embarking on Your AI Journey?

If you're intrigued by the prospect of fine-tuning LLMs for your projects or are curious about exploring this technology further, I'm more than happy to connect and possibly collaborate. Together, we can push the boundaries of what's possible with AI, making custom models more accessible than ever before.

Get started with Brillibits