Course Staff

Suhas Kotha headshot
Suhas Kotha
Instructor
Course CA placeholder
TBA
Course CA

Logistics

  • Lectures: Tues/Thurs, 1:30-2:50pm in CoDa B90
  • Recordings: TBA (All class materials will be made public)
  • Contact: TBA

Content

What is this course about?

Deep learning is now the foundation of all of machine learning and AI, making it more important than ever for students to obtain mastery of the empirical phenomena and experimental skills involved in deep neural networks. How can students acquire the skills necessary to invent the next generation of architectures or develop new broad theories of how deep learning works? This course takes the stance that knowledge or math abilities alone are not enough, and there is no substitute to getting your hands dirty and running many, many experiments. To this end, we will work through computationally tractable domains and take students through the process of obtaining mastery in this domain through efficient experimentation and experiment outcome prediction. The class will alternate between assignments (where students run experiments to understand deep learning phenomena), quizzes (where students are tested for their ability to predict held-out experiment outcomes), lectures, and tutorials.

Prerequisites

Note: This is a 5-unit class. It will require running a lot of experiments and taking seven difficult quizzes, and we don't intend to apply inflated grading curves. Please make a well-informed decision if you have the appropriate background and time to take this class.


Coursework

Structure

The goal of this class is to develop human intuition for the variety of strange deep learning phenomena that exist in the real world. Our two core beliefs are:

  • Alchemy is learned by hand: Deep learning has many mysteries and surprises that are not well understood by the best researchers, let alone deep learning classes. As such, many classes teach mental models that are not supported by an empiricist's experience (e.g. classic bias-variance tradeoff disagrees with the current scaling era). This class will teach students how to design clean experiments that enable them to build intuition for themselves.
  • Prediction is understanding: To build a scientific understanding is to be able to predict the outcome of an experiment before running it. Therefore, this class assesses human understanding via quizzes where students have to predict experiment outcomes.

In this class, students will alternate between running experiments to understand a given unit (e.g. architecture stability) and taking quizzes testing their understanding. Course staff will support student learning with lectures on each unit and tutorials for interactive discussion.

Example schedule
  • At the introductory meeting and after each quiz: The assignment for the next unit is released
    • The assignment scopes out empirical phenomena that students will best understand through designing clean experiments.
    • Students will eventually submit a report with plots/tables explaining the experiments they ran.
  • One or two class meetings: Lectures explain common intuitions for the unit
  • Once a week: 30 minute tutorial
    • Every week, each student is required to meet with three other students and one course staff for 30 minutes.
    • During this session, the instructor will ask questions about what experiments each student is running as well as cover practice problems that will help for the quiz. This time can also serve as group office hours.
    • Students will receive a full grade given active participation.
  • The day before the quiz: Student reports are due
    • Note that the assignment is not graded and is only useful for partial credit on the quiz.
    • The reports may inspire questions that appear on the quiz.
  • At the end of the unit: A 40-minute experiment prediction quiz is administered
    • Each quiz question will correspond to a thematic held-out experiment run by the instructors. The student will be given a description of the experiment (including code diff) and asked to predict the outcome of the experiment.
    • Quiz questions will span easy, medium, and hard difficulty depending on how much extrapolation they require from the assignment suggestions.
    • During this quiz, students will not be allowed to refer to any external resources including their report. Students can cite their report in the quiz and can receive partial credit if their reasoning appears sound.
    • Immediately after the quiz, the instructors will cover the answers and discuss mental models with the class.
Example problem and questions
Example Assignment Problem: Start from the baseline depth 8 transformer that we pre-train on 614M tokens. This transformer (implementation provided below) features multiple components such as prenorm, attention, MLP, residuals, and positional embeddings. In this problem, we want to understand how much each component improves loss. Explore the following directions.
  1. Perform leave-one-out ablations on the role of each component in our current model.
  2. ...
  3. ...
  4. Understand the role of the residual connection. Can you come up with different schemes that improve the loss benefit of the residual connection?
