# 07 — Policy-gradient foundations & the critiques of return-conditioned sequence models

Research note for a later interactive lesson. Read on 2026-11-20.

**Tag legend** — every claim carries one: **[paper]** read in the primary PDF/arXiv text; **[code]** read in source at a pinned commit; **[docs]** read in official docs/blog; **[inferred]** my reading/derivation (not stated by the source); **[computed]** produced by code in this note (re-run it). Anything I could not read is in §9.

Page numbers refer to the arXiv PDF of the version cited (text extracted with pdf.js; math symbols such as ε sometimes drop out of extraction, so I restore them from context and mark that **[inferred]**).

---

## 0. Corrections to the brief (check these first)

| In the brief | What the sources say |
|---|---|
| Bhargava et al. 2023 "Sequence Modeling is a Robust Contender for Offline RL" | That is the **v1/v2 title** of arXiv 2305.14550. v3 (Mar 2024, the ICLR 2024 version) is titled **"When should we prefer Decision Transformers for Offline Reinforcement Learning?"** [paper: arxiv.org/abs/2305.14550, submission history + v1 abs page]. |
| Siebenborn et al. arXiv id | Correct id is **2211.14655**. (2305.16683 is an unrelated Xie et al. paper.) [paper] |
| Kumar et al. "Should I run offline RL or behavioral cloning?" | arXiv **2204.05618v1** carries the title **"When Should We Prefer Offline RL Over Behavioral Cloning?"**, and its PDF header says "Published as a conference paper at ICLR 2022" [paper p1]. I did not verify whether the OpenReview/camera-ready title differs ("Should I Run…" is the title I remember — **[unverified]**). It is **not a Decision-Transformer paper**: DT only appears in the reference list (p11), so use it as the "offline RL vs BC" theory background, not as a DT critique. |
| Paster et al. | Title in arXiv: "You Can't Count on Luck: Why Decision Transformers and RvS Fail in Stochastic Environments"; NeurIPS 2022 [paper p1 footer]. |

---

## PART 1 — Policy-gradient foundations

### 1.1 Reference table

