29 Seconds to a Fine-Tune: What an 800-Yuan GPU Can Actually Do

Not "train your own LLM in 3 minutes." Two days of falling into holes, 29 seconds to prove the pipeline was connected, 8 minutes to train an 80MB file.

Every number here matches a screenshot on my disk; every command copies as-is.

TL;DR

  • Hardware: RTX 3070 Laptop 8GB (a modded machine — I had to edit the driver INF and self-sign it)
  • Model: Qwen3-0.6B + LoRA (r=32), 20.19M trainable parameters, 3.33% of the full model
  • Pipeline check: 12 steps / 29 seconds — which learn nothing; it only proves the plumbing is connected
  • Actual learning: 264 samples / 180 steps / 8 min 27 sec, peak VRAM 4.6 GB
  • Artifact: adapter_model.safetensors, 80 MB
  • Result: on 20 new question phrasings, base model 0/20, fine-tuned 18/20 ("correct" means the answer cites the right article number — scoring looks at the citation, not the content. That's the metric; stated up front.)
  • The biggest trap: pip swapped my CUDA build of torch for the CPU build without telling me

If you have a gaming card gathering dust, this should let you skip my two days.

1. Do the arithmetic first: is 8GB even enough?

Don't take "8GB can play with LLMs" on faith. Run the numbers once and you'll have your own judgment.

Full fine-tune of 0.6B (bf16 mixed precision + Adam):

Item Cost
Model weights, bf16 1.2 GB
Gradients, bf16 1.2 GB
Adam first + second moments, fp32 4.8 GB
fp32 master weight copy 2.4 GB
Subtotal (activations not counted yet) ≈ 9.6 GB

An 8GB card can't hold a full fine-tune of 0.6B. Not mysticism — multiplication at 16 bytes/param.

Switch to LoRA: the base is frozen, so of that 9.6GB everything but the 1.2GB of weights goes — the remaining 8.4GB — because only 20.19M parameters need gradients and optimizer state, about 320MB at the same 16 bytes/param.

New ledger: 1.2GB weights + 0.3GB training state + activations + logits. Measured peak: 4.6GB. 8GB is plenty.

A correction to something I had wrong: this is not a breakthrough from this year. LoRA dates from 2021, QLoRA from 2023; the community has fine-tuned small models on 8GB cards for years.

What came down isn't the hardware barrier, it's integration cost. You used to wire transformers + peft + a data collator + a training loop yourself; now LLaMA-Factory does it in one command. The barrier didn't collapse — a road was built through it.

2. Three traps; the second is the most valuable

Trap 1: a 2.66GB wheel at 800KB/s on a single connection

The Windows CUDA torch wheel is 2.66GB (2,862,033,275 bytes); the official source gave me 800KB/s on a single connection, and dying at 900MB was routine.

Multi-threading was slower — the CDN rate-limits per IP: 16 connections split the same bandwidth 16 ways, plus 16 handshakes.

The Shanghai Jiao Tong University mirror saved me: 6MB/s on one connection, done in 8 minutes:

https://mirror.sjtu.edu.cn/pytorch-wheels/ 

Go into the directory for your CUDA version — cu128 / cu124 / cu121 etc. — instead of hunting the index page.

Trap 2: pip swapped the GPU build for the CPU build behind my back ⭐

After installing LLaMA-Factory, my routine health check:

import torch print(torch.__version__, torch.cuda.is_available()) # 2.15.0+cpu False 

+cpu. The 2.66GB I'd spent 8 minutes downloading had become a CPU package.

Half an hour of digging reconstructed the crime:

  1. I installed torch with --no-deps as a shortcut and never installed torchvision / torchaudio
  2. LLaMA-Factory depends on torchaudio; pip found it missing and fetched it from PyPI
  3. PyPI's default torchaudio is the CPU build — version 2.11.1 — and its dependency is declared as torch>=2.11: not an exact pin, a lower bound
  4. My CUDA build was 2.9.1, which fails >=2.11, so pip helpfully pulled torch 2.15.0+cpu from PyPI and added torchvision 0.29.2 to match

Not one line of red. pip thought it had done a great job.

That's the nasty part: it didn't fail, it silently downgraded. Don't check, and you'll train on CPU, then sigh that "8GB cards really are too slow."

Fix 1: the trio — same version, same CUDA suffix, installed together

pip install torch==2.9.1 torchvision==0.24.1 torchaudio==2.9.1 \ --index-url https://download.pytorch.org/whl/cu128 

Or download the three wheels from the SJTU mirror and install them together (what I actually did):

pip install --no-deps --force-reinstall \ torch-2.9.1+cu128-cp312-cp312-win_amd64.whl \ torchvision-0.24.1+cu128-cp312-cp312-win_amd64.whl \ torchaudio-2.9.1+cu128-cp312-cp312-win_amd64.whl 

The three version numbers have a strict correspondence table — look it up on PyTorch's previous-versions page; don't guess.

Fix 2: lock pip with constraints

# constraints.txt torch==2.9.1 torchvision==0.24.1 torchaudio==2.9.1 
pip install -c constraints.txt llamafactory 

Now any dependency that wants to touch torch has to get past the lock.

Most important: save this as check.py and run it after installing anything

import torch print("torch:", torch.__version__) # should be 2.9.1+cu128 print("cuda available:", torch.cuda.is_available()) # should be True print("device:", torch.cuda.get_device_name(0) if torch.cuda.is_available() else "N/A") print("vram(GB):", round(torch.cuda.get_device_properties(0).total_memory / 1024**3, 1) if torch.cuda.is_available() else 0) assert torch.cuda.is_available(), "CUDA is gone! Go check the trio's versions" 

Two seconds, saves you half an hour. I run it before and after every install now.

Trap 3: the "supernatural constitution" of a modded card

This machine's driver was installed by editing the INF and self-signing, which depends on Windows Test Mode. One day nvidia-smi was a screen of errors. I thought the card had died — then I touched the heatsink: cool.

bcdedit /enum | findstr -i testsigning # if it's off: bcdedit /set testsigning on 

Reboot, card back.

Two honest warnings: Test Mode relaxes driver-signature checks, and that has a security cost. Some anti-cheat games and DRM content refuse to run under it. Know that before switching it on; don't push it as an "optimization tip."

Troubleshooting order for modded-card owners: bcdedit first, nvidia-smi second, incense last.

3. The homework you can copy

3.1 Dataset: grown from a single document

No open-source data. I wrote a fictional employee handbook (33 policies: attendance, leave, expenses, performance) and had a script, build_dataset.py, expand "one policy → several phrasings" into 192 policy Q&A pairs, plainest three-column format:

{"instruction": "入职两年,年假几天?", "input": "", "output": "根据《员工手册》「年假」(第6条),入职满1年不满5年5天……"} 

("Two years in — how many days of annual leave?" → "Per the Employee Handbook 「Annual Leave」 (Article 6), employees with 1 to 5 years of service get 5 days...")

Then 72 negative samples — "Does the company provide a car?" "Can I apply for public housing?" — questions the handbook simply doesn't cover, mixed in to force a "not found." Total 264, split 9:1 (237 train / 27 validation).

Separately, 20 "new phrasings never seen in training" as the eval set: 17 in-scope + 3 out-of-scope. Handbook: "male employees get 15 days of paternity leave" (陪产假15天). Eval: "My wife is due next month — how many days can I take?" Eval and training phrasings don't overlap — the first line of defense between "learned" and "memorized."

3.2 One command: smoke test first, then the real run

# Smoke test: 20 steps first, confirm the pipeline ./train.sh max_steps=20 # Real run: 180 steps (6 epochs) ./train-policy.sh 

Core config, in full:

stage: sft finetuning_type: lora lora_rank: 32 lora_alpha: 64 lora_target: all template: qwen3_nothink # add _nothink if you don't want <think> from Qwen3 cutoff_len: 512 per_device_train_batch_size: 2 gradient_accumulation_steps: 4 gradient_checkpointing: true bf16: true learning_rate: 1.0e-4 num_train_epochs: 6.0 

During the smoke test confirm three things: VRAM actually rises in nvidia-smi (peak 4.6GB), the loss moves, files appear in output/. Then remove max_steps.

Smoke run: 20 steps in 46 seconds, ~2.3 s/step. Real run: 180 steps in 8 min 27 sec, 2.8 s/step, train_loss 0.388, eval_loss 0.040. The pipeline check's 12 steps / 29 seconds means exactly one thing — "connected" — not a performance figure.

Bonus Windows-only trap: multi-process preprocessing occasionally throws
OSError: [WinError 1224] 另一个程序正在使用此文件 ("another program is using this file").
Add preprocessing_num_workers=1 and it goes away.

3.3 Why the artifact is exactly 80MB (verify it yourself)

Qwen3-0.6B: hidden 1024, 28 layers, intermediate 3072, head_dim 128 (so q_proj outputs 2048, not 1024). r=32 on all 7 linear layers adds r × (in + out) per layer:

Module Parameters per layer
q_proj 32 × (1024 + 2048) = 98,304
k_proj 32 × (1024 + 1024) = 65,536
v_proj 32 × (1024 + 1024) = 65,536
o_proj 32 × (2048 + 1024) = 98,304
gate_proj 32 × (1024 + 3072) = 131,072
up_proj 32 × (1024 + 3072) = 131,072
down_proj 32 × (3072 + 1024) = 131,072
Per-layer total 720,896 × 28 layers ≈ 20.19M

20.19M ÷ 606M ≈ 3.33%. safetensors defaults to fp32: 20.19M × 4 bytes ≈ 80.74MB; with header metadata the real file is 80,792,456 bytes ≈ 80.8MB.

Checks out. bf16 would halve it again, to 40MB.

That's the romance of LoRA: it doesn't remake you, it clips on a detachable accessory. Attach it and the model carries what you taught it; detach it and the base is untouched.

3.4 Where an 8GB card actually runs out (the part fewest people explain)

When a small-model fine-tune blows up VRAM, odds are it isn't the weights — it's the logits.

Qwen3's vocabulary is 151,936. At batch=1, seq=512, the last layer's logits alone:

151936 × 512 × 4 byte ≈ 311 MB 

Cross-entropy usually upcasts to fp32, computes a softmax, and keeps intermediates for backward — around 1GB is normal. Push seq to 2048 and this one item starts at 1.2GB — bigger than your whole model's weights.

Priority order on 8GB:

  1. Cut cutoff_len (if 512 works, don't open 2048 — the most direct win)
  2. per_device_train_batch_size: 1 + gradient accumulation for the equivalent batch
  3. gradient_checkpointing: true (saves activations, costs about 20% speed)
  4. Only then QLoRA at 4bit — but at 0.6B there's no need; the few hundred MB quantization saves is less than cutting seq saves

Don't jump to QLoRA first. Work out which item you're blowing up on, then turn that knob.

4. The moment it ran

20 questions outside the training set: base 0/20, fine-tuned 18/20.

The convincing part isn't the 18 — it's the two answers to one question:

Q: How many days off when my grandfather passes away? (爷爷去世有几天假?)

Before (base model), translated:

<think> Alright, the user asks "how many days off when grandfather passes away?" First, is the question correct? Generally there may be several days of bereavement leave, but the number varies by region and custom. In China, for example, maybe three to five days...

After (with the 80MB attachment):

根据《员工手册》「丧假」(第11条),直系亲属(父母、配偶、子女)丧假为3天;祖父母、外祖父母、兄弟姐妹丧假为1天,均须在事发后1个月内休完。

(Per the Employee Handbook 「Bereavement Leave」 (Article 11): 3 days for immediate family — parents, spouse, children; 1 day for grandparents, maternal grandparents, siblings; all within 1 month of the event.)

The base model doesn't know this handbook exists, so it guesses at the world. The fine-tune not only answers right, it points to Article 11.

But 18/20 took three more traps:

Iteration Data Hits What I fixed
v1 137 samples 1/20 One Q&A per policy; it could only parrot training sentences
v2 7~8 paraphrases per policy 11/20 Froze when the phrasing changed → teach recognize, not memorize
v3 「Title」 first, (Article N) after 16/20 Article numbers mismatched everywhere → right format, stable citations
v4 Negatives expanded to 24 categories (264 total) 18/20 Invented answers out-of-scope → learned to say "the handbook doesn't say"

The two remaining misses are the two classic "didn't learn" flavors:

  1. Semantic boundary: "Is arriving at 9:40 late?" → cites 「Late Arrival / Early Departure」(迟到早退) Article 3, but Article 2 sets flexible clock-in 9:00~10:00, so 9:40 isn't late. Memorized clause, no boundary.
  2. Over-refusal: "Can I install games on my work laptop?" → Article 26 covers device management, yet it said "not found." Too many negatives; overcorrected.

An eval score isn't proof of learning — but the wrong answers show where you're short, and that beats a perfect score.

And honestly: the first smoke test was 12 steps at loss 1.76. It learned nothing; that number only means forward and backward didn't crash. What produced the sentence above was 264 samples, 180 steps, 8 min 27 sec, peak 4.6GB VRAM.

I'm leaving that in, because the most deceptive line in tutorials is "it ran, so it succeeded." Between running and learning there's a whole weekend of data cleaning.

5. The whole fine-tuning family, in plain words

  • Pretraining = elementary school: you know the letters and can talk, but can't do a job
  • SFT = on-the-job training: practice the script against the answer key
  • LoRA = training that doesn't touch the body, just clips on a detachable skill pack — 80MB, hot-swappable
  • Quantization = same body weight in a coarser format, 1.2GB compressed to 400MB. Not dieting — compression
  • QLoRA = coarse-stored body + fine-tuned skill pack; a lifeline for small VRAM (unnecessary at 0.6B)
  • RM / PPO = hire a teacher to grade, then let the model train itself against the grades
  • DPO = skip the teacher; feed "good answer" and "bad answer" in pairs and let it work it out. Cheaper on VRAM and effort; the hobbyist's pick

The summary is borrowed, and borrowed gladly:

Pretraining learns to talk, SFT learns to obey, preference alignment learns to be liked.

6. For you, with equally modest hardware

  1. 0.6B–3B fits in 8GB — but do the arithmetic first. Full fine-tune of 0.6B needs 9.6GB; LoRA needs about 0.3GB of training state as a floor; my measured peak was 4.6GB. Do this multiplication once and you'll stop asking "is my card good enough"
  2. The barrier isn't the GPU, it's the data. 264 Q&A pairs grown from policy text beat 20,000 dirty rows scraped from chat logs — and all four iterations from 1/20 to 18/20 changed the data, not the model. The most expensive lesson of my two days
  3. The biggest trap is always the environment, and it never raises an error. Mirrors, silent CPU/GPU downgrade, driver signing — save check.py, run it after every install
  4. Don't put "alchemy" on a pedestal. What it does is plain: show it examples, have it imitate, repeat a few hundred times. The mysticism is in the vocabulary, not the work

At 2 a.m. last night, when the loss curve slid down smoothly for the first time, I think I understood what the people who spend whole nights inside fan noise are after.

Not a stronger model. How strong can 0.6B get?

It's that moment when a model that could only "continue the sentence" says something my way for the first time.

This is part 1 of "Fine-Tuning on an 800-Yuan GPU". The scripts, configs, logs, and every raw error message from these two days live in the 8gb-lora-lab/ directory of the series' GitHub repository.

Next, in part 2: I train the model on purpose until it breaks — train loss 0.00016, eval score up. (I'd planned "teach a model to recognize your cat with 20 images" first, but discovered Qwen3-0.6B is text-only and can't see images at all. That post needs Qwen2.5-VL, a different set of traps. I owe you that one.)