reference · read before Project 01

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.

PackageVersionUsed fromNote
torch2.13.0Lesson 01Everything. Includes the Apple mps backend.
torchvision0.28.0Lesson 01MNIST and CIFAR loaders.
torchaudio2.11.0Lesson 11Audio loading, spectrograms.
transformers5.15.0Lesson 03v5 is a breaking release. See below.
datasets5.0.1Lesson 04Loading scripts were removed in v4. See below.
peft0.20.0Lesson 05LoRA and QLoRA.
trl1.10.0Lesson 05Supervised fine-tuning and DPO trainers.
accelerate1.14.0Lesson 04Device placement, mixed precision.
torchao0.18.0Lesson 07The PyTorch-native quantization path.
onnxruntime1.28.0Lesson 09Needs Python 3.11 or newer.
executorch1.4.1Lesson 09PyTorch's own on-device runtime.
coremltools9.0Lesson 09Apple export. Validated against torch 2.7 — expect friction.
mlx / mlx-lm0.32.0 / 0.31.3optionalApple-Silicon-native training and inference.
setup.shbash
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

transformers v5

Most code you find online is v4 code and will not run. What changed:

  • The dtype argument is dtype=, not torch_dtype=.
  • load_in_4bit= and load_in_8bit= are gone. Pass quantization_config=BitsAndBytesConfig(...) instead.
  • TensorFlow and Flax support was removed. It is PyTorch only.
  • Everything saves as safetensors; safe_serialization=False no longer exists.
  • One tokenizer class per model. Call the tokenizer directly rather than encode_plus.
  • The command line tool is transformers, not transformers-cli.
datasets v4 and later

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.
~/.zshrcbash
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 a GradScaler. 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.
The rule this course follows

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.

debug.pypython
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.

Ready

That is everything you need installed. Go to Lesson 01 and build the first model.