Credit Assignment in Reinforcement Learning

The credit assignment problem is a long-standing issue in reinforcement learning: determining which past actions actually caused a future reward. Here are notes on two papers addressing this problem:

Synthetic Returns for Long-Term Credit Assignment

1-step TD learning struggles when rewards are heavily delayed or when uncontrollable events occur between an action and its eventual reward. Combining synthetic returns with an IMPALA agent solves Atari Skiing (notorious for delayed rewards) 25x faster than the prior state of the art.

State-associative learning: The goal is to learn associations between pairs of states such that an earlier state is predictive of a future reward and timestep. This lets the algorithm construct a synthetic return connecting the reward back to the earlier state by skipping intermediate timesteps.

Door-key example: To open a door and receive a reward, the agent must first pick up a key. Credit should be assigned to picking up the key; otherwise, 1-step TD receives zero reward signal at the key-pickup transition and requires many samples to propagate credit backward.

Reward prediction loss (Eq. 1): A gating function \(g(s_t)\) softly gates the sum over outputs \(c(s_k)\) for \(T\) previous states, with a baseline \(b(s_t)\) subtracted. Because the environment is partially observable, \(s_t\) here is the agent’s internal recurrent state summarizing history rather than the raw observation. Note that there is no explicit notion of causality — only temporal association. The final augmented reward used for RL is:

\[\hat{r}_t = \alpha\, c(s_t) + \beta\, r_t\]

The intuition for summing over \(c(s_k)\) is that reward prediction is cast as a regression problem where past states contribute sparsely (hence the gating mechanism \(g(s_t)\)). The hyperparameters \(\alpha\) and \(\beta\) trade off the inductive bias of 1-step TD (temporal recency) against the synthetic return.

Summary / Discussion: Calling \(c(s_k)\) a “synthetic return” is a slight misnomer — it acts more like a synthetic reward. Because of the multiplicative gates and additive regression, they cannot offer general convergence or optimal credit-assignment guarantees in the main formulation (though they discuss state-associative variants in the appendix), and the method exhibits noticeable variance across seeds. In the appendix, they also note that reward contributions in the summation may be double-counted, meaning reward is not strictly conserved.

Counterfactual Credit Assignment

Key idea: Condition value-function baselines on future events by learning to extract policy-independent information from a trajectory.

Policy Gradient & Future-Conditional Baselines

Starting from REINFORCE, the likelihood of an action is increased proportionally to the return \(G_t\) from timestep \(t\), with a baseline \(V(X_t)\) subtracted to reduce variance without introducing bias. Normally, \(V(X_t)\) cannot depend on future observations — Weber et al. (2019) showed that including variables causally dependent on the action \(A_t\) biases the gradient estimator.

Hindsight reasoning vs. luck: Imagine a team game where a weak agent plays alongside a strong teammate. The team wins, but the weak agent shouldn’t reinforce all of its actions if they didn’t contribute to the win. Buesing et al. (2019) showed that hindsight information is helpful in model-based settings; this paper brings hindsight conditioning to model-free RL.

Future-conditional PG (Theorem 1): A baseline \(V(X_t, \phi_t)\) can be conditioned on a future statistic \(\phi_t\) without bias if weighted by an importance correction ratio \(\frac{\pi(A_t \mid X_t)}{p(A_t \mid X_t, \phi_t)}\), provided the denominator is non-zero (meaning \(\phi_t\) cannot completely reveal or determine the action taken).

CCA-PG (Theorem 2): Importance weighting can increase variance, so the paper instead enforces conditional independence between the action and the hindsight statistic: \(p(a \mid X_t, \phi_t) = \pi(a \mid X_t)\), making the ratio equal to \(1\). Under this condition, the variance of Counterfactual Credit Assignment (CCA-PG) is at most that of the classical policy gradient, with zero bias.

Estimating \(\phi_t\) (Theorem 3): Consider a trajectory-level variable \(Y_t\) known in hindsight, generated by a latent variable \(\epsilon_t\) satisfying \(\epsilon_t \ind A_t\):

\[p(Y_t \mid A_t, X_t) = \int p(\epsilon_t \mid X_t)\, p(Y_t \mid X_t, A_t, \epsilon_t)\, d\epsilon_t\]

Sampling a single \(\phi_t\) from the posterior \(p(\epsilon_t \mid A_t, X_t, Y_t)\) recovers the conditional independence properties of the prior (though a collection of samples would not).

Model-free approach to learning CCA: Two objectives guide training:

  1. \(V(X_t, \phi_t)\) should be predictive of the return.
  2. \(\phi_t\) should be conditionally independent of \(A_t\) given \(X_t\), enforced by minimizing the KL divergence between action classifiers \(p(A_t \mid X_t)\) and \(p(A_t \mid X_t, \phi_t)\) (which is \(0\) iff \(A_t \ind \phi_t\)).

Practical implementation: Uses an RNN for POMDPs, a hindsight network to predict \(\phi_t\), and a hindsight predictor outputting a distribution over \(A_t\) to enforce conditional independence.

Counterfactual Credit Assignment architecture

Connections to Causality

Assume the MDP is generated by a structural causal model (SCM) where the return \(G_t\) is a deterministic function \(f(X_t, A_t, \mathcal{E})\), with exogenous variables \(\mathcal{E}\) capturing factors that \(A_t\) cannot influence but that affect the return. The agent does not observe \(\mathcal{E}\) directly, so it implicitly estimates them via \(\phi_t\) — maximizing information about the outcome while minimizing information about \(A_t\).

Counterfactual distributions differ from interventional distributions because we hold the exogenous variables fixed (“what would have happened had I acted differently under the same conditions?”):

Theorem 4 (Identifiability): Under faithfulness and conditional independence of \(\phi_t\), the counterfactual distribution is identifiable from samples of \((X_t, \phi_t, A_t)\), and the expected return under this distribution equals \(Q(X_t, A_t, \phi_t)\). Of course, in practice this depends on how accurately \(\hat{\phi}_t\) is estimated.