| Item | Reference | Venue / version | Code / license |
|---|---|---|---|
| REINFORCE | R. J. Williams, "Simple statistical gradient-following algorithms for connectionist reinforcement learning", 1992 | Machine Learning 8:229–256; DOI 10.1007/BF00992696 **[inferred — standard citation; PDF not readable, see §9]** | n/a |
| Policy-gradient theorem | Sutton, McAllester, Singh, Mansour, "Policy Gradient Methods for RL with Function Approximation" | NeurIPS 1999 (proceedings 2000). Read: `papers.nips.cc/paper_files/paper/1999/file/464d828b85b0bed98e80ade0a5c43b0f-Paper.pdf` (OCR-garbled but Theorem 1 legible) | n/a |
| TRPO | Schulman, Levine, Moritz, Jordan, Abbeel, "Trust Region Policy Optimization", arXiv **1502.05477** (v1 19 Feb 2015 … v5 20 Apr 2017) | ICML 2015 **[inferred]**; arXiv license: nonexclusive-distrib | none read |
| GAE | Schulman, Moritz, Levine, Jordan, Abbeel, "High-Dimensional Continuous Control Using Generalized Advantage Estimation", arXiv **1506.02438** (v1 8 Jun 2015 … v6 20 Oct 2018) | ICLR 2016 [paper: "Published as a conference paper at ICLR 2016", p5] | none read |
| A3C | Mnih, Badia, Mirza, Graves, Lillicrap, Harley, Silver, Kavukcuoglu, "Asynchronous Methods for Deep RL", arXiv **1602.01783** (v1 4 Feb 2016, v2 16 Jun 2016) | ICML 2016 **[inferred]** | none read |
| PPO | Schulman, Wolski, Dhariwal, Radford, Klimov, "Proximal Policy Optimization Algorithms", arXiv **1707.06347** (v1 20 Jul 2017, v2 28 Aug 2017) | arXiv preprint (no venue printed) | "official" code = `openai/baselines` `pposgd`/`ppo1` commit `da99706` per the 37-details blog **[docs]** |
| 37 details | Huang, Dossa, Raffin, Kanervisto, Wang, "The 37 Implementation Details of Proximal Policy Optimization", 25 Mar 2022 | ICLR 2022 Blog Track: `iclr-blog-track.github.io/2022/03/25/ppo-implementation-details/` | `github.com/vwxyzjn/ppo-implementation-details` (linked in blog) |
| CleanRL | `github.com/vwxyzjn/cleanrl`, file `cleanrl/ppo.py`, pinned at master commit `fe8d8a03c41a7ef5b523e2e354bd01c363e786bb` (2026-04-20); last commit touching the file `e421c2e50b81febf639fced51a69e2602593d50d` | MIT (LICENSE file read; GitHub's API reports NOASSERTION) | |
| Spinning Up | `github.com/openai/spinningup`, `spinup/algos/pytorch/ppo/ppo.py`, master `038665d62d569055401d91856abb287263096178` | MIT | |

### 1.2 Policy gradient, REINFORCE, baselines — the one-screen derivation to teach

**General form [paper — GAE §2, p2, Eq. 1].** All of the common estimators have the shape

`g = E[ Σ_t Ψ_t ∇θ log πθ(a_t|s_t) ]`, with Ψ_t one of: (1) total trajectory reward; (2) reward following a_t; (3) `Σ_{t'≥t} r_t' − b(s_t)` ("baselined version"); (4) Q^π; (5) A^π; (6) the TD residual `r_t + V^π(s_{t+1}) − V^π(s_t)` [paper GAE p2].

**Policy-gradient theorem [paper — Sutton et al., Thm 1, p3].** "For any MDP, in either the average-reward or start-state formulations, ∂ρ/∂θ = Σ_s d^π(s) Σ_a ∂π(s,a)/∂θ · Q^π(s,a)." The authors stress "there are no terms of the form ∂d^π(s)/∂θ: the effect of policy changes on the distribution of states does not appear. This is convenient for approximating the gradient by sampling." They also state that "Williams's (1988, 1992) theory of REINFORCE algorithms can also be viewed as implying (2)", and that using the actual return R_t in place of Q^π "leads to Williams's episodic REINFORCE algorithm, Δθ_t ∝ (∂π(s_t,a_t)/∂θ)(1/π(s_t,a_t)) R_t … which is known to follow ∂ρ/∂θ in expected value" [paper p3]. (This is the best I could verify of Williams's result, second-hand — see §9.)

**Baselines [paper — Sutton et al. §3, p5].** Because `Σ_a ∂π(s,a)/∂θ = 0` for every s, any state-dependent `v(s)` can be subtracted from Q: "The choice of v does not affect any of our theorems, but can substantially affect the variance of the gradient estimators… entirely analogous to … reinforcement baselines in earlier work (e.g., Williams, 1992…)". In practice v ≈ V^π. GAE lists the same idea as estimator 3 (`− b(s_t)`) [paper GAE p2].

**Actor-critic [inferred]:** the baseline/advantage is itself learned (critic V_φ), the policy is the actor. This is exactly what A3C does (below) and what PPO's value head does.

**A3C [paper — Mnih et al., pp4–5].** Advantage is an n-step estimate `Σ_{i=0}^{k−1} γ^i r_{t+i} + γ^k V(s_{t+k}) − V(s_t)`, "k can vary from state to state and is upper-bounded by t_max"; the actor update is `∇θ' log π(a_t|s_t;θ') (R_t − V(s_t;θ_v)) + β∇θ' H(π(s_t;θ'))` with entropy-regularisation strength β; parallel actor-learners replace experience replay ("we do not use a replay memory and rely on parallel actors employing different exploration policies"); RMSProp update `g = αg + (1−α)Δθ², θ ← θ − η Δθ/√(g+ε)`; Atari trained with 16 CPU cores; learning rates for the async methods sampled from LogUniform(10⁻⁴, 10⁻²) [paper p4–5].
**A2C:** the synchronous variant of A3C. The OpenAI blog that introduced the name returned HTTP 403, so I could not verify its wording **[unverified]**; the PPO paper does use A2C as a baseline (Table 2: A2C wins 1/49 games on both metrics vs PPO 30/19 and ACER 18/28) [paper PPO p8]. The 37-details blog describes the matching "vectorized architecture: single learner … multiple environments" [docs].

**TRPO [paper — Schulman 2015, pp2–3, 15–16].**
- Thm 1 (Eq. 8): with `α = D_TV^max(π_old, π_new)` and `ε = max_{s,a}|A_π(s,a)|`: `η(π_new) ≥ L_{π_old}(π_new) − (4εγ/(1−γ)²) α²`. Using `D_TV² ≤ D_KL` gives a KL-penalised bound; Eq. 10: maximising `M_i(π) = L_{π_i}(π) − C·D_KL^max(π_i,π)` each iteration "guarantee[s] that the true objective η is non-decreasing" (monotonic improvement).
- Practical version: because the theory's C gives "very small" steps, use a trust-region constraint (Eq. 11): `maximize L_{θ_old}(θ) subject to D_KL^max(θ_old, θ) ≤ δ`.
- Hyper-parameters, Table 2 (continuous control): step size D_KL = **0.01**, γ = 0.99; Atari: step size 0.01, γ 0.99 [paper p15–16].
- PPO's motivation text: TRPO "is relatively complicated, and is not compatible with architectures that include noise (such as dropout) or parameter sharing" [paper PPO p1].

### 1.3 GAE — exact definitions

All [paper, GAE p5, Eq. 16–19] unless noted.
- TD residual: `δ_t = r_t + γV(s_{t+1}) − V(s_t)`.
- `Â_t^{GAE(γ,λ)} = (1−λ)(Â^(1)+λÂ^(2)+λ²Â^(3)+…) = Σ_{l=0}^∞ (γλ)^l δ_{t+l}`  (Eq. 16).
- λ=0: `Â_t = δ_t` (Eq. 17). λ=1: `Â_t = Σ γ^l δ_{t+l} = Σ γ^l r_{t+l} − V(s_t)` (Eq. 18). "GAE(γ,1) is γ-just regardless of the accuracy of V, but it has high variance… GAE(γ,0) … induces bias [if V ≠ V^{π,γ}], but typically has much lower variance."
- Experiments: best cart-pole results at γ∈[0.96,0.99], λ∈[0.92,0.99] (p9); Fig 2 caption: "fastest policy improvement is obtained by intermediate values of λ in the range [0.92, 0.98]" at γ=0.99.
- PPO's truncated form for T-step rollouts, Eq. 10–12 [paper PPO p5]: `Â_t = −V(s_t)+r_t+γr_{t+1}+…+γ^{T−t+1}r_{T−1}+γ^{T−t}V(s_T)` (Eq. 10; the paper prints exponent `T−t+1` on the last reward), `Â_t = δ_t + (γλ)δ_{t+1}+…+(γλ)^{T−t+1}δ_{T−1}` (Eq. 11), `δ_t = r_t+γV(s_{t+1})−V(s_t)` (Eq. 12). **[inferred]** The printed exponents look off-by-one relative to a rollout ending at T−1 (they would be `T−t−1`); don't copy them verbatim into a lesson.
- CleanRL implements the same thing as a backwards recursion, with `nextnonterminal` masking at episode ends [code: cleanrl/ppo.py:217–231]:
  `delta = rewards[t] + gamma*nextvalues*nextnonterminal − values[t]` (L229); `advantages[t] = lastgaelam = delta + gamma*gae_lambda*nextnonterminal*lastgaelam` (L230); `returns = advantages + values` (L231).

### 1.4 PPO — exact objective

**Clipped surrogate [paper PPO §3, Eq. 7, p3].**
`L^CLIP(θ) = Ê_t[ min( r_t(θ) Â_t , clip(r_t(θ), 1−ε, 1+ε) Â_t ) ]`, `r_t(θ) = πθ(a_t|s_t)/πθ_old(a_t|s_t)`, "ε is a hyperparameter, say, ε = 0.2".
Paper's own explanation: the second term "removes the incentive for moving r_t outside of the interval [1−ε, 1+ε]. Finally, we take the minimum of the clipped and unclipped objective, so the final objective is a lower bound (i.e., a pessimistic bound) on the unclipped objective… we only ignore the change in probability ratio when it would make the objective improve, and we include it when it makes the objective worse." `L^CLIP = L^CPI` to first order around θ_old.
**Combined objective [paper Eq. 9, p5]:** `L_t^{CLIP+VF+S}(θ) = Ê_t[ L_t^CLIP(θ) − c1 L_t^VF(θ) + c2 S[πθ](s_t) ]`, `L^VF = (Vθ(s_t) − V_t^targ)²`. Notes in the paper's continuous-control experiment: "We don't share parameters between the policy and value function (so coefficient c1 is irrelevant), and we don't use an entropy bonus" [p6].
**Algorithm 1 [paper p5]:** N parallel actors × T timesteps → compute Â → optimise surrogate for K epochs with minibatch size M ≤ NT → θ_old ← θ.
**Ablation Table 1 [paper p6]** (7 MuJoCo envs × 3 seeds = 21 runs, avg normalised score; random=0, best=1): no clipping/penalty **−0.39**; clipping ε=0.1 **0.76**, **ε=0.2 0.82**, ε=0.3 0.70; adaptive-KL d_targ 0.003/0.01/0.03 = 0.68/0.74/0.71; fixed KL β=0.3/1/3/10 = 0.62/0.71/0.72/0.69. (No-clip is negative because HalfCheetah goes below random.)
**Fig 2 [paper p4]:** L^CPI, clipped term and L^CLIP interpolated between θ_old and θ_new for the first Hopper-v1 update; L^CLIP is maximal at KL ≈ 0.02.

**Default hyper-parameters — paper.**
| | MuJoCo 1M (Table 3) | Roboschool (Table 4) | Atari (Table 5) |
|---|---|---|---|
| Horizon T | 2048 | 512 | 128 |
| Adam stepsize | 3×10⁻⁴ | adjusted to target KL | 2.5×10⁻⁴ × α |
| Epochs K | 10 | 15 | 3 |
| Minibatch | 64 | 4096 | 32×8 |
| γ / λ | 0.99 / 0.95 | 0.99 / 0.95 | 0.99 / 0.95 |
| Actors | (1) | 32 loco / 128 flagrun | 8 |
| ε | 0.2 (best in Table 1) | – | 0.1 × α |
| c1 / c2 | irrelevant / none (§6.1) | – | 1 / 0.01 |
α is linearly annealed 1→0 in Atari [paper p10 Tables 3–5]. Roboschool log-stdev anneals linearly from −0.7 to −1.6.
(MuJoCo "actors = 1" is **[inferred]** — Table 3 lists no actor count.)

**Default hyper-parameters — CleanRL `ppo.py`** [code: vwxyzjn/cleanrl@fe8d8a0, `cleanrl/ppo.py`, `Args` dataclass L36–69]:
`env_id="CartPole-v1"` L37, `total_timesteps=500000` L39, `learning_rate=2.5e-4` L41, `num_envs=4` L43, `num_steps=128` L45, `anneal_lr=True` L47, `gamma=0.99` L49, `gae_lambda=0.95` L51, `num_minibatches=4` L53, `update_epochs=4` L55, `norm_adv=True` L57, `clip_coef=0.2` L59, `clip_vloss=True` L61, `ent_coef=0.01` L63, `vf_coef=0.5` L65, `max_grad_norm=0.5` L67, `target_kl=None` L69. Network: two 64-unit tanh MLPs, separate actor and critic, orthogonal init (√2 hidden, 0.01 actor head, 1.0 critic head) (L~96–115), `Adam(lr, eps=1e-5)` (L168). Batch = 4×128 = 512, minibatch = 128.
Key lines of the update [code, same file]: `ratio = logratio.exp()` L252; `pg_loss1 = -mb_advantages*ratio` L265; `pg_loss2 = -mb_advantages*clamp(ratio, 1-clip_coef, 1+clip_coef)` L266; `pg_loss = max(pg_loss1, pg_loss2).mean()` L267 (identical to `−min(rA, clip·A)` of Eq. 7); advantage normalisation **per minibatch** L261–263; value-loss clipping L271–280 (reuses `clip_coef`); `loss = pg_loss − ent_coef*entropy_loss + v_loss*vf_coef` L285; `clip_grad_norm_(…, max_grad_norm)` L289; optional KL early stop L292; `approx_kl = ((ratio−1) − logratio).mean()` L257; `clipfrac` L258. LR annealing L187–190.
**Differences from the paper [inferred from comparing the two]:** per-minibatch advantage normalisation, value-loss clipping, gradient clipping, orthogonal init, LR annealing and Adam ε=1e-5 are **not in Eq. 7/9 or Algorithm 1**; they are the "implementation details" below. CleanRL's comment on `clip_vloss` says "as per the paper" (L62), yet Eq. 9 on p5 of the paper shows a plain squared error — treat the "as per the paper" remark as referring to the original baselines code **[inferred]**.

**Default hyper-parameters — Spinning Up** [docs: spinningup.openai.com/en/latest/algorithms/ppo.html; code: openai/spinningup@038665d `spinup/algos/pytorch/ppo/ppo.py`]:
`ppo(... steps_per_epoch=4000, epochs=50, gamma=0.99, clip_ratio=0.2, pi_lr=3e-4, vf_lr=1e-3, train_pi_iters=80, train_v_iters=80, lam=0.97, max_ep_len=1000, target_kl=0.01 ...)` (code L88–91; same signature in docs). Loss: `ratio = exp(logp − logp_old)` L232; `clip_adv = clamp(ratio, 1−clip_ratio, 1+clip_ratio)*adv` L233; `loss_pi = −(min(ratio*adv, clip_adv)).mean()` L234 (no entropy term in that expression); two separate Adam optimisers L251–252; policy early stop when KL > `1.5*target_kl` L269; advantages normalised over the whole buffer (MPI mean/std) L80–81; GAE via `discount_cumsum(deltas, gamma*lam)` L64. Gotcha **[code]**: `PPOBuffer.__init__` default is `lam=0.95` (L19) but `ppo()` passes its own `lam=0.97` (L90) — the effective default is 0.97.
Docs: the simplified clip form `min(r·A, g(ε,A))`, `g = (1+ε)A if A≥0 else (1−ε)A`; "clip_ratio… Usually small, 0.1 to 0.3", "target_kl… Usually small, 0.01 or 0.05" [docs]. Docs also warn "it is still possible to end up with a new policy which is too far from the old policy", which is why they add KL early stopping [docs].

### 1.5 The 37 implementation details (ICLR Blog Track 2022) [docs]

Source: `iclr-blog-track.github.io/2022/03/25/ppo-implementation-details/`. The authors define the "official" PPO as `openai/baselines` **ppo2 at commit ea25b9e** (pposgd/ppo1 `da99706`, 20 Jul 2017, is the paper-era code) and give a code permalink for each item. Titles I extracted verbatim (with the blog's code references):
- **13 core** — 1 Vectorized architecture; 2 Orthogonal init of weights + constant init of biases; 3 Adam optimizer's epsilon; 4 Adam learning-rate annealing; 5 Generalized Advantage Estimation; 6 Mini-batch updates; 7 Normalization of advantages; 8 Clipped surrogate objective; 9 Value-function loss clipping; 10 Overall loss and entropy bonus; 11 Global gradient clipping; 12 Debug variables; 13 Shared vs separate MLP networks for policy and value.
- **9 Atari** — NoopResetEnv, MaxAndSkipEnv, EpisodicLifeEnv, FireResetEnv, WarpFrame, ClipRewardEnv, FrameStack, shared Nature-CNN for policy+value, scaling images to [0,1].
- **9 continuous-action (MuJoCo)** — continuous actions via normal distributions; state-independent log-std; independent action components; separate MLPs for policy/value; action clipping and storage; observation normalisation; observation clipping; reward scaling; reward clipping.
- **5 LSTM** (titles partially captured: initialise LSTM states to zeros; reset LSTM states at episode end; …).  **1 MultiDiscrete** action space detail.
- **4 "situational", not in official code:** clip-range annealing; parallelised gradient update; early stopping of policy optimisation; invalid-action masking.
- Count check: 13+9+9+5+1 = 37 ✓.
- Their reproduction table (best reported results across libraries) shows the same algorithm giving very different numbers — e.g. Breakout 274.8 (baselines pposgd) vs 114.26 (baselines ppo2, 2018 benchmark) vs 409.265±30.98 (ppo2 ea25b9e, their run) — "even the original implementation could produce inconsistent results" [docs]. Good lesson hook: *PPO the paper ≠ PPO the code*.

### 1.6 Tiny verifiable numerics [computed] (Python, NumPy only — re-run to check)

**GAE on a 4-step rollout.** γ=0.99, λ=0.95. Rewards `r=[0,1,0,2]`; critic values `V=[0.5,0.6,0.8,0.4]`; bootstrap `V(s_4)=0.3`; no episode ends inside the window (so `nextnonterminal=1`, mirroring CleanRL L222–231).
| t | r_t | V(s_t) | V(s_{t+1}) | δ_t = r+γV'−V | Â_t (λ=0.95) | Â_t (λ=0) | Â_t (λ=1) | return target = Â+V |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0.5 | 0.6 | 0.094 | **2.435855** | 0.094 | 2.718777 | 2.935855 |
| 1 | 1 | 0.6 | 0.8 | 1.192 | **2.490011** | 1.192 | 2.651290 | 3.090011 |
| 2 | 0 | 0.8 | 0.4 | −0.404 | **1.380128** | −0.404 | 1.474030 | 2.180129 |
| 3 | 2 | 0.4 | 0.3 | 1.897 | **1.897000** | 1.897 | 1.897000 | 2.297000 |
Check: backwards recursion (`A_t = δ_t + γλ A_{t+1}`) equals the direct sum `Σ(γλ)^l δ_{t+l}`; at λ=1 it equals the bootstrapped discounted return minus V(s_t). Example hand step: `A_3 = δ_3 = 2 + 0.99·0.3 − 0.4 = 1.897`; `A_2 = −0.404 + 0.99·0.95·1.897 = 1.380128`.

```python
import numpy as np
g, lam = 0.99, 0.95
r = np.array([0, 1, 0, 2.]); V = np.array([.5, .6, .8, .4]); Vboot = .3
delta = r + g*np.append(V[1:], Vboot) - V
adv = np.zeros(4); last = 0.0
for t in reversed(range(4)):
    last = delta[t] + g*lam*last; adv[t] = last
```

**PPO clipped objective on 3 samples** (ε=0.2):
| sample | ratio r | advantage A | r·A | clip(r,0.8,1.2)·A | min = L^CLIP term | CleanRL `max(−rA, −clip·A)` | gradient wrt r |
|---|---|---|---|---|---|---|---|
| 1 | 1.3 | +2.0 | 2.600 | 2.400 | **2.400** (clipped) | −2.400 | 0 (clip active) |
| 2 | 0.7 | −1.5 | −1.050 | −1.200 | **−1.200** (clipped) | 1.200 | 0 (clip active) |
| 3 | 1.1 | +0.5 | 0.550 | 0.550 | **0.550** (inside band) | −0.550 | A = 0.5 |
`L^CLIP` (mean over the 3) = 0.5833, versus unclipped mean `r·A` = 0.7 → clipping removes the incentive to push samples 1 and 2 further. Pessimism extra: for A<0 and r>1+ε (e.g. r=1.5, A=−1) the min picks the **unclipped** `r·A = −1.5`, so the gradient still pushes the ratio back down [inferred from Eq. 7; consistent with Spinning Up's case analysis, docs].

### 1.7 Figures worth reusing (Part 1)
- PPO paper Fig 1 (single-timestep L^CLIP vs r for A>0 and A<0) — arXiv PDF p3 (`arxiv.org/pdf/1707.06347v2`); Fig 2 (surrogates vs interpolation, KL≈0.02) — p4. The arXiv HTML for 1707.06347 is a stub (no images), so the figure must come from the PDF. Teaches: the flat region = no incentive. arXiv license nonexclusive-distrib → redraw rather than copy.
- GAE Fig 2 (cart-pole: λ sweep at γ=0.99 and γ×λ heatmap) — `https://arxiv.org/html/1506.02438v6/cartpole-grid.png` (verified HTTP 200). Teaches: bias–variance sweet spot at intermediate λ,γ.
- Spinning Up has equation images only (no figures) [docs].

---

## PART 2 — Critiques of return-conditioned sequence models

**Baseline claim being critiqued — Decision Transformer** [paper, arXiv 2106.01345 v2, NeurIPS 2021 **[inferred venue]**, Chen, Lu, Rajeswaran, Lee, Grover, Laskin, Abbeel, Srinivas, Mordatch]: abstract says DT "simply outputs the optimal actions by leveraging a causally masked Transformer… conditioning an autoregressive model on the desired return (reward), past states, and actions… matches or exceeds the performance of state-of-the-art model-free offline RL baselines on Atari, OpenAI Gym, and Key-to-Door tasks" [p1]. Official code: `github.com/kzl/decision-transformer`, MIT [GitHub API]. arXiv license nonexclusive-distrib.

Common vocabulary: **RCSL** (return-conditioned supervised learning, Brandfonbrener) = **RvS** (RL via supervised learning, Emmons) = DT's training objective: maximise `log π(a_t | s_t, g)` where g is the trajectory's return(-to-go) [paper Brandfonbrener Eq. 1].

### 2.0 One-paragraph map (for the lesson)

| Failure | Paper | Mechanism | Fix suggested |
|---|---|---|---|
| Needs near-deterministic dynamics, known target, return coverage; exponential sample complexity possible | Brandfonbrener 2022 | conditioning on a return ≠ achieving it | DP/value methods |
| "Lucky" returns mislead conditioning in stochastic envs | Paster 2022 | P(a\|return) mixes skill and luck | ESPER (cluster-average returns) |
| No trajectory stitching | Brandfonbrener 2022 (App. B), Yamagata 2023 | trajectory-level conditioning can't combine sub-paths | QDT: relabel RTG with a Q/V estimate |
| Is the Transformer the active ingredient? | Emmons 2022, Siebenborn 2022 | MLP (RvS) / LSTM matches or beats | capacity+regularisation matter |
| When *does* DT win? | Bhargava 2023 | sparse reward, low-quality data, long horizon | choose per regime |
| Offline RL vs BC theory | Kumar 2022 | concentrability, horizon-free sparse reward | – |

---

### 2.1 Brandfonbrener, Bietti, Buckman, Laroche, Bruna — "When does return-conditioned supervised learning work for offline reinforcement learning?"

- **Reference:** arXiv **2206.01079** (v1 2 Jun 2022, v2 10 Oct 2022, v3 11 Jan 2023); **NeurIPS 2022** (36th Conf., footer p1). [paper]
- **Code:** `github.com/davidbrandfonbrener/rcsl-paper`, MIT (GitHub API); code link stated in paper p8 and App. D. Paper's own asset licences: DT repo MIT, jaxrl MIT, D4RL Apache-2.0 [paper p21]. arXiv licence nonexclusive-distrib.
- **Exact claim:** "RCSL returns the optimal policy under a set of assumptions that are stronger than those needed for the more traditional dynamic programming-based algorithms." [paper abstract p1]. "RCSL (but not DP) requires nearly deterministic dynamics in the MDP, knowledge of the proper value to condition on, and for the conditioning value to be supported by the distribution of returns in the dataset." Conclusion: "RCSL alone is unlikely to be a general solution for offline RL problems, but does show promise in some specific situations such as deterministic MDPs with high-quality behavior data." [p2]
- **Setup [paper p2]:** loss `L̂(π) = −Σ_τ Σ_t log π(a_t | s_t, g(τ))` (Eq. 1); test policy `π_f(a|s) = π(a|s, f(s))` (Eq. 2); infinite-data optimum `π^RCSL_f(a|s) = P_β(a|s,f(s)) = β(a|s) · P_β(f(s)|s,a)/P_β(f(s)|s)` (Eq. 3) — "the RCSL policy re-weights the behavior based on the distribution of future returns." DT is the special case where the state includes the whole history.
- **Theorem 1 (p3):** assume (1) return coverage `P_β(g=f(s_1)|s_1) ≥ α_f`; (2) near-determinism (prob. of deviating from some `T(s,a), r(s,a)` ≤ ε); (3) consistency of f. Then `E[f(s_1)] − J(π^RCSL_f) ≤ (1/α_f + 2) ε H²`, and "there exist problems where the bound is tight up to constant factors." (ε restored from context **[inferred]**.) Corollary (p4): ∃ f with `J(π*) − J(π^RCSL_f) ≤ (1/α_f + 3) ε H²`; Corollary 2: if α_f>0, ε=0, `f(s_1)=V*(s_1)` then `J(π^RCSL_f) = J(π*)`.
- **Theorem 2 (p5), reduction to supervised learning:** with bounded occupancy mismatch `C_f` and return coverage `α_f`, `J(π^RCSL_f) − J(π̂_f) ≤ (C_f/α_f) H² √(2 L(π̂))`.
- **Theorem 3 / 4 (App. C, pp18–19):** same style bounds for %BC (quantile-filtered BC).
- **Why each assumption is needed — Fig 1 (p4):** (a) a one-action MDP with Bernoulli outcome: conditioning on return 1 gives `J = ε` (bound tight in ε/α_f): "the goal of achieving a specific desired return is incompatible with stochastic environments"; (b) and (c): stochastic transitions produce real regret, in (c) "for any conditioning function."
- **Exponential sample complexity in a *deterministic* MDP — Fig 2 (p6):** horizon H=4 (as printed), `P_β(g=k|s_1,a_2) = 0.5·(0.25)^k` vs `P_β(g=k|s_1,a_1) = 0.5·(0.1)^k` — conditioning on a medium return makes the worse action *more* likely; need data exponential in H to see the optimal return.
- **Stitching (App. B, pp13–14, Fig 8):** with infinite data and deterministic dynamics, RCSL "can fail to recover the optimal policy": conditioning on g=1 leaves `π(·|s_1,g=1)` undefined, and the only workable conditioning (`f(s_0)=0, f(s_2)=1`) is non-standard; `π` "will never choose the optimal path with probability larger than 0.5"; for DT-style full-history conditioning "`P_data(a_1|s_0,a_0,s_2,g=1)=0` … can perform even worse." Empirical: Fig 9 (stitch-easy / stitch-hard) — RvS nearly matches DP on stitch-easy; "DT totally fails on this task since it conditions on the entire history of the trajectory… DT always reproduces such trajectories from the initial state" (p15).
- **Evidence — point-mass (§6.1, Fig 3, p9):** three reward functions in a DeepMind-control point-mass: "ring of fire" and sparse → RCSL fails (exponentially small probability of good trajectories); dense → generalises. "BC methods blue, DP methods brown, RCSL green; error bars std over 3 seeds."
- **Evidence — D4RL (Fig 4 p9; Figs 5–7 App. A):** antmaze-umaze, antmaze-medium-play, halfcheetah-medium-replay, pen-human; hyper-parameters tuned over 4 values, best reported, 3 seeds. "For most of the datasets DP-based algorithms TD3+BC and IQL outperform both the BC-based algorithms and RCSL-based algorithms. This is especially stark on the antmaze datasets where the behavior policy is highly stochastic, requiring the learner to stitch… RCSL performs well when the behavior policy is already high quality, but not optimal (as in the pen-human task)… IQL … is outperformed by DT (perhaps due to the use of history-dependent policies)." (p9). Shared hyper-params: 5e5 steps, batch 256, MLP 2×256; DT reward-target sets: point-mass [300,200,100,50,10,0], antmaze [1.0,0.75,0.5], halfcheetah [12000,9000,6000], pen [3000,2000,1000] (Tables 1,2,4, pp20–21).
- **When RCSL/DT works:** near-deterministic dynamics; the conditioning value is covered by data and known (e.g. V*); good-quality behaviour data with dense reward (pen-human; point-mass dense) [paper pp2, 9–10].
- **When it fails:** stochastic dynamics (Fig 1); sparse/"ring of fire" rewards (exponential sample complexity, Fig 2–3); needing stitching (Fig 8–9, antmaze) [paper].
- **What the paper concluded vs what people say:** *Concluded:* RCSL is simple and "an excellent practical choice" when the stated requirements hold, but "as a general learning paradigm, RCSL is fundamentally limited in ways that DP is not" (p10); also "empirically, current deep DP algorithms are not well-behaved" (p10). *Often mis-said* **[inferred]:** "Brandfonbrener proved DT is bad / DT can't work" — no: it gives sufficient conditions, a tightness example, and a reduction to supervised learning; and "DT can't stitch" is the paper's App. B result for conditioning on trajectory-level returns, not for all sequence models.
- **Figures to reuse:** Fig 1a–c (three tiny stochastic MDPs) — PDF p4; Fig 3 `https://arxiv.org/html/2206.01079v3/gridworld.png` (point-mass reward comparison); Fig 4 `https://arxiv.org/html/2206.01079v3/d4rl_results.png`; Fig 9 `https://arxiv.org/html/2206.01079v3/stitch-easy-data.png` (all HTTP 200; Figs 1/2/8 are not exposed as separate images in the HTML — use PDF pp4, 6, 14).

---

### 2.2 Paster, McIlraith, Ba — "You Can't Count on Luck: Why Decision Transformers and RvS Fail in Stochastic Environments"

- **Reference:** arXiv **2205.15967** (v1 31 May 2022, v2 28 Nov 2022); **NeurIPS 2022** [paper p1 footer "NeurIPS 2022", "arXiv:2205.15967v2"].
- **Code:** only "https://sites.google.com/view/esper-paper" (paper p6); no GitHub repo or licence found [searched GitHub: nothing]. arXiv licence nonexclusive-distrib.
- **Exact claim [abstract p1]:** "simply conditioning a probabilistic model on a desired return and taking the predicted action can fail dramatically in stochastic environments since trajectories that result in a return may have only achieved that return due to luck." Proposed fix **ESPER**: "learns to cluster trajectories and conditions on average cluster returns, which are independent from environment stochasticity."
- **Theory — Theorem 2.1 (p4):** `π_D` data policy, RvS trained so `π(a_t|s_0,a_0,…,s_t,z) = p_{π_D}(a_t|s_0,a_0,…,s_t, I(τ)=z)`. Then for any goal z with `p_{π_D}(I(τ)=z|s_0) > 0`, **z is "consistently achievable" iff** `p_{π_D}(s_t|s_0,a_0,…,a_{t−1}) = p_{π_D}(s_t|s_0,a_0,…,a_{t−1}, I(τ)=z)` — i.e. the statistic the policy is conditioned on must be independent of the environment's stochastic transitions. Consequence: "use trajectory statistics that are independent from the stochasticity in environment transitions".
- **The toy environment — Fig 1 (p3):** one state, three actions, behaviour policy uniform (33% each).
  - a0: reward +5 w.p. 50%, −15 w.p. 50% (E = −5)
  - a1: reward +1 w.p. 50%, −6 w.p. 50% (E = −2.5)
  - a2: reward +1 w.p. 100% (optimal)
  - Table in figure: conditioned return → E[r] of the BC'd policy: −15 → −5.0 (a0); −6 → −2.5 (a1); **+1 → −0.17 (a1 or a2)**; +5 → −5.0 (a0). Caption: "conditioned on receiving a reward of 1, it will always gamble and take a1 some of the time, rather than just taking a2, which guarantees the reward… No matter how much data the model is trained on". Arithmetic in caption: `−2.5×1/3 + 1×2/3 = −0.17`.
  - **Reproduced [computed], exact via Bayes** (Fractions, plus 300k-sample Monte-Carlo with seed 0): `P(a1|r=1) = (1/3·1/2) / (1/3·1/2 + 1/3·1) = 1/3`, `P(a2|r=1) = 2/3`, policy value `1/3·(−2.5)+2/3·1 = −1/6 ≈ −0.1667`. Empirical `P(a|r=1) = [0, 0.334, 0.666]`; rolling out that policy gives mean return **−0.17** (vs 1.0 for always-a2). Asking for r=5 or −15 gives a0, whose true mean is −5.
  ```python
  from fractions import Fraction as F
  beh = F(1,3)
  outs = {'a0': [(5,F(1,2)),(-15,F(1,2))], 'a1': [(1,F(1,2)),(-6,F(1,2))], 'a2': [(1,F(1))]}
  joint = {(a,r): beh*p for a,l in outs.items() for r,p in l}
  R = 1; z = sum(p for (a,r),p in joint.items() if r==R)
  pa = {a: p/z for (a,r),p in joint.items() if r==R}          # {a1: 1/3, a2: 2/3}
  value = sum(pa[a]*sum(r*p for r,p in outs[a]) for a in pa)  # -1/6
  ```
  This is the best "few lines" teaching example for the stochastic-environment failure; more data does not help because the *conditional* P(a|return) is already exactly the learned thing.
- **ESPER (Fig 2, p4; Eq. 2.2–2.5, p5):** phase 1 learn a discrete cluster assignment `I(τ)` with an adversarial loss that stops a dynamics model "cheating" from the cluster id (`L(θ) = E[−β_act log p_θ(a_t|s_t,I(τ)) + β_adv log p_φ(s_{t+1}|…,I(τ))]`; `L(φ)=E[−log p_φ(s_{t+1}|…)]`); phase 2 average return per cluster; phase 3 train an RvS policy conditioned on that expected return.
- **Evidence — Fig 3 table (p6)** (max achievable performance, 3 seeds, max possible = 1.0): Gambling — RvS/DT **−0.02 (0.24)**, CQL 1.0, ESPER 1.0; Connect Four (20% chance opponent fails to place in rightmost column, Fig 4 p7) — DT **0.8 (0.07)**, CQL 0.61, ESPER 0.99; 2048 (reward 1 for a 128 tile) — DT **0.57 (0.05)**, CQL 0.7, ESPER 0.81. Fig 6 left: more data does not improve the return-conditioned agent but improves ESPER's alignment; Fig 6 right on gambling confirms that representations that let the dynamics model "cheat" are worse (empirical check of Thm 2.1). Fig 8: ESPER also works with MLP (not just transformer) policies.
- **When DT works / fails:** works when returns are determined by the agent's actions (deterministic dynamics, or noise independent of the conditioning statistic); fails when the return depends on stochastic transitions [paper].
- **Concluded vs misstated:** *Concluded:* a limitation "that cannot be fixed by more scale and data alone" (conclusion p9), for return conditioning in stochastic envs. *Often mis-said* **[inferred]:** "DT can't handle any stochasticity." The paper's claim is about conditioning on a single realised return; Bhargava et al. later find DT competitive under *moderate* stochasticity with high-quality data (§2.5), and the failure is not about the Transformer (ESPER keeps the transformer or an MLP).
- **Figures to reuse:** Fig 1 (gambling MDP + conditioning table) — PDF p3, redraw as an interactive; Fig 2 `https://arxiv.org/html/2205.15967v2/algo.png`; Fig 3 table (p6).

---

### 2.3 Yamagata, Khalil, Santos-Rodriguez — "Q-learning Decision Transformer: Leveraging Dynamic Programming for Conditional Sequence Modelling in Offline RL"

- **Reference:** arXiv **2209.03993** (v1 8 Sep 2022 … v4 25 May 2023, used here); **ICML 2023** (PMLR 202; "Proceedings of the 40th ICML, Honolulu", p1). arXiv licence **CC-BY 4.0** (abs page). [paper]
- **Code:** I found **no official repository** (paper has no code link; QDT code is "extra code" added to `kzl/decision-transformer`'s `gym/experiment.py` per App. C.2; GitHub search found only unrelated repos) → **[unverified]**.
- **Exact claim [abstract p1]:** "DT lacks stitching ability — one of the critical abilities for offline RL to learn the optimal policy from sub-optimal trajectories. This issue becomes particularly significant when the offline dataset only contains sub-optimal trajectories." QDT "utilises the Dynamic Programming results to relabel the return-to-go in the training data to then train the DT with the relabelled data."
- **Method [paper Alg. 1–2, p4]:** `R_T ← 0; for τ=T..1: R_{τ−1} ← r_{τ−1} + max(R_τ, V̂(s_τ))` (V̂ from CQL); Alg. 2 re-derives a consistent RTG sequence inside each context window (`R̂_τ ← r_τ + R̂_{τ+1}`).
- **Evidence:**
  - *Simple environment (Fig 1/5; Table 1, p5; 10 seeds):* total reward CQL **40.0±0.0**, DT **15.9±4.4**, QDT **42.2±6.3**. Fig 1 caption: the DT approach "fails to find the shortest path to the goal. In contrast, Q-learning finds the shortest path."
  - *Maze2D (Table 2, p6; 5 seeds):* sparse reward — umaze CQL 94.7±23.1 / DT 31.0±21.3 / QDT 57.3±8.2; medium 41.8±13.6 / 8.2±4.4 / 13.3±5.6; large 49.6±8.4 / 2.3±0.9 / 31.0±19.8; open 216.7±80.7 / 196.4±39.6 / 190.1±37.8. Dense — umaze-dense 72.7±10.1 / **−6.8±10.9** / 58.6±3.3; medium-dense 70.9±9.2 / 31.5±3.7 / 42.3±7.1; large-dense 90.9±19.4 / 45.3±11.2 / 62.2±9.9; open-dense 307.6±43.5 / 346.2±14.3 / 325.7±61.4. Text: "QDT clearly improves DT performance … It indicates that QDT brings the stitching capability to DT approach," but QDT is "still not as good as CQL."
  - *Gym-MuJoCo delayed reward (Table 3, p7):* CQL "struggles", DT is good, QDT ≈ DT; exception medium-replay-walker2d where QDT (29.6±15.5) < DT (51.6±24.6) because CQL over-estimates values there.
  - *Dense Gym (Table 4):* CQL and DT both fine; hopper-medium: CQL 69.4±13.1, DT 67.6±1.0 (ref), QDT 66.5±6.3.
  - Benchmark hygiene note (p9): the authors flag D4RL version mix-ups (v0 vs v2) and ≤3–5 seeds as sources of conflicting numbers across papers.
- **When DT works vs fails:** works when high-return trajectories exist (Gym-MuJoCo medium-expert-like data; DT ≈ CQL on dense Gym), fails where the optimal behaviour must be assembled from sub-optimal fragments (simple env, Maze2D) [paper].
- **Concluded vs misstated:** *Concluded:* relabelling RTG with DP estimates "brings the benefits of DP to reward-conditioning sequence models"; "there is room for improvement" (Conclusion p9). *Often mis-said* **[inferred]:** "Transformers can't stitch." The paper's mechanism is the *return-to-go label* (trajectory-level, behaviour-policy-dependent), and the fix keeps the same transformer.
- **Figures to reuse:** Fig 1 `https://arxiv.org/html/2209.03993v4/figs/simple_example_1.png` (arrows = rewards, node labels = RTGs; shows DT's RTG cannot reveal the short path); Fig 2 `https://arxiv.org/html/2209.03993v4/figs/results-preview-plots.png`; Fig 3 `…/figs/maze2d_view.png` (all HTTP 200 for the first two).

---

### 2.4 Emmons, Eysenbach, Kostrikov, Levine — "RvS: What is Essential for Offline RL via Supervised Learning?"

- **Reference:** arXiv **2112.10751** (v1 20 Dec 2021, v2 11 May 2022); **ICLR 2022** ("Published as a conference paper at ICLR 2022"). arXiv licence **CC-BY 4.0**. [paper]
- **Code:** `github.com/scottemmons/rvs`, MIT [paper Fig 1 caption; GitHub API].
- **Exact claim [abstract p1]:** "In every environment suite we consider, simply maximizing likelihood with a two-layer feedforward MLP is competitive with state-of-the-art results of substantially more complex methods based on TD learning or sequence modeling with Transformers. Carefully choosing model capacity (e.g., via regularization or architecture) and choosing which information to condition on (e.g., goals or rewards) are critical…" Intro (p2): "These simple results contradict the narrative put forward in many prior works that argue for more complex design decisions."
- **Method:** hindsight relabelling of a replay buffer to outcomes ω (goals or reward-to-go), MLP with two FC layers + dropout (Fig 2, p2).
- **Evidence — Table 1 (pp7), D4RL gym-v2 averages** (7 columns read as BC / Filt. BC / TD3+BC / Onestep / CQL-r / DT / RvS-R — column mapping **[inferred]** from per-row values that match known DT/TD3+BC numbers): gym-v2 average **39.6 / 56.2 / 58.2 / 61.4 / 63.0 / 57.0 / 54.7**; medium-expert average 71.7 / 104.3 / 99.6 / 102.2 / 99.1 / 100.8 / 100.0; medium-replay average 26.9 / 59.7 / 62.4 / 61.7 / 77.1 / 62.0 / 57.4. So RvS-R is **close to but not above DT** in Gym (the caption says "In Gym, RvS-R matches the performance of Decision Transformer while only using an MLP"). AntMaze average row (9 values): BC 16.7, Filt.BC 41.4, TD3+BC 27.3*, Onestep 20.9*, CQL-r 11.4, CQL-p 50.6*, DT 19.8, RvS-R 25.6, RvS-G 53.5 **[inferred column mapping]** — i.e. reward-conditioned DT/RvS-R are far below goal-conditioned RvS-G on stitching-heavy AntMaze. The Kitchen row has fewer columns populated and I could not map it reliably; RvS-G's Kitchen average appears as 54.0 (last value) **[inferred]** — check the PDF before quoting.
- **Capacity & regularisation (Fig 3, p5):** "The best-performing architectures are generally larger than the architectures used in standard online RL and imitation learning… RvS policies must represent both the optimal policy and policies for other conditioning values." Over/under-fitting is the main challenge. Fig 4: validation loss only loosely correlated with final performance on Kitchen.
- **Conditioning variable matters:** "RvS conditioned on rewards (RvS-R) performs worse at [AntMaze/Kitchen/GCSL], highlighting the importance of the conditioning variable"; goals (RvS-G) is state-of-the-art there (Table 1 caption p7).
- **Stitching (p8):** "such stitching is usually viewed as a key benefit of dynamic programming methods, so it is surprising that RvS-G performs as well as prior methods based on dynamic programming (TD3+BC and CQL)… We speculate that the spatial information encoded by goal information helps RvS-G generalize."
- **When DT/RvS works:** dense-ish reward Gym data of decent quality; goal-conditioned tasks with goals; with enough capacity + regularisation. **Fails/weaker:** reward-conditioned on tasks that need stitching (AntMaze, Kitchen) [paper].
- **Concluded vs misstated:** *Concluded:* the Transformer isn't essential for these suites; capacity/regularisation/conditioning variable are. *Often mis-said* **[inferred]:** "RvS beats DT" (Gym table shows parity, not a win) or "RvS proves RL via SL solves offline RL" (reward-conditioned variants lag on stitching tasks).
- **Figures to reuse:** Fig 2 (pipeline: replay buffer → hindsight relabel → MLP) PDF p2; Fig 3 `https://arxiv.org/html/2112.10751v2/figures/network-architecture-catplot_v4.png` (capacity × dropout heatmaps; HTTP 200); Fig 1 bar chart p1.

---

### 2.5 Bhargava, Chitnis, Geramifard, Sodhani, Zhang — "When should we prefer Decision Transformers for Offline RL?" (v1/v2 title: "Sequence Modeling is a Robust Contender for Offline RL")

- **Reference:** arXiv **2305.14550** (v1 23 May 2023, v2 26 May 2023, v3 11 Mar 2024); **ICLR 2024** (PDF header, v3). arXiv licence **CC-BY 4.0**. [paper]
- **Code:** paper p2 states `github.com/facebookresearch/rl_paradigm` — **that repo returns 404 via the GitHub API** (private/removed) → licence **[unverified]**.
- **Exact claim [abstract v3, p1]:** DT requires more data than CQL but is more robust; DT is the best choice in sparse-reward and low-quality-data settings; DT and BC preferable as task horizon increases or when data come from (suboptimal) human demonstrators; "CQL excels in situations characterized by the combination of high stochasticity and low data quality"; scaling data 5× gives 2.5× Atari score. (The v1 abstract had fewer qualifiers: "(2) Sequence Modeling is a substantially better choice than both Q-Learning and Imitation Learning in sparse-reward and low-quality data settings.")
- **Table 1 (p2):** a ✓/× robustness matrix of DT, CQL, BC against eight properties (sparse reward, best-X% data, worst-X% data, trajectory length, noise, horizon, state space, stochasticity). The ✓/× cells could not be aligned to their columns reliably in text extraction, so I do **not** transcribe them — read the matrix from PDF p2 or rely on the abstract's prose findings above.
- **Table 2 (p4), D4RL averaged over HalfCheetah/Hopper/Walker, columns inferred as DT-sparse / DT-dense / CQL-sparse / CQL-dense / BC:** medium-expert **103.15 / 103.64 / 29.36 / 105.39 / 47.72**; medium-replay **64.08 / 65.22 / 49.04 / 78.41 / 14.6**; overall average **76.6 / 77.51 / 40.78 / 83.64 / 38.74**. So with sparse reward DT (76.6) ≫ CQL (40.78) ≈ BC; with dense reward CQL (83.64) > DT (77.51).
- **Table 3 (p5), Robomimic MG (machine-generated) average:** DT sparse 88.2±1.6, dense 89.6±1.4; CQL 30±6.6 / 35.2±3.7; BC 57.2±6 (Lift: DT 93.2 / 96; CQL 60 / 68.4; Can: DT 83.2 / 83.2; CQL 0 / 2).
- **Data-quality sweeps (Fig 1, p6):** CQL is the most sample-efficient with a small amount of high-quality ("best X%") data but "could degrade with lower-quality data"; DT's performance "never worsened with more data".
- **Trajectory length (Table 4, p6):** on human-generated data **BC outperformed all** and all degrade with longer trajectories; contrast with Table 3 — data source matters.
- **Random data added (Fig 2, p7); state-space dimension and horizon (Fig 3, p8); Atari scaling (Fig 4, p8); architecture knobs (Fig 6, p14):** context length / heads help on Atari, not D4RL.
- **Stochasticity (Fig 5, p9):** added evaluation-time stochasticity on dense D4RL; "CQL demonstrated superior resilience compared to DT and BC. Building on the observation made by Paster et al. (2022)… DT's performance may hold up reasonably well with CQL in continuous action spaces when stochasticity is moderate and data is high-quality." (Exact deterioration percentages are in the figure; the bar labels I extracted could not be uniquely mapped, so they're omitted.)
- **When DT works:** sparse/delayed rewards, low-quality data, long horizons, machine-generated mixed data, enough data. **Fails/loses:** needs more data than CQL; CQL better with dense rewards and high stochasticity + low-quality data; BC better on small human data [paper].
- **Concluded vs misstated:** *Concluded:* a regime-dependent recommendation. *Often mis-said* **[inferred]:** the v1 title ("robust contender") is cited as "DT beats offline RL"; the v3 title and Table 2 (CQL 83.64 vs DT 77.51 dense) say otherwise. Always cite the version.
- **Figures to reuse:** Fig 1 (best/worst-X% data sweeps) PDF p6; Fig 5 (stochasticity) PDF p9; Table 1 matrix p2. HTML figure URLs for this paper were not exposed (`arxiv.org/html/2305.14550v3`: no `<img>` URLs extracted).

---

### 2.6 Siebenborn, Belousov, Huang, Peters — "How Crucial is Transformer in Decision Transformer?"

- **Reference:** arXiv **2211.14655v1** (26 Nov 2022, only version); "Foundation Models for Decision Making Workshop at NeurIPS 2022" (p1 footer). arXiv licence nonexclusive-distrib. [paper]
- **Code:** `github.com/max7born/decision-lstm`, MIT (GitHub API); description: "Codebase for the paper 'How Crucial is Transformer in Decision Transformer?'… Extension of the original Decision Transformer codebase". **[code]**
- **Exact claim [abstract]:** "DT struggles with continuous control problems, such as inverted pendulum and Furuta pendulum stabilization. On the other hand, the proposed Decision LSTM is able to achieve expert-level performance… These results suggest that the strength of the Decision Transformer for continuous control tasks may lie in the overall sequential modeling architecture and not in the Transformer per se."
- **Decision LSTM (Fig 1, p2):** replace GPT-2 by an LSTM, remove attention mask and positional embeddings, zero-init hidden/cell states (p3).
- **Evidence — Table 1 (expert data, 30 eval episodes, p4):** MuJoCo pendulum stabilisation — dataset 1000.00±0.00, DT **454.72±360.12**, DLSTM **985.31±71.96**, BC 61.61±170.16; OpenAI pendulum swing-up — dataset −207.53±167.75, DT −761.44±375.71, DLSTM −252.86±233.21, BC −235.78±204.45; Furuta stabilisation — dataset 5.95±0.02, DT **0.46±0.03**, DLSTM **5.93±0.01**, BC 1.82±1.60. (Fourth row, Furuta swing-up, was cut off in my extraction.) **Table 2 (replay data, p5):** OpenAI swing-up — dataset −837.35, DT −1083.78, DLSTM −569.89, BC −815.41; Furuta swing-up — dataset 1.56, DT 0.51, DLSTM 1.30, BC 0.89; "DLSTM is the only model which achieves better mean episode return than the average return of the training dataset." Fig 3 (learning curves + phase portraits): only DLSTM stabilises the Furuta pendulum; swing-up "not successful in every run."
- **Scope caveats [inferred]:** a workshop paper; low-dimensional pendulum tasks, one dataset family, single-digit environment count; real-hardware Furuta swing-up reported for DLSTM.
- **When DT works/fails:** fails on tight stabilisation/continuous control with expert data in these tasks; the paper does *not* show DT failing on D4RL (it doesn't test it).
- **Concluded vs misstated:** *Concluded:* sequence modelling formulation may matter more than attention. *Often mis-said* **[inferred]:** "LSTMs beat Transformers" or "attention is useless in DT". The claim is narrow (pendulum stabilisation/swing-up), and Emmons shows an MLP also suffices on D4RL — together they support "the formulation, not the architecture", not a general architecture ranking. Bhargava (Fig 6) finds context length / heads matter on Atari — the opposite direction on a different domain.
- **Figures to reuse:** Fig 1 `https://arxiv.org/html/2211.14655v1/img/architectures/decision_arch_comp.png`; Fig 3 phase portraits `https://arxiv.org/html/2211.14655v1/qube-swup-expert-final-models.png` (both HTTP 200).

---

### 2.7 Kumar, Hong, Singh, Levine — offline RL vs behavioural cloning (background theory)

- **Reference:** arXiv **2204.05618v1** (12 Apr 2022, only version); PDF header "Published as a conference paper at ICLR 2022"; arXiv title "When Should We Prefer Offline Reinforcement Learning Over Behavioral Cloning?". arXiv licence **CC-BY 4.0**. [paper] (Title discrepancy vs. the "Should I run…" wording — see §0.)
- **Code:** none found in the text I read. **[unverified]**
- **Exact claim [abstract p1]:** characterise "conditions on the MDP and dataset that are sufficient for offline RL to achieve better worst-case guarantees than even the best-case lower-bound for BC using the same amount of expert demonstrations" — e.g. "horizon-independent returns (i.e., sparse rewards) or a low volume of states where it is 'critical' to take the same action as the expert" (p2); and "in the case of sufficiently noisy data, offline RL again enjoys better guarantees" (p2). Experiments: gridworld diagnostics, robotic manipulation, maze navigation, Atari; "under specific but common conditions such as sparse rewards or noisy data sources, modern offline RL methods can outperform BC."
- **Theorems [pp4–5, 8]:** Thm 4.1 (BC) `SubOpt(π̂_β) ≲ (C*−1)H² + |S|Hι/N`; Thm 4.2 (conservative offline RL) `SubOpt ≲ √(C*|S|Hι/N) + C*|S|Hι/N`; Thm 4.3 (lower bound when C*=1, i.e. exact expert data) `≳ |S|H/N` — "BC achieves the lower bound up to logarithmic factors… we cannot improve over BC" in that case; Thm 4.4: one-step improvement is worse than k-step.
- **Relevance to DT:** DT/RCSL is a (return-)conditioned form of BC; Kumar's results explain *why* BC-like methods can be near-optimal on expert data and why RL helps under noisy data / long horizon. It does not evaluate DT. **[inferred]** Bhargava Table 3/4 (BC best on small human-demonstration data; CQL not) is consistent with this.
- **Misstated risk [inferred]:** citing Kumar as "evidence DT fails" — it contains no DT experiments (DT appears only in the references).

---

## 3. Cross-paper synthesis: when does DT / return-conditioning work?

Collect these as a decision table in the lesson **[inferred synthesis of the cited results]**:
| Condition | Works | Fails | Evidence |
|---|---|---|---|
| Dynamics | near-deterministic | stochastic where return is luck-dependent | Brandfonbrener Thm 1 / Fig 1; Paster Fig 1, Thm 2.1, Fig 3 (DT −0.02 on gambling) |
| Conditioning value | covered by data, known (V*) | OOD or unknown target | Brandfonbrener Cor. 2, Thm 1 |
| Data composition | high/medium-quality trajectories with the good behaviour present | optimal behaviour only obtainable by combining fragments | Brandfonbrener App. B/Fig 9; Yamagata Table 1–2; Emmons antmaze |
| Reward density | sparse/delayed (DT robust, CQL brittle) | – (dense: CQL ≥ DT) | Bhargava Table 2–3 |
| Horizon | long (DT, BC fine) | exponential sample complexity if good returns exponentially rare | Bhargava Fig 3; Brandfonbrener Fig 2–3 |
| Architecture | MLP with capacity+dropout often enough | undersized/under-regularised | Emmons Fig 3; Siebenborn |
| Stochasticity level | moderate + high-quality data (DT ≈ CQL) | high stochasticity + low-quality data (CQL better) | Bhargava Fig 5 vs Paster |

Bridge back to Part 1 **[inferred]**: policy-gradient methods optimise expected return directly with a baseline/advantage (REINFORCE/GAE/PPO), so they average over environment luck by construction; return-conditioned SL instead learns `P(a|s, realised return)`, which is exactly the object Paster shows is contaminated by luck (the Bayes calculation in §2.2 is a 4-line analogue of importance-weighting that REINFORCE *does* do correctly).

---

## 4. Official figures to reuse — consolidated

| Paper | Fig | URL | Caption (short) | What it teaches |
|---|---|---|---|---|
| PPO | 1 | PDF p3, `arxiv.org/pdf/1707.06347v2` | "Plots showing one term… of L^CLIP as a function of r, for positive advantages (left) and negative (right)" | flat region ⇒ no incentive to move ratio |
| PPO | 2 | PDF p4 | surrogate objectives vs interpolation; KL≈0.02 at maximum | clipped objective is a pessimistic bound |
| GAE | 2 | https://arxiv.org/html/1506.02438v6/cartpole-grid.png | cart-pole λ sweep + γ×λ grid | bias/variance sweet spot |
| Brandfonbrener | 1a–c, 2, 8 | PDF pp4, 6, 14 | tiny MDPs: stochastic failure; exponential sample complexity; stitching failure | every assumption has a counter-example |
| Brandfonbrener | 3 | https://arxiv.org/html/2206.01079v3/gridworld.png | RCSL fails under ring-of-fire/sparse, generalises on dense | reward shape matters |
| Brandfonbrener | 9 | https://arxiv.org/html/2206.01079v3/stitch-easy-data.png | stitch-easy / stitch-hard | DT (history) fails, RvS partly succeeds |
| Paster | 1 | PDF p3 | gambling env + conditioned-return table | "lucky return" confound |
| Paster | 2 | https://arxiv.org/html/2205.15967v2/algo.png | ESPER three phases | fix: condition on expected return |
| Yamagata | 1 | https://arxiv.org/html/2209.03993v4/figs/simple_example_1.png | RTG numbers on arrows; DT misses shortest path | RTG labels block stitching |
| Yamagata | 2 | https://arxiv.org/html/2209.03993v4/figs/results-preview-plots.png | CQL vs DT vs QDT | – |
| Emmons | 3 | https://arxiv.org/html/2112.10751v2/figures/network-architecture-catplot_v4.png | capacity × regularisation | architecture size/dropout matter |
| Siebenborn | 1 | https://arxiv.org/html/2211.14655v1/img/architectures/decision_arch_comp.png | DT vs Decision LSTM | swap the sequence model, keep everything else |
| Bhargava | 1, 5 | PDF pp6, 9 | best/worst-X% data; stochasticity | regime dependence |
All HTML image URLs above returned HTTP 200 (HEAD) on 2026-11-20. Licences: arXiv "nonexclusive-distrib" for PPO, GAE, TRPO, A3C, Brandfonbrener, Paster, Siebenborn, DT; **CC-BY 4.0** for Yamagata, Bhargava, Emmons, Kumar. For the non-CC-BY papers, redraw/re-implement the figure and cite instead of copying.

---

## 5. Suggested lesson hooks (all derivable from verified material)
1. Re-run §1.6 GAE table; slider on λ (0 → 1 interpolates the λ=0 and λ=1 columns exactly).
2. Slider on ε with the 3-sample PPO table; show which samples have zero gradient.
3. Paster gambling MDP as a live Bayes calculator (behaviour mix ↔ P(a|r)); "more data" button does nothing.
4. Stitching toy (Brandfonbrener Fig 8 / Yamagata Fig 1): RTG labels vs a `max(R, V̂)` relabel.
5. Cross-paper table (§3) as a "which regime am I in?" selector.

---

## 6. Re-run snippet for the §1.6 / §2.2 numbers
The full script used (NumPy + `fractions`) is reproduced in the two code blocks above; the outputs reproduced exactly: δ = [0.094, 1.192, −0.404, 1.897]; Â(λ=0.95) = [2.435855, 2.490011, 1.380128, 1.897]; L^CLIP mean 0.5833; P(a|r=1) = {a1: 1/3, a2: 2/3}, value −1/6.

---

## 9. Not verified / open questions

**Sources not readable / not verified**
- **Williams 1992** (Springer BF00992696): Springer returned HTTP 406 (web) and an invalid PDF; the UMass-hosted PDF (`www-anw.cs.umass.edu/~barto/courses/cs687/williams92simple.pdf`) extracts as garbled font-encoded text. All REINFORCE statements are second-hand via Sutton et al. 1999 and Schulman 2015. Williams's own baseline discussion/theorem numbering therefore not quoted.
- **OpenAI "ACKTR & A2C" blog** (A2C definition): HTTP 403 — A2C description is **[inferred]** + PPO paper Table 2.
- **TRPO venue (ICML 2015), A3C venue (ICML 2016), DT venue (NeurIPS 2021)**: stated from memory, not read in the PDFs I extracted.
- **PPO paper**: arXiv HTML is a stub (page images only), so figures can only come from the PDF. Eq. 10–11 exponents look off-by-one (see §1.3). PPO's own code (`openai/baselines` `da99706`, `ea25b9e`) was **not opened by me** — only the blog's description/permalinks, CleanRL and Spinning Up.
- **37-details blog**: the 5 LSTM item titles and the exact text of each of the 37 detail explanations were not individually read; I extracted titles/code references and the count structure only. I did not read "Recommendations" or "Results" sections.
- **Code availability**: QDT (no official repo found), Paster/ESPER (Google Sites only; no repo/licence), Bhargava (`facebookresearch/rl_paradigm` → 404), Kumar (none found). Siebenborn's repo is the author's personal account (`max7born`), identified from its README description, not from the paper text.
- **DT evidence**: I did not extract the DT paper's own result tables; claims about it are limited to its abstract.

**Table-parsing caveats**
- Emmons Table 1 and Bhargava Table 1/2: column headers dropped in text extraction; mappings above are inferred from per-row numbers/known values and Table 3 headers. Check against the PDF before quoting numbers in the lesson (Emmons p7, Bhargava p4).
- Bhargava Fig 5 deterioration percentages could not be mapped to bars; omitted.
- Siebenborn Table 1 fourth row (Furuta swing-up expert) not captured.
- Brandfonbrener Fig 8's state labels are partially garbled in the text extraction (e.g. which of s_1/s_2 is reached by which action); the verbal conclusion (≤0.5 optimal probability under standard conditioning) is quoted faithfully, but redraw the diagram from the PDF p14, not from my paraphrase.

**Open research questions for the lesson**
1. Does the Paster failure persist with DT's autoregressive full-history conditioning when the *return-to-go is decremented* during rollout? (Brandfonbrener notes DT-style conditioning includes history; Paster's theorem is stated for history-conditioned policies, so yes in theory — **[inferred]**, no experiment run here.)
2. How much of Bhargava's DT-vs-CQL gap is hyper-parameter budget (Brandfonbrener tune 4 values; Bhargava report different tuning)? Neither paper isolates this.
3. Is QDT's relabelling stable when the value estimate over-estimates (their own walker2d-medium-replay failure)?
4. Newer sequence-model-RL work (e.g. Q-value-conditioned/ "Elastic DT", etc.) is outside the brief and not covered.
