Fine-tuning a 32B model on a 6 GB laptop GPU by streaming weights from disk
- Hardware
- RTX 3050 Laptop GPU with 6 GB VRAM, 34 GB RAM and an NVMe SSD, on Windows
- Models & engines
- A 32B model quantized to NF4, with LoRA adapters
The stream-finetune engine (tools/finetune.py, GUIDE_6GB_32B.md)
Dolly-15k for the SFT runs; Qwen2.5-3B NF4 for the gradient checks - Key gotcha
- An evaluation script loaded the checkpoint before patching in the router modules, so days of results measured a randomly initialized router.
What they built
With a single RTX 3050 Laptop GPU (6 GB of VRAM), 34 GB of RAM and an NVMe SSD on Windows, the author built a small engine that trains models that don't fit on the card. The post is the honest result for a 32B model, including the places where earlier published numbers were wrong.
The 32B weights are 19.2 GB and never fully live in VRAM. They are memory-mapped from disk and streamed block by block, with one transformer block resident at a time and recompute in the backward pass, so the I/O is paid once per step rather than per token.
The engine, a one-command wrapper and a guide for the 6 GB, 32B case are in the stream-finetune repo on GitHub.
Setup
- RTX 3050 Laptop GPU with 6 GB VRAM, 34 GB RAM and an NVMe SSD, on Windows
- A 32B model quantized to NF4, with LoRA adapters
- The stream-finetune engine (tools/finetune.py, GUIDE_6GB_32B.md)
- Dolly-15k for the SFT runs; Qwen2.5-3B NF4 for the gradient checks
How it works
- Weights are mmap'd from the SSD and one transformer block is kept resident on the GPU at a time, recomputed during the backward pass.
- Because I/O is paid once per step, longer sequences amortize it: going from 128 to 1024 tokens per step raised throughput 3.1 times.
- The resident block window can be bounded with flags such as --blocks-on-gpu 1..2 and --vram-hard-gb 5.3 so it doesn't spill into Windows shared memory.
Results & numbers
- At 1024 tokens per step the 32B model trains at 27.91 s per step, 36.7 tokens per second and 4.61 GB peak VRAM (warm medians on AC power).
- A corrected 30-step SFT run on Dolly-15k took the 32B held-out eval loss from 1.8755 to 1.0008 at 3.90 GB peak and 12.5 s per step, with all 64 layers receiving a gradient.
- Against PEFT at 14B, the streaming engine took 6.73 s per step at 3.86 GB versus 18.56 s at 16.48 GB; at 32B, PEFT ran out of CUDA memory before the first step. At 3B, where everything fits, PEFT was faster.
- A gradient check on Qwen2.5-3B found the streaming path's adapter gradients bit-identical to the all-blocks-resident path.
Gotchas
- An evaluation script loaded the checkpoint before patching in the router modules, so days of results measured a randomly initialized router.
- A reported 8.6 times speedup was really dividing a truncation cap by step time: Dolly rows have a median of 134 tokens, so the real gain was 3.1 times.
- A sparse-attention baseline wasn't budget-matched, which made it look 5 PPL better than it was.
- The autotune grew to 11 resident blocks at seq 2048, spilled into shared memory, and one step didn't finish in an hour; 2k context still doesn't fit, about 0.6 GB over the card.
- A masked-loss bug over-weighted prompt-heavy chunks in the gradient; every SFT number was re-run after the fix.
“check that your evaluation actually loaded the thing you think it loaded, and that your baseline has the same budget.”— mycute
Do it yourself
- Clone byjameson/stream-finetune on GitHub and read GUIDE_6GB_32B.md and LONGCTX_FINDINGS.md.
- Use a 4-bit (NF4) base model on a fast NVMe SSD so weights can be memory-mapped and streamed.
- Start at 1024 tokens per step and keep the resident window small with --blocks-on-gpu 1..2 and a hard VRAM cap.
- Compare warm runs only; the first step after boot is dominated by reading the weights from disk.
- Before trusting a number, check that the evaluation loaded the checkpoint you think it did and that baselines have the same budget.
Similar setups
PatchPal TinyAgent: a coding agent on a 4B model and a 6GB laptop GPU
WiseProbe adapted its PatchPal coding agent to run Gemma 4 E4B or Qwen3.5 4B through Ollama on a 6GB RTX A1000, using handoff-note compaction and capped file reads to work inside a 16K or 32K window.
A local Qwen model took over a server-patching job when the cloud model refused
Seppe Gadeyne was patching seven servers and about 30 WordPress sites with an AI agent when the cloud model's safety filter stopped answering; he switched the same session to a Qwen model on his RTX 5090 workstation, which finished the job.
Cutting a local Qwen coding agent's wait on a 16GB Mac with a memory hook
A developer running a coding agent on qwen3.5:9b through Ollama replaced its always-loaded memory index with a hook that attaches only relevant memory lines, and cut median answer time from 90.4s to 56.4s.
Running NVIDIA's looped Dory 4B on a CPU homelab with llama.cpp and an Ollama wrapper
Big Iron built NVIDIA's llama.cpp fork on a no-GPU Debian VM, measured Dory 1.0 4B at each loop count against Qwen3.5-4B, and got it running inside Ollama 0.40 through a wrapper around Ollama's internal llama-server.