Relevant code snippet
class Block(nn.Module):
    def __init__(self, width, ...):
        super().__init__()
        self.attn_norm = RMSNorm(width)
        self.attn = Attention(width, ...)
        self.mlp_norm = RMSNorm(width)
        self.mlp = MLP(width, ...)

    def update(self, x):
        attn = self.attn(self.attn_norm(x))
        mlp = self.mlp(self.mlp_norm(x + attn))
        return attn + mlp

    def forward(self, x):
        return x + self.update(x)


class Transformer(nn.Module):
    def __init__(self, vocab_size, depth=8, ...):
        super().__init__()
        self.token_embed = nn.Embedding(vocab_size, ...)
        self.position_embed = nn.Embedding(...)
        self.blocks = nn.ModuleList(
            [Block(...) for _ in range(depth)]
        )
        self.final_norm = RMSNorm(...)
        self.lm_head = nn.Linear(..., vocab_size)

    def forward(self, tokens):
        positions = torch.arange(
            tokens.size(1), device=tokens.device
        )
        x = self.token_embed(tokens)
        x = x + self.position_embed(positions)
        for block in self.blocks:
            x = block(x)
        return self.lm_head(self.final_norm(x))
Example Quiz Question (Difficulty Easy): We train each of the following depth-8 transformer variants using the same training recipe and hyperparameters. Rank the variants from lowest to highest final validation loss. Use <, >, or = between the letters; use = when the losses are within 0.01.
  1. Baseline
  2. No prenorm
  3. No residual
  4. No MLP
  5. No attention
  6. No positional embeddings
No prenorm diff
@@ -10,4 +10,4 @@ class Block.update
 def update(self, x):
-    attn = self.attn(self.attn_norm(x))
+    attn = self.attn(x)
-    mlp = self.mlp(self.mlp_norm(x + attn))
+    mlp = self.mlp(x + attn)
     return attn + mlp
No residual diff
@@ -16,2 +16,2 @@ class Block.forward
 def forward(self, x):
-    return x + self.update(x)
+    return self.update(x)
No MLP diff
@@ -10,4 +10,3 @@ class Block.update
 def update(self, x):
     attn = self.attn(self.attn_norm(x))
-    mlp = self.mlp(self.mlp_norm(x + attn))
-    return attn + mlp
+    return attn
No attention diff
@@ -10,4 +10,3 @@ class Block.update
 def update(self, x):
-    attn = self.attn(self.attn_norm(x))
-    mlp = self.mlp(self.mlp_norm(x + attn))
-    return attn + mlp
+    mlp = self.mlp(self.mlp_norm(x))
+    return mlp
No positional embeddings diff
@@ -22,2 +22,1 @@ Transformer.__init__
         self.token_embed = nn.Embedding(vocab_size, ...)
-        self.position_embed = nn.Embedding(...)
@@ -30,8 +29,4 @@ Transformer.forward
     def forward(self, tokens):
-        positions = torch.arange(
-            tokens.size(1), device=tokens.device
-        )
         x = self.token_embed(tokens)
-        x = x + self.position_embed(positions)
         for block in self.blocks:
             x = block(x)

Example Quiz Question (Difficulty Hard): We train the default 8 layer transformer as well as a variant where instead of having the residual connection come from the previous layer, we take 0.5 contribution from the previous layer and 0.5 contribution from two layers before (except for the first layer). For each method, we take the best loss over six learning rates {10−4, 3 × 10−4, 10−3, 3 × 10−3, 10−2, 3 × 10−2}. What is your prediction of the loss difference between each method (Lmixed residualLdefault)?
Core diff
@@ -34,3 +34,9 @@ Transformer.forward
 x_two_back = None
 for i, block in enumerate(self.blocks):
-    x = block(x)
+    update = block.update(x)
+    residual = (
+        x if i == 0
+        else 0.5 * x + 0.5 * x_two_back
+    )
+    x_two_back, x = x, residual + update

Note: both of these questions are hard, do not get discouraged if you do not have intuition for them without running experiments from the assignment!

Assignments

Current assignment topics are tentative. Assignments 1 through 4 will study language model pre-training at a small scale reflective of larger-scale phenomena. Assignments 5 through 7 will switch to DNA.

  1. Basics: Hyperparameter tuning and scaling
  2. Optimization 1: Sharp and flat basins
  3. Optimization 2: Hyperparameter invariants
  4. Architecture 1: Extending model capacity
  5. Architecture 2: Stability across depth/time
  6. Generalization: Data-efficient algorithms
  7. Exotic: ???
All (currently tentative) deadlines are listed in the schedule.

Grading

  • 15% will come from tutorial participation (with 2 permitted absences)
  • 85% will come from quizzes (with 2 drops out of 7 quizzes)
  • 0% will come from assignments (except for their use as partial credit when cited in a quiz)

Attendance is mandatory on quiz and tutorial sessions. There will be no rescheduling or make-up opportunities except for those covered by accommodations.

Honor code

Like all other classes at Stanford, we take the student Honor Code seriously. Please respect the following policies:
  • Collaboration: We encourage students to discuss experiment ideas with each other over the week and at tutorial. However, since we believe that running experiments confers deeper understanding, we require all submitted experiments to be run by the student. If you discussed experiments with anyone, please put their names at the top of your assignment.
  • AI tools: We view assignments as instrumental to improving human understanding. Therefore, we support AI usage on assignments for implementation, visualization, mock quizzes, etc. However, since grades will be primarily determined by quiz performance, we encourage students to be thoughtful about what AI usage enhances their ability to digest phenomena (as measured by their ability to predict experiment outcomes).

Submitting coursework

  • All coursework is submitted via Gradescope by the deadline (not by email). You can submit as many times as you'd like until the deadline: we will only grade the last submission.
  • Since assignment reports are not necessary to take the quiz, we will not accept any late reports.
  • If you believe that the course staff (and their models) made an objective error in grading, you may submit a regrade request on Gradescope within 3 days after the grades are released.

GPU compute for self-study

If you are following along at home, you can access GPU compute from a cloud provider to complete the assignments.

Here are a few options (public pricing for a single B200 GPU on March 28, 2026):

Sponsor

We would like to thank Modal for sponsoring compute for this class.


Schedule (YouTube playlist TBA)

# Date Description Materials Assignments
1 Tue September 22 Lecture: Introduction TBA Assignment 1 out
(due 09/28)
2 Thu September 24 Lecture: Basics TBA
3 Tue September 29 Quiz: Basics TBA Assignment 2 out
(due 10/07)
4 Thu October 1 Lecture: Optimization 1 TBA
Tue October 6 Lecture: Optimization 1 TBA
5 Thu October 8 Quiz: Optimization 1 TBA Assignment 3 out
(due 10/19)
6 Tue October 13 Lecture: Optimization 2 TBA
Thu October 15 Lecture: Optimization 2 TBA
7 Tue October 20 Quiz: Optimization 2 TBA Assignment 4 out
(due 10/28)
8 Thu October 22 Lecture: Architecture 1 TBA
Tue October 27 Lecture: Architecture 1 TBA
9 Thu October 29 Quiz: Architecture 1 TBA Assignment 5 out
(due 11/09)
Tue November 3 No class (Democracy Day)
10 Thu November 5 Lecture: Architecture 2 TBA
11 Tue November 10 Quiz: Architecture 2 TBA Assignment 6 out
(due 11/18)
12 Thu November 12 Lecture: Generalization TBA
Tue November 17 Lecture: Generalization TBA
13 Thu November 19 Quiz: Generalization TBA Assignment 7 out
(due 12/02)
Tue November 24 No class (Thanksgiving Recess)
Thu November 26 No class (Thanksgiving Recess)
14 Tue December 1 Lecture: Exotic TBA
15 Thu December 3 Quiz: Exotic TBA