How do you measure whether a learned reward function is right? Not by training a policy on it — that conflates reward error with optimiser failure. EPIC compares reward functions directly, while ignoring the ways two rewards can differ on paper but mean the same thing in practice. Written as a self-contained chapter: worked numbers throughout, verify everything by hand.
Read this before: any experiment that reports “how good is the recovered reward?” — including the continuous-action work in continuous-action-extension-directions.
1. The problem: reward functions are not their numbers
Suppose the ground-truth reward for a navigation task is +1 for reaching the goal. Your IRL algorithm returns +100 for reaching the goal.
Measure the difference numerically — say distance — and you get an enormous error. But the two rewards induce literally the same optimal policy under every transition dynamics. Your algorithm was correct and your metric lied.
This is the Celsius/Fahrenheit problem. 20 °C and 68 °F are different numbers and the same temperature. Comparing reward functions naively is comparing the numerals and ignoring the units.
The alternative that also fails
The obvious fix is to train a policy on the learned reward and see how well it does under the true reward. This is what the field did before EPIC, and it has two defects:
- It confounds two failures. A bad score could mean the reward is wrong, or it could mean RL failed to optimise a perfectly good reward. You cannot tell which.
- It only tests one environment. A reward can look fine in the training environment and incentivise catastrophic behaviour in a slightly different deployment environment. Policy-based evaluation cannot see this.
Both defects matter for alignment specifically: a reward model that scores well on-distribution and misgeneralises off-distribution is exactly the failure mode we want an evaluation to catch, not hide.
EPIC’s move is to compare and as functions, with no policy optimisation anywhere in the pipeline — but to do the comparison in a coordinate system where the meaningless differences have been quotiented away.
2. The two invariances
Two rewards induce the same optimal policy — under every transition dynamics — if they differ by these two transformations:
2.1 Positive affine transformation
Scale everything up, shift everything by a constant. Every policy’s return is transformed monotonically, so the ranking over policies is untouched. This is the Celsius/Fahrenheit case.
2.2 Potential shaping (Ng, Harada & Russell, 1999)
This one is subtler, and it is the reason EPIC needs machinery rather than just a correlation.
Pick any function assigning a number to each state. Define
Why does this preserve behaviour? Sum the added terms along a trajectory , with discounting:
Everything telescopes. The interior terms cancel in a chain. So the total added reward depends only on where you started and where you ended — not on the route. Every path from to shifts by the same amount, so the ranking of paths is preserved exactly.
The intuition
Shaping is a loan against future reward. is a “you’re doing well” bonus paid out for entering a state, and immediately clawed back when you leave it. Over any complete journey the loans net out. You can move reward earlier in time — which is genuinely useful for RL training speed — without changing what is being rewarded.
2.3 Worked example — a shaped reward that looks nothing like the original
Three states in a line, goal at C:
graph LR A((A)) -->|R| B((B)) B -->|R| C((C, goal)) B -->|L| A C -->|L| B
True reward : whenever , else .
Shaping potential: , with .
Shaped reward :
| transition | |||
|---|---|---|---|
| A →R→ B | 0 | +5 | |
| B →R→ C | 1 | +6 | |
| B →L→ A | 0 | −5 | |
| C →L→ B | 0 | −5 | |
| C →R→ C | 1 | +1 |
looks like a completely different objective: it pays out lavishly for moving right and punishes moving left, whereas is indifferent to everything except arriving at C.
Now total up any route from A to C:
- A→B→C: gives ; gives .
- A→B→A→B→C: gives ; gives .
Always exactly 10 more, on every route, because . Identical rankings, identical optimal policy.
is large. The right answer is that the distance is zero.
3. The pipeline
graph TD R1["R₁ raw"] --> C1["canonicalise C(R₁)"] R2["R₂ raw"] --> C2["canonicalise C(R₂)"] C1 --> P["Pearson correlation ρ over coverage distribution 𝒟"] C2 --> P P --> D["d = √((1−ρ)/2) ∈ [0,1]"] style C1 fill:#e8f0fe style C2 fill:#e8f0fe style P fill:#fef3e8 style D fill:#e8f6ec
| step | kills which invariance | mechanism |
|---|---|---|
| 1. Canonicalise | potential shaping | map each reward to a fixed representative of its shaping class |
| 2. Pearson | positive affine | correlation is invariant to , |
| 3. | — | turns a similarity into a genuine metric |
4. Step 1 — Canonicalisation, in full
4.1 The definition
where and are drawn independently of each other and of the transition being evaluated. Lowercase letters are the fixed inputs; capitals are random.
Stare at this and it looks arbitrary. It isn’t. Define
Read as: “sitting in state , if something random happens, what reward do I get on average?” It is a crude one-step goodness score for each state, computed from alone — no policy, no dynamics, no value iteration. Write .
Substituting the three expectations:
The key structural fact
Canonicalisation applies a potential shaping to , using a potential that itself determines.
That self-reference is the whole trick. Hand it a shaped version of , and the computed from that shaped version differs in precisely the way needed to undo the shaping. It’s a normalisation that finds its own zero point.
4.2 Proof that shaping cancels
Let , and let .
First, how does transform?
Note the term. That is the piece that will do the cancelling. Averaging again:
Now expand :
Collect terms:
| term | from | cancels against |
|---|---|---|
| in line 2 | ||
| in line 3 | ||
| line 2 | in line 4 | |
| line 3 | in line 4 |
Everything involving dies. What survives:
Exactly equal — for any , any , any sampling distributions. Two rewards differing by shaping collapse onto the identical canonical form.
4.3 Numerically, on the three-state example
Take and .
For ( iff ): since depends only on the destination and is drawn independently of ,
(The terms cancel because is constant here.) So:
For (the shaped one), , so :
Now check individual entries against , using (with ):
| transition | ||||||
|---|---|---|---|---|---|---|
| B →R→ C | ✓ | |||||
| A →R→ B | ✓ | |||||
| C →L→ B | ✓ |
Two rewards that looked utterly unrelated — one paying where the other pays — land on identical canonical forms. This is the payoff.
Do this by hand once
Working the B→R→C row on paper is the single most useful five minutes for internalising EPIC. .
5. Step 2 — Pearson correlation
Canonicalisation killed shaping. It did not kill scaling: the operation is linear in , so
(the constant washes out entirely, and passes straight through). Correlation handles the leftover, since for any .
Mechanically: pick a coverage distribution over transitions, sample a batch, evaluate both canonical rewards on each sampled transition, correlate the two resulting columns.
Two different distributions, don't conflate them
- (§4) control how you canonicalise — they define .
- (here) controls where you compare — which transitions enter the correlation.
They serve different roles and can be chosen independently. Both are free parameters, and §8 is about why that matters.
5.1 A non-zero distance, computed end to end
Introduce iff — “go to B instead of C”, a genuinely different objective. By the same symmetry argument, .
Take uniform over all triples. Both canonical rewards depend only on , and each value of covers 6 triples, so each carries probability :
| A | |||
| B | |||
| C |
Means: , likewise .
Canonical rewards come out already centred under — that is what the term was for. In general (mismatched ) they won’t be, and Pearson subtracts the means anyway.
Covariance:
Variance:
Correlation:
Negative — which is right. “Reach B” and “reach C” actively disagree: each rewards a state the other treats as ordinary.
6. Step 3 — Correlation to distance
For our pair: . Large, as it should be.
6.1 Why this formula and not just
Because it is genuinely a metric, and there is a clean geometric reason.
Centre both canonical rewards and normalise them to unit length in the -weighted inner product, giving on the unit sphere. Then , and
The geometric picture
EPIC is half the straight-line (chord) distance between two points on a unit sphere.
Every reward function is projected onto that sphere: canonicalisation picks the representative, centring-and-normalising puts it on the surface. Rewards in the same equivalence class map to the same point.
ρ = 1 ρ = 0 ρ = −1
X̂ = Ŷ X̂ ⊥ Ŷ X̂ = −Ŷ
● ● ●
╱ ╲ ╱│╲ ╱ ╲
╱ ╲ ╱ │ ╲ ● ╲
│ ● │ │ ●──● │ │ ↕ │
╲ ╱ ╲ ╱ ╲ ●
╲ ╱ ╲ ╱ ╲ ╱
● ● ●
d = 0 d ≈ 0.707 d = 1
Scale reference points:
| interpretation | ||
|---|---|---|
| equivalent — same optimal policy everywhere | ||
| fairly similar | ||
| unrelated | ||
| actively disagreeing (our vs ) | ||
| exact opposites |
Because it is a scaled Euclidean distance on a sphere, the triangle inequality is inherited for free. It is a pseudometric rather than a metric only because distinct-but-equivalent rewards map to the same point — does not imply . That is the design goal, not a defect.
7. The three checks, together
| pair | why | ||
|---|---|---|---|
| vs | canonical forms identical | 0 ✓ | |
| vs | is linear, scale-free | 0 ✓ | |
| vs (goal at B) | genuinely different objective | 0.87 ✓ |
Compare against what would have told you: large, large, and moderate — wrong, wrong, and uninformative.
8. The regret bound (why the number means something)
Without a theorem connecting to behaviour, this would just be a heuristic that happens to be invariant. The headline result:
Low EPIC distance implies low regret. If is small, then a policy optimal under has bounded regret when evaluated under — and the bound holds even under different transition dynamics than those used to compute the distance.
That last clause is the interesting one, and it follows from EPIC being deliberately dynamics-independent. It addresses the second defect from §1: a low EPIC distance is evidence about deployment environments you never tested in.
The bound scales with the magnitude of the rewards and with how well covers the transitions the relevant policies actually visit.
Flags to check before citing this in the thesis
- Get the exact constants and coverage conditions from §4 of the paper — restated qualitatively here.
- The implication runs one way. Low EPIC ⟹ low regret. High EPIC does not imply high regret; it may just mean the two rewards disagree on transitions nothing ever visits.
- Per the STARC authors, the bound covers only optimal policies, not arbitrary policy pairs. See §10.
9. Computing it in practice
def epic_distance(R1, R2, transitions, states, actions, gamma):
"""
R1, R2 : callables (s, a, s') -> float
transitions : sampled batch ~ 𝒟 (coverage)
states : sampled batch ~ 𝒟_S (canonicalisation)
actions : sampled batch ~ 𝒟_A (canonicalisation)
"""
def canonicalise(R):
# Ψ(s) = E_{A,S'}[R(s, A, S')]
psi = {s: mean(R(s, a, sp) for a in actions for sp in states)
for s in set(states) | set(all_states_in(transitions))}
psi_bar = mean(psi[s] for s in states)
return lambda s, a, sp: (R(s, a, sp)
+ gamma * psi[sp]
- psi[s]
- gamma * psi_bar)
C1, C2 = canonicalise(R1), canonicalise(R2)
x = np.array([C1(s, a, sp) for (s, a, sp) in transitions])
y = np.array([C2(s, a, sp) for (s, a, sp) in transitions])
rho = np.corrcoef(x, y)[0, 1]
return np.sqrt((1 - rho) / 2)Cost: reward evaluations to build , plus for the correlation. No policy optimisation, no value iteration, no environment rollouts. This cheapness is the entire practical argument for the method.
Reference implementation: HumanCompatibleAI/evaluating-rewards.
10. Where it breaks, and the successors
10.1 The impossible-transition problem
Look again at the canonicalisation: it evaluates where and are drawn independently. In our three-state chain, that includes asking for the reward of going directly from A to C — a transition the dynamics never permit.
EPIC evaluates rewards on all state–state combinations regardless of whether those transitions are physically possible. A learned reward network will happily output something for such inputs — arbitrary extrapolation from a region it was never trained on. Those arbitrary numbers then enter , and hence every canonical value.
In a three-state gridworld you can enumerate everything and it hardly matters. In a high-dimensional continuous space, the fraction of sampled pairs that are dynamically reachable can approach zero.
This is a deliberate trade, not an oversight: independence from dynamics is what buys the cross-dynamics regret bound in §8. You cannot have both.
10.2 Sensitivity to
Both the canonicalisation distributions and the coverage distribution are free choices, and the number moves when you move them. EPIC is more robust to this than the baselines it was compared against — but “more robust” is not “insensitive”. Report your distributions alongside any EPIC number, or the number is not reproducible.
10.3 Successors
| method | fix | trade-off |
|---|---|---|
| DARD (Wulfe et al., ICLR 2022) — Dynamics-Aware Reward Distance | canonicalises using the actual transition dynamics, so rewards are only evaluated on reachable transitions | tighter when dynamics are known; no regret bound derived, and loses the cross-dynamics guarantee |
| STARC (Skalse et al., ICLR 2024) | generalises the canonicalise → normalise → compare recipe into a whole family; bounds in both directions | also dynamics-dependent; more machinery |
STARC’s specific criticisms of EPIC, worth knowing before you cite EPIC as the standard: the regret bound is weaker and less general, it covers only optimal policies rather than arbitrary policy pairs, and they argue EPIC’s notion of regret does not capture what practitioners actually care about. Appendix A of the STARC paper is an extended analysis of EPIC and is probably the best critical reading available.
11. Relevance to the thesis
Direct, on two fronts — see thesis-hub and continuous-action-extension-directions.
Why it fits Bayesian IRL particularly well. The invariances EPIC quotients out are exactly the directions the BIRL likelihood cannot see:
- Shaping is unidentifiable from demonstrations by construction. The expert behaves identically under and from §2.3, so no quantity of data separates them. A metric that penalises this is penalising the method for failing at something provably impossible.
- Scale is entangled with the rationality parameter. In the Boltzmann model , a large reward with small is observationally identical to a small reward with large . See ramachandran-2007-bayesian-irl. EPIC’s affine invariance handles this directly.
Why it fits Bayesian IRL, not just IRL. Because there is no policy optimisation, EPIC is cheap enough to evaluate per posterior sample. Instead of one number for a point estimate, you get a distribution of EPIC distances across the ValueWalk / MCMC posterior. That is the right object for calibration claims — you can ask whether posterior spread in EPIC space tracks actual error, which point-estimate metrics simply cannot express.
The continuous-action complication. Both expectations defining become integrals requiring Monte-Carlo approximation:
- over an unbounded or high-dimensional continuous action space is a genuine modelling decision, not a uniform-over--actions default. Uniform over a box? Gaussian around the expert’s action? Under the learned policy?
- §10.1 bites much harder here: the impossible-transition fraction is far worse in continuous state spaces than in a 3-state chain.
- Monte-Carlo error in propagates into every canonical value. Estimator variance needs a budget of its own.
- This may make DARD the better default for the continuous experiments — worth an explicit decision rather than defaulting to EPIC because it is better known.
Relevant neighbours for baselines: AVRIL, IQ-Learn, DistIRL.
12. Exercises
- Telescoping. Verify by hand that the shaped total for path A→B→A→B→C equals 11, matching the direct-route total. Now change to and confirm both totals are still equal to each other.
- Canonicalisation is idempotent. Show . (Hint: what is of an already-canonical reward?)
- Constant rewards. What is when ? What does that imply about between two constant rewards, and why is that degenerate case unavoidable?
- Sensitivity. Recompute the vs distance with restricted to only the transitions the shortest path A→B→C visits. Does the number change? What does that tell you about §10.2?
- Negative scaling. EPIC is invariant to . Construct a two-state example showing why must not be treated as equivalent.
- Continuous-action estimator. For a 1-D action space and , write in closed form under . Then compare against a 10-sample Monte-Carlo estimate and characterise the variance.
13. References
Primary
- Gleave, Dennis, Legg, Russell & Leike (2021). Quantifying Differences in Reward Functions. ICLR 2021. arXiv:2006.13900
- Code: github.com/HumanCompatibleAI/evaluating-rewards
Foundational
- Ng, Harada & Russell (1999). Policy Invariance Under Reward Transformations. ICML. — origin of potential shaping and the proof that it preserves optimal policies.
Successors
- Wulfe et al. (2022). Dynamics-Aware Comparison of Learned Reward Functions (DARD). ICLR 2022. arXiv:2201.10081
- Skalse et al. (2024). STARC: A General Framework For Quantifying Differences Between Reward Functions. ICLR 2024. arXiv:2309.15257
Open questions for Ondřej (advisor)
- Is EPIC the metric the QVIRL/ValueWalk line already reports, or does the group use something else for reward recovery?
- For the continuous-action extension: EPIC or DARD as the primary metric? The impossible-transition issue (§10.1) seems considerably worse in continuous state spaces, but DARD gives up the regret bound.
- Is per-posterior-sample EPIC (§11) something that has been done in the BIRL literature, or would reporting the distance distribution be a small novel contribution in itself?
- How much does the group weight the STARC critique — is EPIC still the community default in 2026, or has the field moved?