Large Language Model from Scratch

Go from tensors and gradients all the way to a working LLaMA-style decoder. This teaching lab covers PyTorch fundamentals, every transformer component (tokenisation, attention, normalisation, FFN), efficiency techniques (FlashAttention, MoE, LoRA), training pipelines, and inference optimisation — all designed to run on AMD GPUs.

Large Language Model architecture overview

Goals

  • Master PyTorch fundamentals: forward pass, backpropagation, and training loops
  • Understand every component inside a Transformer block (RoPE, RMSNorm, MHA, SwiGLU)
  • Apply efficiency techniques: FlashAttention, MoE, LoRA, and quantization
  • Build complete training and inference pipelines with KV-Cache optimisation
  • Assemble a Tiny LLaMA from scratch as a capstone project

Foundations (LLM01 to LLM03)

What this section covers

Introduction to LLM inference, forward propagation, and backpropagation with autograd.

Transformer Components (LLM04 to LLM06)

What this section covers

Tokenisation, positional encoding, normalisation, FFN, and attention mechanisms.

Efficiency and Adaptation (LLM07 to LLM09)

What this section covers

FlashAttention, Mixture of Experts, numerical precision, and LoRA fine-tuning.

Training and Data (LLM10 to LLM11)

What this section covers

Data pipelines, model packaging, and end-to-end training workflows.

Inference and Serving (LLM12 to LLM13)

What this section covers

Decoding strategies, KV-Cache, sparse attention, and PagedAttention.

Capstone (LLM14)

What this section covers

Assemble a complete LLaMA-style transformer from scratch.

Explore the other teaching labs: Computer Vision, Deep Learning, Physics Simulation.