---
title: "About: Fine-Tune a Self-Improving Local Coding Agent"
description: "How the course works, the hardware and toolchain, and the reading list."
---

# About This Course

## How It Works

This course is a ladder. Each part produces an artifact the next part consumes:

1. **Part 1** builds intuition — an image LoRA where overfitting is *visible*
2. **Part 2** builds the pipeline — train, fuse, serve, on a model small enough to iterate in minutes
3. **Part 3** builds the data format — an agent harness that logs every trajectory
4. **Part 4** builds the scoreboard — a mechanical pass/fail verifier on real tasks
5. **Part 5** closes the loop — the agent trains on its own verified successes

Nothing is decorative. If a part feels skippable, the part after it will tell you why it wasn't.

---

## Hardware

| Box | Role | Toolchain |
|---|---|---|
| M4 MacBook, 64GB | Iteration, dataset work, Parts 1–4 | MLX (`mlx_lm.lora`, `mflux`) |
| Jetson AGX Thor, 128GB | Scale runs, Nemotron, final serving | Unsloth / CUDA, Ollama |

You can complete Parts 1–4 entirely on Apple Silicon. A 64GB machine is comfortable; 32GB works with `--low-ram` flags and smaller batch sizes. The Thor (or any CUDA box) only enters at Part 5's scale-up.

---

## The Toolchain

| Tool | What It Is | Used In |
|---|---|---|
| [mflux](https://github.com/filipstrand/mflux) | MLX port of FLUX image generation, with Dreambooth training | Part 1 |
| [mlx-lm](https://github.com/ml-explore/mlx-lm) | Apple's LLM training and serving toolkit for MLX | Parts 2–5 |
| Gemma 3 | The model ladder: 270M → 1B → 4B → 12B → 27B | Parts 2–5 |
| Claude (Anthropic API) | The teacher for trajectory distillation | Part 3 |
| [Unsloth](https://unsloth.ai/) | CUDA fine-tuning for the Thor scale-up | Part 5 |
| [Ollama](https://ollama.com/) | Final serving via GGUF | Part 5 |

Everything is driven from a `Makefile`/`justfile` you build in Part 2 and never stop using.

---

## Why Gemma 3 and Not Nemotron (on the Mac)

Nemotron's hybrid Mamba2-Transformer architecture is still maturing in `mlx-lm` — it runs for inference but fights you for training. Save it for the Thor, where Unsloth on CUDA handles it (with caveats covered in [Chapter 16](/fine-tune-local-agent/05-the-flywheel/16-scale-up-and-ship/)).

Gemma 3's size ladder is exactly the ramp this course wants: prove everything on 1B where iteration is minutes, then move the same pipeline up.

---

## The Core Insight

You are not fine-tuning the model on your code. **You are fine-tuning it on the shape of agentic behavior.**

Codebase knowledge belongs in context, retrieved at runtime — bake it into weights and you retrain every time the code changes, and it hallucinates moved APIs anyway. What small models are actually bad at, and what *is* stably trainable, is the loop: take a task, emit a well-formed tool call, read the result, reason, call again, stop when done, report.

That behavior is learnable. That behavior is what you train.

---

## Safety Notes

- The agent in Parts 4–5 gets `edit_file` and `run_tests` — write and execute tools. Sandbox them. Container, git worktree, whatever — the agent *will* do something stupid and you want to `git checkout .` and move on.
- Fine-tuning runs are long. Don't interleave generation with training in mflux (documented slowdowns); train, then generate.
- Guard your eval set with your life. If eval tasks leak into training data, every number your scoreboard prints becomes fiction.

---

## Reading, Roughly in Order

- **LoRA** (Hu et al., 2022) — the original, still the clearest
- **STaR / expert iteration** — the Part 5 method
- **DPO** (Rafailov et al., 2023) — Chapter 14
- **Reflexion** — Chapter 15
- **Nemotron Nano 2 tech report** — a full post-training recipe (SFT → GRPO → DPO → RLHF), openly documented, worth reading as a map of where this ladder goes
- **The `mflux` source** — a diffusion transformer with the abstractions removed. Short enough to read in an evening.

---

[← Back to Course](/fine-tune-local-agent/)

[hey@thefocus.ai](mailto:hey@thefocus.ai) · [thefocus.ai](https://thefocus.ai)
