research29 min studyLesson 648 in Engineering

Reward transformations: stabilize scales without hiding the objective

Separate fixed scaling, duration-dependent offsets, potential shaping, and proxy failures while preserving raw evaluation signals.

On this page

What you’ll understand

  • Identify when reward transformations preserve a pure-return ranking.
  • Derive a finite potential-shaping telescoping sum with endpoint conditions.
  • Separate improved proxy reward from intended task success.

A reward-normalization wrapper can improve numerical behavior while also changing what a policy is rewarded for. Fixed positive scaling, changing running statistics, per-step offsets, clipping, and potential-based shaping have different semantics. A proxy can also be exploited even when the transformation code is correct. We use finite return calculations and the original potential-shaping theorem’s structure to make the conditions visible. No normalization method or reward model supplies a universal guarantee that optimization improves the task people actually intended.

Scaling and offsets have different invariance conditions

A fixed positive scale multiplies a pure expected-return objective and preserves its policy ordering when the underlying task, discount, initial distribution, and evaluation convention remain unchanged. It can still change optimization dynamics, gradient clipping, and the relative influence of unchanged entropy, KL, or auxiliary coefficients. An online normalization statistic is not simply one fixed scale: its state depends on data and time. Version and checkpoint that state, define whether evaluation freezes it, and log raw rewards alongside transformed training signals.

Adding a constant per step can favor different episode durations, because a longer trajectory accumulates the offset more times. With a fixed policy-independent horizon and the same discount convention, the offset contribution can instead be a policy-independent constant; the condition matters. Nonlinear clipping or task-dependent scales can change rankings and mixture weights. Do not describe every reward wrapper as harmless numerical normalization. Derive the transformed return for at least one short and one long trajectory before interpreting a learning curve in the new units.

G′=aG+b∑t=0T−1γt(a>0)G^{\prime}=aG+b\sum_{t=0}^{T-1}\gamma^t\qquad(a>0)
For the per-step affine transformation r′=ar+b over a finite episode of length T and common discount γ, returns use compatible transformed units. Positive a preserves pure-return ranking when b=0; the offset term can depend on policy through episode length. Other objective terms are not automatically scaled.↔ Scroll wide equations horizontally.

Potential shaping needs the endpoint argument

Potential-based shaping adds a term derived from the same discount and a potential difference between successive task states. Its discounted sum telescopes, exposing both the initial potential and a finite endpoint term. Under appropriate conditions, such as a fixed initial distribution and zero potential at task terminal states, that endpoint contribution does not change policy ordering. For infinite discounted tasks, bounded potentials and discount strictly below one give another familiar vanishing-tail argument. State which condition is being used rather than quote policy invariance without its boundary assumptions.

External truncation is especially easy to mishandle: it is not automatically a task terminal state where a potential can be discarded. A bootstrap target and shaping convention must account for the continuing tail consistently. Shaping on reset observations can add an unintended transition between episodes. Partial observations, learned potentials, and changing reward models require further analysis rather than a blanket transfer of the state-based fixed-potential result. Keep the potential version and task boundary contract with the experiment so evaluation can reconstruct which objective was optimized.

∑t=0T−1γt(γΦ(st+1)−Φ(st))=−Φ(s0)+γTΦ(sT)\sum_{t=0}^{T-1}\gamma^t\bigl(\gamma\Phi(s_{t+1})-\Phi(s_t)\bigr)=-\Phi(s_0)+\gamma^T\Phi(s_T)
This finite telescoping identity assumes the same fixed potential Φ and discount on consecutive task states. A policy-invariant conclusion needs additional endpoint and initial-state conditions; the identity alone does not remove a policy-dependent terminal term or justify a changing learned potential.↔ Scroll wide equations horizontally.

A correct reward pipeline can still optimize the wrong proxy

A simulated assistant rewarded for tool-call count may learn unnecessary calls, while a robot rewarded only for forward motion may exploit a simulator artifact. Those are objective-specification failures rather than evidence that the optimizer misunderstood the scalar reward. Separate raw task outcomes, constraints, and independent audit metrics from the training proxy. Evaluate adversarial cases and distribution shifts where the proxy and intended goal can diverge. Reward-model agreement or a larger transformed return is not sufficient evidence of useful or safe behavior.

The function lab illustrates only a fixed coefficient scale. Reset, explicitly set coefficient one and position two, predict y, then Play or Step. Compare a fresh Reset with coefficient 0.5 and position two explicitly set; y changes from four to two. This scales a fixed parabola and has no episodes, reward offsets, changing normalization state, shaping potential, or proxy optimization. Use the return calculations and independent task evaluation to test those distinctions rather than treat an unchanged-looking curve shape as policy invariance.

A per-step bonus can reverse an episodic preference

Use undiscounted finite episodes. Policy A ends after one step with reward two. Policy B ends after three steps with rewards [0,0,1]. Compare raw returns, then add one reward unit to every executed task step.

  1. Raw return is two for A and one for B, so the pure raw-return objective prefers A. Their different lengths do not matter to the original sum beyond the listed rewards.

  2. After adding one per step, A receives three. B receives [1,1,2], totaling four. The transformed objective now prefers B because its longer duration collects more offsets.

  3. A fixed positive multiplication without the offset would preserve this pure-return ordering: scaling by 0.5 gives one and 0.5. That statement does not automatically preserve a composite objective with unchanged entropy or KL coefficients.

The result

The per-step offset reverses the ranking from A to B. Its effect depends on episode duration and therefore cannot be dismissed as a constant baseline here.

Explore the model

Interactive lab

Interactive lab · function

Fixed scalar multiplication is narrower than reward invariance

Use independent Reset → explicitly set BOTH coefficient and position → predict → Play/Step runs for (1,2) and (.5,2), yielding y=4 and y=2. The fixed quadratic has no task duration, shaping, running reward statistics, or learned policy.

Fixed scalar multiplication is narrower than reward invarianceThis lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Current readings: y at chosen x: 0.608; Tangent slope · 2ax: 1.35; Signed area · ax³/3: 0.182. All parameters are adjustable with the labeled controls below.−2.4−1.201.22.4−9−4.504.59xy(x, ax²)
y = ax²TangentSigned integral
y at chosen x
0.608
Tangent slope · 2ax
1.35
Signed area · ax³/3
0.182
t = 0 s

This lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA simple scale comparison does not establish that a complete transformed RL objective preserves the intended task.

Check your understanding

Which condition supports the finite episodic potential-shaping invariance argument stated here?

Try it yourself

Two policies have raw expected returns three and two, with entropy terms zero and two. A hypothetical composite score is return plus entropy. Compute both scores before and after multiplying only rewards by two. What does this show?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Keep the entropy coefficient unchanged and distinguish pure-return ordering from the composite objective.

Compare with the solution

Initially the scores are three and four, so the second policy is preferred by this composite. Scaling only rewards gives scores six and six, a tie. Pure reward ordering remains first over second, but its tradeoff with the unscaled entropy term changed. Real optimizers and clipping can add further scale sensitivity. Record the complete objective and normalization state, and evaluate raw task metrics rather than claim universal invariance from positive reward scaling alone.

Take it with you

  • State reward, duration, discount, and auxiliary-objective conditions for invariance.
  • Retain the endpoint term in shaping and truncation analysis.
  • Evaluate intended outcomes independently from the optimized proxy.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.