Setup & toolkit
One environment for the whole course. These versions were checked in August 2026, and they matter more than usual right now, because two of the libraries had breaking releases that make most tutorials on the internet wrong.
tools · 1The pinned set
Pin these. When a lesson shows code, it was written against exactly this set.
| Package | Version | Used from | Note |
|---|---|---|---|
torch | 2.13.0 | Lesson 01 | Everything. Includes the Apple mps backend. |
torchvision | 0.28.0 | Lesson 01 | MNIST and CIFAR loaders. |
torchaudio | 2.11.0 | Lesson 11 | Audio loading, spectrograms. |
transformers | 5.15.0 | Lesson 03 | v5 is a breaking release. See below. |
datasets | 5.0.1 | Lesson 04 | Loading scripts were removed in v4. See below. |
peft | 0.20.0 | Lesson 05 | LoRA and QLoRA. |
trl | 1.10.0 | Lesson 05 | Supervised fine-tuning and DPO trainers. |
accelerate | 1.14.0 | Lesson 04 | Device placement, mixed precision. |
torchao | 0.18.0 | Lesson 07 | The PyTorch-native quantization path. |
onnxruntime | 1.28.0 | Lesson 09 | Needs Python 3.11 or newer. |
executorch | 1.4.1 | Lesson 09 | PyTorch's own on-device runtime. |
coremltools | 9.0 | Lesson 09 | Apple export. Validated against torch 2.7 — expect friction. |
mlx / mlx-lm | 0.32.0 / 0.31.3 | optional | Apple-Silicon-native training and inference. |
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install torch==2.13.0 torchvision==0.28.0 torchaudio==2.11.0
pip install transformers==5.15.0 datasets==5.0.1 accelerate==1.14.0
pip install peft==0.20.0 trl==1.10.0 torchao==0.18.0
pip install jupyterlab matplotlib
python -c "import torch; print(torch.__version__, torch.backends.mps.is_available())"
Install the export tools later, in Lesson 09. They pull in a lot and some of them conflict with each other, so it is better to keep a second virtual environment for exporting than to fight the resolver now.
tools · 2Two breaking changes that will confuse you
Most code you find online is v4 code and will not run. What changed:
- The dtype argument is
dtype=, nottorch_dtype=. load_in_4bit=andload_in_8bit=are gone. Passquantization_config=BitsAndBytesConfig(...)instead.- TensorFlow and Flax support was removed. It is PyTorch only.
- Everything saves as safetensors;
safe_serialization=Falseno longer exists. - One tokenizer class per model. Call the tokenizer directly rather than
encode_plus. - The command line tool is
transformers, nottransformers-cli.
Dataset loading scripts were removed, and trust_remote_code=True
no longer exists. Any dataset whose data sits behind a .py loader now raises
RuntimeError: Dataset scripts are no longer supported. This silently breaks a
lot of older audio tutorials. Each lesson names a dataset that was confirmed to load; use
the one it names.
tools · 3If you are on a Mac
Apple Silicon is a good machine for this course, with three things to know.
- Memory is shared. There is no separate video memory, so the model, the data and everything else compete for the same RAM. A 16 GB machine can LoRA-fine-tune models of roughly one to two billion parameters in bf16. An 8 GB machine is fine for everything up to Lesson 06.
- No
bitsandbytes, no CUDA kernels, no Triton. The 4-bit NF4 path used by most QLoRA tutorials is CUDA-only. Lesson 05 gives you the alternative. - Some operations still fall back to the CPU. If you hit one, set
PYTORCH_ENABLE_MPS_FALLBACK=1. It will be slower but it will run.
export PYTORCH_ENABLE_MPS_FALLBACK=1
tools · 4If you use a free Colab GPU
The free tier gives you an NVIDIA T4 with 16 GB. Two consequences:
- A T4 cannot do bf16. It is a Turing card: fp16 tensor cores yes,
bfloat16 no. Use
torch.amp.autocast('cuda', dtype=torch.float16)together with aGradScaler. On Apple Silicon and newer NVIDIA cards, use bf16 and skip the scaler. - Sessions are killed when idle, and there is a weekly cap. Save checkpoints to Google Drive rather than to the session disk, and assume the machine will disappear.
No project needs more than about two hours of training. If a lesson describes something longer, it also gives you a checkpoint so you can carry on without waiting.
tools · 5A habit worth building now
Before you debug maths, print shapes. Most failures in this course are a tensor of the wrong shape or data on the wrong device, and both are visible in one line.
def peek(name, t):
print(f"{name:12} {tuple(t.shape)} {t.dtype} {t.device} "
f"min={t.min().item():.3f} max={t.max().item():.3f}")
peek("images", images)
peek("logits", logits)
And the single most useful test in machine learning: take ten examples and try to overfit them on purpose. A correct training loop drives the loss on ten samples to nearly zero within a minute. If it cannot, stop tuning hyper-parameters — the bug is in your code.
That is everything you need installed. Go to Lesson 01 and build the first model.