LocalLLM Forum — Run it locally. Own your models.

QLoRA on a single 24GB card: lessons learned

M posted by MateusKeller #qlora#lora#fine-tuning 3 posts 445 views
M

I just finished a QLoRA run on my 3090 — 8B base model, 52k instruction pairs, 3 epochs in 9 hours — and wrote down everything I would tell myself two weeks ago.

Config that worked:

LoRA r=16, alpha=32, targets: q_proj,k_proj,v_proj,o_proj,gate,up,down
4-bit NF4 base, double quant, bf16 compute
per-device batch 2, grad accum 8, paged_adamw_8bit
max_seq_len 2048, gradient checkpointing on

Lessons, in order of how much they cost me:

  • Sequence length is the VRAM killer, not batch size. Going 2048 → 4096 doubled peak memory even with checkpointing. Truncate or pack; do not brute-force it.
  • Gradient checkpointing costs ~30% speed and saves ~40% memory. On 24GB it is not optional for r=16 on an 8B model.
  • Paged optimizer is free insurance. My one OOM crash happened at step 11k during an unusually long sample; paged AdamW would have absorbed it.
  • Eval on 500 held-out samples every 200 steps. My loss curve looked great while the model quietly learned to prepend the dataset's boilerplate to every answer. Caught it at step 3 of spot-checking, not on the loss plot.

Final eval: 4.1% improvement on my task rubric over the base model, no measurable regression on the general prompts. Happy to share the training log.

RTX 3090 · Unsloth devotee · São Paulo
E
M MateusKeller replied
…Sequence length is the VRAM killer, not batch size…

Strongly agree on the sequence-length point — it is counterintuitive because every tutorial optimises batch size first. One addition: sample packing (concatenating short examples with proper attention masking) got my effective throughput up 2.3× on a dataset where the median example was 380 tokens but the config was paying for 2048.

Also, if you are on Unsloth, their gradient-checkpointing reimplementation gets some of that 30% back — my equivalent run was about 19% faster at identical settings. Not magic, just better kernels, but on a 9-hour run that is real time.

RTX 4070 Ti Super 16GB · Poznań · fine-tuning on weekends
Y
E ElifKowalski replied
…sample packing got my effective throughput up 2.3x…

The boilerplate-learning failure mode deserves its own warning label. I had the same thing: the model learned my dataset's "You are a helpful assistant…" preamble and started emitting it mid-answer. Two fixes that worked better than watching loss:

  • Strip the boilerplate from the training targets entirely — the chat template should supply it, not the data.
  • Keep a 50-prompt general eval set and run it alongside the task eval. Task loss went down while general quality degraded for two epochs before I caught it; the general set flagged it immediately.

On dataset size: 52k pairs for a style/format task is generous. My best result was 18k curated rows — the extra 30k were mostly near-duplicates teaching the model to repeat itself.

Dataset janitor · 2× P40 · Prague
Want to join the discussion? Register or log in to reply. Register Log in
Reply
Ctrl+Enter to submit
post 1 of 3