Best LoRA rank for an 8B fine-tune on a single 4090?
Finally getting around to fine-tuning instead of just hoarding checkpoints. Constraints:
- Base: Llama 3.1 8B Instruct
- GPU: single RTX 4090 (24GB)
- Dataset: ~5,000 curated instruction pairs (Portuguese support-ticket replies)
- Tooling: unsloth or axolotl — open to either
What rank are you all landing on for this kind of domain-adaptation job? I've seen everything from r=8 to r=256 and I'd rather not burn a weekend finding out the hard way.
For domain adaptation on 5k pairs, r=16 with alpha=32 is where I'd start — it captures style and vocabulary shifts without memorising your dataset. Config that works well on a 4090:
rank: 16
alpha: 32
dropout: 0.05
target_modules: q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj
learning_rate: 2e-4
scheduler: cosine
epochs: 2-3
batch: 2 (x8 gradient accumulation)
That fits comfortably in ~14GB with QLoRA (4-bit base), leaving room to push batch size. Going to r=64 on a dataset this size mostly buys you overfitting, not capability. Monitor eval loss, stop when it plateaus — usually epoch 2.
Agreed on r=16 — I trained a Finnish customer-service tune with almost exactly this recipe and it was indistinguishable from a friends r=64 run, at half the disk.
One addition: rank matters more when you're teaching knowledge than style. If you later need the model to actually learn new facts, consider a small full fine-tune of a few layers on top rather than cranking the rank.
Chiming in with the boring truth: dataset quality beats every hyperparameter here. Dedupe aggressively, check your templates for tokenisation surprises, and hand-review 100 random samples before the first run. Most "the LoRA didn't learn" stories I've seen were dataset bugs.