Environment setup
Use Python 3.11 or newer and uv. Create one project for the twelve weeks. Add packages in phases so later adds keep the CPU torch wheels. Use --index, not --index-url. That flag is not saved, and a later uv add can swap torch to a CUDA wheel. --index writes the CPU index into pyproject.toml.
This week stays in NumPy. Torch lands in week 2. Pydantic lands in week 4. vLLM, Triton, and CUDA wheels are for later GPU weeks (9 and 10). They may need a CUDA host. Do not install them here. Do not pretend they install on CPU-only machines.
curl -LsSf https://astral.sh/uv/install.sh | sh
mkdir -p ai-full-stack-operator && cd ai-full-stack-operator
uv init --python 3.11
uv venv
uv add numpy
uv add torch --index pytorch-cpu=https://download.pytorch.org/whl/cpu
uv add pydantic
uv run python -c "import numpy, torch, pydantic; print(numpy.__version__, torch.__version__, pydantic.__version__); print('cuda:', torch.cuda.is_available())"Always run with uv run. The same sticky CPU index is used in the LiteRT course so a later add does not swap torch to CUDA.
Core principle, keep it for the whole twelve weeks: you do not need to pretrain an 800B model to understand the shape of the problem. You do need to build progressively realistic replicas of the whole stack. Week 1 is the replica of the math the rest of the stack pretends you already know.
This is not a sightseeing tour of Wikipedia linear algebra. Every object you write down should show up again in attention, in backprop, or in a training log. If you cannot prove a one-line identity, you will hand-wave a transformer later.
Weekly rhythm
Use this rhythm every week. Monday: read and prove the claim. Tuesday and Wednesday: code the replica. Thursday: finish the assignment. Friday: write the opinion checkpoint in your own words. Weekend stretch is optional. Ship the artifact, do not collect tabs.
Topics
- Vector spaces, bases, and linear maps. A layer is a map. A residual is a sum of maps.
- Inner products, norms, and orthogonality. Cosine similarity is an inner product after you normalise.
- Projections. Residual connections and least squares are the same geometric move.
- Eigenvalues and SVD. Low-rank adapters and compressed KV ideas start here.
- Gradients, Jacobians, Hessians. Backprop is a Jacobian-vector product, not magic.
Write the identities you will reuse. The squared Euclidean norm of x is xTx. A projection onto the column space of A with full column rank is A(ATA)-1AT. Softmax is invariant to adding a constant to logits, which is why you can subtract the row max before the exp.
Coding
Stay in NumPy first. Do not hide behind autograd until you can compute a gradient by hand for a two-layer map.
import numpy as np
def project(A, y):
"""Least-squares projection of y onto col(A)."""
gram = A.T @ A
return A @ np.linalg.solve(gram, A.T @ y)
def svd_lowrank(X, rank):
U, s, Vt = np.linalg.svd(X, full_matrices=False)
return (U[:, :rank] * s[:rank]) @ Vt[:rank]
def softmax(logits):
z = logits - logits.max(axis=-1, keepdims=True)
exp = np.exp(z)
return exp / exp.sum(axis=-1, keepdims=True)
Then write a tiny autograd for y = Wx and L = ||y - t||^2. The gradient wrt W is an outer product. If that sentence is fuzzy, stop and derive it on paper.
Assignment
- Prove that the residual
y - P yis orthogonal to the column space ofAwhenPis the projection above. - Measure the condition number of
ATAon a skinny random matrix and on a near-collinear one. Write one paragraph on what that does to a learning rate. - Implement SVD truncation and plot reconstruction error versus rank. No invented accuracy claims. Report the numbers you measured.
Opinion checkpoint
Core project 1 starts here: a linear algebra and tiny autograd lab.
Next week you will put a non-convex optimiser on top of these maps.
Next: Non-convex optimisation.
Key concepts
- A network layer is a linear map plus a cheap nonlinearity.
- Inner products and norms turn geometry into the numbers you log.
- SVD is the honest way to talk about rank and compression.
- Backprop is Jacobian-vector products, not a framework feature.
- You do not need an 800B pretrain to learn the shape of the stack.
Takeaways
- Prove one projection identity and implement it. That is the week.
- Condition numbers explain more training instability than lore does.
- Keep a written opinion: replicas beat tourism.