Unit 7 of 11 · about 4 hours · explain, measure
The sequence-modeling view and online fine-tuning after offline initialization
Offline training ends and interaction resumes. This unit decides whether the offline initialization helps or gets unlearned first, and where sequence copying stops being reinforcement learning.
You'll be able to
- Explain the sequence-modeling view (return-conditioned action prediction) and its stitching limit.
- State the calibration condition that prevents initial unlearning when online fine-tuning starts.
- Measure the first online episodes after offline initialization with and without the calibration fix.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Offline RL through sequence modelingHands-on Modern RL - Offline RL and Imitation Concepts
Sections 1.1-1.5: return-to-go conditioning, supervised action prediction, the inference loop that decrements the target return, why the method can work, and its limitations including stitching (page read 2026-10-14)
- Lecture 07: stitching and the imitation baselinesStanford CS224R Spring 2026 - Imitation and Offline RL
PDF pp. 11-12: the stitching diagram (good segments recombined into a better whole); PDF p. 17: filtered imitation that copies only good trajectories; PDF p. 28: the summary listing filtered and weighted imitation as baselines, with trajectory stitching as the improvement over imitation
- Cal-QL: calibration against the initial dipCal-QL: Calibrated Offline RL Pre-Training for Efficient Online Fine-Tuning
Sections 1 and 4.1 of arXiv:2303.05479v4: the initial unlearning diagnosis for conservative methods; Section 4.2 with Definition 4.1 (calibration of the learned values against a reference policy); Section 7: the fine-tuning experiments that measure the first online episodes
- Lecture 18: the offline-to-online problemBerkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Imitation and Offline RL
PDF pp. 22-25: offline pretraining followed by fast online fine-tuning, the CQL recovery period wasted regaining offline performance, and why one algorithm that does both phases well is hard to find
Focus on
- A Decision Transformer is supervised learning on triples: condition on a target return, predict the action, then subtract the observed reward from the target at the next step. No Bellman backup ever combines two different trajectories.
- Stitching is the test sequence models fail: one dataset segment runs from start to middle, another from middle to goal, and only multi-step dynamic programming returns the full route. Copying whole trajectories, however filtered, cannot invent the combination.
- Calibration is a one-sided guard, not accuracy: expected learned values must sit above the reference policy's values on dataset states. Conservative pretraining violates it by pushing learned-policy values too far down, so online updates spend their first episodes unlearning.
- The measurement that matters is the return curve of the first online episodes with and without the calibration fix, not the asymptotic return after both converge.
Common mistakes · 3
- Conditioning on a high target return and calling the result optimal. An unreachable target pushes the model into trajectory regions it never saw; sequence models copy statistics, they do not optimize.
- Assuming fine-tuning can only help. Conservative initialization starts below the behavior it already had, so early online training first recovers lost performance; skipping the first-episode measurement hides exactly this cost.
- Reading calibration as value accuracy. It bounds learned values from below against a reference; a calibrated function can still be far from the true values everywhere.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Write the Decision Transformer inference loop in three steps.Answer
Set a target return and condition the policy on it with the history; execute the predicted action and observe the reward; subtract the reward from the remaining target and repeat until the episode ends.
2.Why can filtered cloning plus a high target still fail the stitching diagram?Answer
Filtering copies only good whole trajectories, and no dataset trajectory contains the combined route. Without a Bellman backup joining the segments at the shared middle, the combination is never constructed.
3.State the calibration condition and what breaks when it fails.Answer
Expected learned values under the learned policy must exceed the reference policy's values on dataset states. When conservative pretraining pushes them below, online updates first unlearn the initialization before improving it.
4.What is the load-bearing measurement when comparing a calibrated against an uncalibrated fine-tuning run?Answer
Returns over the first online episodes: whether the dip appears, how deep it is, and how many episodes recalibration costs, before any asymptotic comparison.
Practice
- Stanford CS224R Homework 3, Question 3: the stitching study
Question 3: IQL versus Filtered BC on the PointMass task with suboptimal data; report which method improves over the dataset behavior and explain the gap in terms of value estimation
Runs on Modal, about 15 minutes for IQL and 10 for Filtered BC. Read the data-construction part first, predict the winner from the stitching argument, then run.
You're done when
You can run the inference loop and the calibration inequality from memory, predict a stitching outcome before seeing numbers, and plot a fine-tuning dip with its cause labeled.
Only when you can do this without notes.
Leads to
Notes
Resources · 4 for this unit, 10 more in the section
- Stanford CS224R Spring 2026 - Imitation and Offline RLStanford University · primary
Study Lecture 02 (imitation: behavior cloning, covariate shift, DAgger) and Lecture 07 (offline RL). Homework 1 (behavior cloning, flow matching and DAgger on a small Flappy Bird environment) runs on CPU; Homework 3 (AWAC, IQL and a stitching study) runs on cloud GPUs, so read it for the losses. Follow the Stanford honor code for course materials.
- Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Imitation and Offline RLUC Berkeley · required
Slides are public at https://rail.eecs.berkeley.edu/deeprlcourse/static/slides/lec-N.pdf; current videos are not, and the public Fall 2023 playlist numbers lectures differently. Study Lectures 2 and 3 (behavioral cloning) and Lectures 17 and 18 (offline RL). Homework 1 (MSE and flow-matching action-chunk policies) runs on a laptop CPU; Homework 5 (SAC+BC, IQL and FQL on OGBench) needs a GPU, so debug on the smallest task and treat full 1M-step sweeps as optional.
- Cal-QL: Calibrated Offline RL Pre-Training for Efficient Online Fine-TuningNakamoto et al. (NeurIPS 2023) · support
Read why conservative values cause an initial dip when online fine-tuning starts and how calibration bounds the values. Measure the first online episodes after offline training with and without the fix.
- Hands-on Modern RL - Offline RL and Imitation ConceptsWalking Labs · support
Use the offline data and distribution-shift page and the imitation chapter as pre-reading for BCQ, CQL, IQL, behavior cloning, DAgger and GAIL. They have no runnable offline or imitation scripts and no off-policy evaluation. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; its
code/chapterNNfolders do not follow the site chapter numbers.
Also in this section
- Offline Reinforcement Learning: Tutorial, Review and PerspectivesLevine et al. · required
Study the problem definition, distribution-shift failure, policy constraints, uncertainty and model-based/model-free taxonomy. Use it to state which offline assumptions each implementation relies on.
- Implicit Q-LearningKostrikov et al. · required
Derive the expectile value loss, Q target and advantage-weighted policy update. Implement fixed-batch loss tests and compare IQL with behavior cloning across dataset quality and coverage.
- Conservative Q-Learning for Offline Reinforcement LearningKumar et al. (NeurIPS 2020) · support
Read the conservative regularizer and the lower-bound argument. Implement the regularizer on a fixed batch and show how it lowers Q-values on actions the dataset does not contain.
- DAggerRoss, Gordon and Bagnell · support
Read the no-regret reduction and interactive data-aggregation loop. Demonstrate compounding error in a controlled imitation task, then show exactly what additional expert queries change.
- Generative Adversarial Imitation LearningHo and Ermon (NeurIPS 2016) · support
Read the occupancy-measure view of imitation and the discriminator-as-reward construction. State what GAIL needs that behavior cloning does not (environment interaction) and what it recovers instead of a reward.
- Doubly Robust Off-policy Value Evaluation for Reinforcement LearningJiang and Li (ICML 2016) · support
Read the per-decision importance-sampling estimator, the doubly robust form and its variance analysis. Implement ordinary, weighted and doubly robust estimates on logged trajectories from a small MDP whose true value you can compute.
- Batch Policy Learning under Constraints (Fitted Q Evaluation)Le, Voloshin and Yue (ICML 2019) · support
Read the Fitted Q Evaluation algorithm and its role inside the constrained learner. Implement FQE on your logged data and compare it with the importance-sampling estimates against the true value.
- Benchmarks for Deep Off-Policy EvaluationFu et al. (ICLR 2021) · support
Read the evaluation protocol and the metrics for estimator quality and offline model selection (rank correlation, regret of the selected policy). Use them to judge your estimators instead of one point error.
- Minari Offline DatasetsFarama Foundation · support
Use Minari as the dataset source for offline experiments: it serves Gymnasium-native datasets that download without login (start with a small MuJoCo set such as
mujoco/invertedpendulum/expert-v0). Record the dataset id and version with every result. - Reinforcement Learning Control Laboratory - Offline StretchRoadmap-Final · support
Add the project offline-data stretch only after online control passes. Calibrate importance or fitted-value estimates against simulator truth and expose one support-mismatch failure before hiding online access.