MODULE 3B · OPTIONAL · DAY 1
Customizing Models with LoRA / QLoRA
Make the model yours — reproducibly, in a container
Gourav Shah · School of DevOps & AI · GPU-gated · Hands-on
M3B·01
What you'll learn
Four ideas — when to fine-tune, what LoRA does, which tool, and why the container matters.
The output is a small LoRA adapter that plugs straight into serving (M2/M3) and packaging (M4).
M3B·02
The problem: a behaviour gap
Sometimes no prompt reliably makes the model behave the way you need. That's not a knowledge gap.
Fine-tuning teaches new behaviour — style, dialect, reliable output structure — not new facts.
M3B·03
Prompt vs RAG vs fine-tune
Three tools, three different gaps. Reach for the cheapest one that closes your gap.
Knowledge problem → RAG. Reasoning problem → better prompt or bigger base. Behaviour problem → fine-tune.
M3B·04
LoRA — sticky notes on a textbook
You can't rewrite the expensive textbook. So you add Post-it notes in the margins instead.
Freeze the base, train two tiny matrices, add them at inference. The adapter is ~1–3% of the model.
M3B·05
QLoRA — squeeze the base to 4-bit
LoRA's frozen base still hogs memory. Quantize it to 4-bit and a 7B fits one consumer GPU.
QLoRA = LoRA + a 4-bit frozen base — half the memory again, with the adapter kept high-precision.
M3B·06
The open-source toolchain
A handful of mature stacks cover almost every fine-tuning job — pick by your hardware.
Axolotl's YAML config is the interface; the pinned Docker image is what makes the run reproducible.
M3B·07
The same GPU reality — again
On Apple Silicon you fine-tune natively. On NVIDIA you fine-tune in a container. Never the reverse.
A 7B QLoRA fits ~24 GB. On Mac, MLX is the accelerated path — CUDA tools simply don't run in a Mac container.
M3B·08
The frozen container is the experiment
Scripts rot — Python, PEFT, and bitsandbytes all drift. An OCI image does not.
YAML in git + image tag in your registry = an immutable, repeatable experiment record.
M3B·09
What you produce: a tiny adapter
The run emits a 50–200 MB adapter directory — two small files, ready to serve.
One adapter, three exits — merge for portability, hot-load for flexibility, package to ship.
M3B·10
The pipeline, end to end
Fine-tuning is one rung — it feeds serving and packaging you already know.
Nothing new downstream — a fine-tune just adds a custom-behaviour adapter to the pipeline you own.
M3B·11
TO THE LAB
Two tracks, one destination: a working adapter
Fine-tune the behaviour · keep the base · ship the tiny adapter.
Optional module — do it if your cohort needs model customization. · Gourav Shah · School of DevOps & AI
M3B·12