Skip to content

dataroot/peft-benchmark

Repository files navigation

Tuning LLM Efficiently: A Deep Dive into PEFT

MIT License Hydra Made with PyTorch Lightning Runs on Modal Built with Taskfile


Overview

This repository contains code used in the article "Tuning LLM Efficiently: A Deep Dive into PEFT".

A reproducible benchmark of PEFT methods on the MRPC dataset (from the GLUE benchmark), focusing on efficient LLM adaptation using Modal cloud GPU environments.

The repo provides:

  • ⚡ Fine-tuning pipelines for classification using PEFT methods (LoRA, BitFit, FourierFT, etc.)
  • 🚀 Ready code for training on Modal with A100s
  • ⚙️ Configurable Hydra-based training system
  • 🔧 Developer-friendly Taskfile for automation

Dependencies installation

To install all required dependencies, run the following command:

task dev-install

Tip: Please, follow these instructions to install Task on your OS if it isn’t already installed.


Environment setup

To run the training pipeline on Modal, you’ll need to sign up and create a user account. Then, run the following command and confirm your local workspace:

task modal-setup

You'll also need to have WandB and HuggingFace accounts to get API keys. Pass these to the environment variables along with the training configuration name:

HF_API_TOKEN=your-huggingface-api-token
WANDB_API_KEY=your-wandb-api-key
TRAIN_CONFIG=your-hydra-config-name

Tip: Create a .env file in the project’s root directory and store the above environment variables there.


Hydra configurations

Hydra is a powerful framework developed by Meta for managing complex configurations. It enables clean hierarchical configuration via .yaml files. In this project, Hydra is used to manage all the configurations related to:

  • Model settings (e.g., model checkpoint, number of classes)
  • Dataset loading (e.g., task name, batch size, max sequence length)
  • Training (e.g., epochs, seed, gradient clipping)
  • Optimizer & scheduler setup
  • PEFT strategy configuration (e.g., LoRA, PrefixTuning, BitFit)
  • Logging & experiment tracking (e.g., Weights & Biases)

Tip: Please read this tutorial to learn how to use Hydra to its full potential.

Ready-to-use configuration files (as used in our article) are provided in the configs directory.

To run one of the PEFT fine-tuning pipelines, simply set the TRAIN_CONFIG environment variable to the name of the desired .yaml config and execute:

task run-ft

We hope this project helps you explore and compare different PEFT strategies with minimal effort.

If you have any questions, issues, or ideas for improvement, feel free to reach out!

Happy fine-tuning! 🚀

About

Tuning LLM Efficiently: A Deep Dive into PEFT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages