HW5 Recitation
Fall 2026 10-405/605/805
Context: Hyperparameter Tuning
Hyperparameter tuning is the process of optimizing the hyperparameters of a machine learning model to improve its performance
Random Search
Grid Search
Adaptive Selection
Context: LLM sizes
Would you run grid search in this case?
Context: GPT2
In 2019, OpenAI released GPT 2, trained on a dataset containing 8 million web-pages with the objective of predicting the next word of a given sentence.
HW5 version (preliminary): Between GPT-2 Small and Medium (~180M)
Aside: GPT2 Training Data
Source: Language Models are Unsupervised Multitask Learners (2019)
Context: HellaSwag Evaluation
HellaSwag is a benchmark designed to test if large language models (LLMs) possess commonsense reasoning abilities.
Humans easily achieve over 95% accuracy on these questions
OpenAI’s GPT-2 model only reached around 30% accuracy
Goals of HW5
Goals of HW5
Goals of HW5
Context: Max learning rate
In this graph, the max learning rate is the peak value that the learning rate reaches during training:
Context: Effective batch size
- Micro-Batch Size: The number of samples processed in a single forward-backward pass on one GPU.
Example: micro batch size of 64 means 64 samples per GPU per step.
- Effective Batch Size The total batch size affecting model updates, calculated as:
Effective Batch Size = Micro-Batch Size X Gradient Accumulation Steps
- Gradient Accumulation If memory is limited, gradients are accumulated over several micro-batches before updating the model weights.
Example: With 8 GPUs and 64 micro batch size, the total effective batch size is 8x64x(maximum sequence length) tokens. If using 1 GPU, gradient accumulation (8 steps) is used to reach the same effective batch size.
Key takeaway: Micro-batch size affects memory usage, while effective batch size controls the training update.
Recommended approach
(1) Scaling down part of the training process,
(2) Tuning hyperparameters on this smaller setup, and
(3) Transferring the findings to estimate optimal hyperparameters for the full-scale model.
Properties that might be scaled down
HW5 Logistics
Part 1. Experimental overview and experiments. Deliverables:
(a) Completed experiential design.
(b) Completed cost analysis.
(c) Completed hyperparameter tuning table.
(d) Completed empirical questions.
(e) Final selection of “max learning rate” hyperparameter.
Budget: $20+ (make sure to leave $20 for part 2!!!)
You may use extra if you have more in your AWS account
Starter Strategies
Scaling training iterations
Grid/random sample learning rates over a small range of values
Heuristic Model Scaling
Make a plot of optimal learning rate as a function of model size, and extrapolate the results.
Find the optimal learning rate for a set of models that are much smaller than the one you hope to test (GPT2-Tiny has ~30M params)
Example Models:
Tiniest ~3M
Tinier ~7M
Tiny ~ 11M
Strategy overview:
Questions you’ll probably run into
Hyperband
Recall from lecture
Train n = 9 models in the first round
Train each model to epoch 9 in the first round
Hyperband
Recall from lecture
Train n = 3 models in the second round
Train each model to epoch 27
Hyperband
Recall from lecture
Train n = 1 models in the final round
Train the model to epoch 81
Hyperband
Now consider the full Hyperband table. Repeat the same procedure, but s+1 times with slightly different values of n and r
Variables n and r have the same meaning as last slide
In this bracket, train 5 models for 81 epochs
Hyperband
Here is the Hyperband table we gave you in the homework.
Hints: Flags -n, -y, and -e may be helpful to continue training a model
Hyperband
Here is the pseudocode.
You will likely need to implement “get_hyperparameter_configuration”, “run_then_return_val_loss”, and “top_k” yourself. You may be able to use an off-the-shelf version of Hyperband.
Scaling Batch Size
It turns out that scaling to the optimal batch size and fitting learning rate as function of batch size might be a good strategy
We are still fleshing out the details on this strategy, look to the HW5 write-up for more details
Source: https://arxiv.org/pdf/2505.13738
Homework 5 Part 2
Objective: Use your hyperparameters to pretrain an LLM from scratch
Part 2 Deliverables:
(a) Final HellaSwag accuracy
(b) Final validation loss
(c) Pre-trained model weights
Budget: $15-20
Background: Embarrassingly Parallel Training
Typical multi-GPU training strategies require complex synchronization schemes
Background: Embarrassingly Parallel Training
Background: Branch-Train-Merge
Background: Branch-Train-Merge
We have trained the seed LM for you
Background: Branch-Train-Merge
We have trained the seed LM for you
Each of you will be training an expert LM on the domains you collected in HW4
Background: Branch-Train-Merge
With approx 100B tokens of data (2B tokens per student with 50 students) our class should be able to train a single massive language mode that is close to optimal