peft-fine-tuning

Fine-tune LLMs with LoRA, QLoRA, and adapter methods using HuggingFace PEFT.

Updated May 29, 2026
One-click install
npx skills add https://github.com/m4an5you6/aspera-agent --skill peft-fine-tuning-m4an5you6
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: peft-fine-tuning
Source: https://github.com/m4an5you6/aspera-agent/tree/main/optional-skills/mlops/peft
Command: npx skills add https://github.com/m4an5you6/aspera-agent --skill peft-fine-tuning-m4an5you6

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires peft, transformers, torch, bitsandbytes, and includes references (resource) components.

What problem does it solve? Full fine-tuning of large language models (7B-70B parameters) requires enormous GPU memory and produces multi-gigabyte checkpoints. This Skill enables parameter-efficient fine-tuning that trains less than 1% of model parameters, producing megabyte-sized adapters that run on consumer GPUs. ## Core Features & Use Cases - LoRA and QLoRA Fine-Tuning: Train low-rank adapters on models like Llama 3.1 8B with 18GB memory, or 70B models on a single 24GB GPU using 4-bit quantization. - 25+ PEFT Methods: Includes AdaLoRA, IA3, Prefix Tuning, Prompt Tuning, DoRA, and LoftQ with guidance on rank, alpha, and target module selection per architecture. - Multi-Adapter Serving: Load, switch, merge, and compose multiple adapters at runtime, with integration patterns for TRL, Axolotl, and vLLM. - Use Case: Fine-tune Llama 3.1 8B on the Dolly-15k instruction dataset with LoRA rank 16, producing a 6MB adapter instead of a 16GB full model checkpoint. ## Quick Start Fine-tune a Llama 3.1 8B model on my instruction dataset using LoRA with rank 16 and save the resulting adapter.

Frequently Asked Questions about peft-fine-tuning

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fine-tune a Llama model with LoRA in Python?▼

Load the base model with transformers, create a LoraConfig specifying rank, alpha, and target modules like q_proj and v_proj, then wrap the model with get_peft_model. Train with the standard Trainer and save only the adapter weights with save_pretrained.

What is the difference between LoRA and QLoRA?▼

QLoRA combines LoRA adapters with 4-bit NF4 quantization of the base model via bitsandbytes, reducing memory from 18GB to 6GB for an 8B model. Use QLoRA when memory is the primary constraint and you can accept roughly 5% quality trade-off.

What LoRA rank should I use for fine-tuning?▼

Start with rank 8-16 for general fine-tuning, which trains about 0.17% of parameters. Use rank 32-64 for complex tasks, domain adaptation, or 70B models, and set lora_alpha to twice the rank as a starting point.

Can I serve multiple LoRA adapters on one base model?▼

Yes, PEFT supports loading multiple adapters with load_adapter and switching between them at runtime using set_adapter. vLLM also supports batched inference with different adapters via LoRARequest and enable_lora.

Why does CUDA run out of memory during LoRA training?▼

OOM occurs from large batch sizes, high rank, or missing gradient checkpointing. Enable gradient checkpointing with prepare_model_for_kbit_training, reduce per-device batch size with gradient accumulation, or switch to QLoRA 4-bit quantization.

When should I use full fine-tuning instead of PEFT?▼

Use full fine-tuning for models under 1B parameters, when maximum quality is required with sufficient compute budget, or when significant domain shift requires updating all weights. PEFT targets scenarios where memory and iteration speed matter more.