← All articles

Training · July 29, 2026 · 3 min read

QLoRA on a budget: fine-tune a 70B model on one GPU

Learn how to use QLoRA and Podstack to fine-tune a 70B parameter model on a single 80GB GPU, optimizing for memory efficiency and cost-per-second billing.

Fine-tuning large language models (LLMs) used to be a luxury reserved for those with massive compute clusters. With the release of Llama 3 and other high-performance 70B models, the barrier to entry has moved from "intelligence" to "infrastructure." However, thanks to QLoRA (Quantized Low-Rank Adaptation) and memory-efficient techniques, you no longer need an 8-GPU node to customize the world’s best open-weight models.

In this guide, we’ll walk through how to fine-tune a 70B parameter model on a single 80GB GPU (like an NVIDIA A100 or H100) using Podstack, keeping your costs low and your iteration speed high.

Why 70B on a Single GPU?

A 70B model in full 16-bit precision requires roughly 140GB of VRAM just to load the weights—long before you even think about gradients or optimizer states. QLoRA changes the math by:

  1. 4-bit Quantization: Reducing the base model weights to 4-bit, shrinking the 140GB footprint to roughly 35-40GB.
  2. Low-Rank Adapters: Only training a small fraction of parameters (the "adapters"), which drastically reduces the memory needed for gradients.
  3. Paged Optimizers: Offloading optimizer states to CPU memory when necessary to prevent Out-of-Memory (OOM) errors.

This allows us to fit the model, the data, and the training overhead into a single 80GB VRAM envelope.

Step 1: Setting Up the Environment

First, ensure you have your PODSTACK_API_KEY configured in your environment. We will use the Podstack API to spin up a high-memory GPU instance.

Podstack does not ship a command-line interface. Use the console, the Python package `podstack-sdk`, or the API at https://podstack.ai/api/v1 with a `ps_live_` key.

Once inside your container, install the essential libraries: bitsandbytes (for quantization), peft (for LoRA), and trl (for the SFT trainer).

pip install -q -U bitsandbytes transformers peft accelerate datasets trl

Step 2: Configuring 4-bit Quantization

The secret sauce is the BitsAndBytesConfig. We use nf4 (NormalFloat 4), which is theoretically optimal for normally distributed weights like those found in LLMs.

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import LoraConfig, get_peft_model

model_id = "meta-llama/Meta-Llama-3-70B-Instruct"

bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_use_double_quant=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.bfloat16
)

model = AutoModelForCausalLM.from_pretrained(
    model_id,
    quantization_config=bnb_config,
    device_map="auto",
    token=True # Ensure your HF_TOKEN is set
)

Step 3: Defining the LoRA Adapter

Instead of updating all 70 billion parameters, we target the linear layers (specifically the attention projections). This reduces the trainable parameters to less than 1% of the original model.

lora_config = LoraConfig(
    r=8, 
    lora_alpha=32,
    target_modules=["q_proj", "v_proj", "k_proj", "o_proj"],
    lora_dropout=0.05,
    bias="none",
    task_type="CAUSAL_LM"
)

model = get_peft_model(model, lora_config)
model.print_trainable_parameters()

Step 4: Memory-Efficient Training

To stay within the 80GB limit, use the SFTTrainer from the trl library with specific flags to save memory:

  • Gradient Checkpointing: Trades compute for memory by re-calculating activations during the backward pass.
  • Groupeded Batching: Ensures sequences of similar lengths are batched together to reduce padding waste.
from trl import SFTTrainer
from transformers import TrainingArguments

training_args = TrainingArguments(
    output_dir="./llama-70b-fine-tuned",
    per_device_train_batch_size=1,
    gradient_accumulation_steps=4,
    learning_rate=2e-4,
    logging_steps=10,
    bf16=True,
    optim="paged_adamw_32bit", # Crucial for saving VRAM
    save_strategy="epoch",
    gradient_checkpointing=True,
    max_steps=500 
)

trainer = SFTTrainer(
    model=model,
    train_dataset=dataset,
    peft_config=lora_config,
    max_seq_length=2048,
    tokenizer=tokenizer,
    args=training_args,
)

trainer.train()

Practical Tips for Success

  1. Monitor VRAM Spikes: Use watch nvidia-smi in a separate terminal. If you hit OOM, reduce your max_seq_length or increase gradient_accumulation_steps while keeping per_device_train_batch_size at 1.
  2. Dataset Quality > Quantity: For 70B models, 1,000 high-quality examples often outperform 50,000 noisy ones.
  3. Use Flash Attention 2: If your GPU supports it (A100/H100), ensure attn_implementation="flash_attention_2" is passed to from_pretrained. It significantly speeds up training and reduces memory usage.

Scaling with Podstack

Fine-tuning a 70B model doesn't have to be an expensive architectural hurdle. On Podstack, you can spin up an 80GB GPU, run your QLoRA job, and shut it down the second it's finished. Because Podstack bills per second, you aren't paying for setup time or idle resources.

Once your training is complete, you can deploy the resulting LoRA adapters as a serverless endpoint using the same Podstack API, allowing you to serve a 70B-grade intelligence without managing the underlying hardware.

Ready to start? Grab your API key and deploy your first 70B trainer today.

Try it on Podstack

Per-second GPUs and pay-per-token models. Add $5, get $10 on your first top-up.

Start building