---
title: Self-Distilled Policy Gradient (SDPG)
url: https://www.emergentmind.com/topics/self-distilled-policy-gradient-sdpg
type: topic
---

# Self-Distilled Policy Gradient (SDPG)

Self-Distilled Policy Gradient (SDPG) is an on-policy reinforcement learning (RL) framework designed for long-sequence generation tasks with sparse, sequence-level rewards, such as mathematical reasoning. SDPG fuses group-relative outcome-driven policy gradients with exact full-vocabulary on-policy self-distillation and reference-policy regularization. By integrating dense, per-token self-supervision with groupwise verifier advantages and a stabilizing policy anchor, SDPG addresses the credit assignment and instability issues that typify sparse-reward environments, and empirically demonstrates improved stability and sample efficiency over RLVR and previous self-distillation baselines [2606.04036].

## 1. Motivation and Problem Statement

Sparse-reward RL in long-sequence domains (e.g., code or mathematics) is ill-posed under standard policy-gradient methods due to two major challenges:

- **Coarse Credit Assignment**: With only sequence-level binary verifier reward \( R(x, y) \in \{0,1\} \), standard approaches such as Group-Relative Policy Optimization (GRPO) compute a group-based normalized advantage \( A_\text{out}^{(i)} \), which is then broadcast to every token in a trajectory. This results in highly coarse-grained, noisy supervision at the token level.
- **Train Instability from Negative Advantages**: Early training is dominated by incorrect sequences, yielding many negative group-relative advantages. PPO-style clipping over-penalizes the policy, leading to slow convergence and unstable updates.

On-policy self-distillation, instantiated via a model acting as both a “student” (conditioned only on input \( x \)) and a “teacher” (conditioned on privileged context \( c \), e.g., reference solutions), provides an auxiliary, dense, tokenwise supervisory signal. However, naive use may reinforce locally plausible yet globally invalid rollouts or cause entropy (mode) collapse.

SDPG unifies three loss components: (a) group-relative outcome-reward policy gradients, (b) a gated per-token self-distillation loss applied only to advantageous trajectories, and (c) a reference-policy Kullback-Leibler (KL) regularizer to anchor policy drift.

## 2. Mathematical Formulation

SDPG minimizes a composite loss:
\[
L_{\mathrm{SDPG}}(\theta) = L_{\mathrm{out}}(\theta) + \beta(k) L_{\mathrm{OPD}^+}(\theta) + \alpha L_{\mathrm{KL}}(\theta)
\]

Where:
- \( L_{\mathrm{out}} \): Outcome-reward group-relative loss.
- \( L_{\mathrm{OPD}^+} \): Positive-advantage-gated, full-vocabulary, on-policy self-distillation (OPD) loss.
- \( L_{\mathrm{KL}} \): KL regularization anchoring the policy to a reference \( \pi_\mathrm{ref} \).
- \( \beta(k) \): A schedule controlling self-distillation strength, with warm-up and late-training decay.
- \( \alpha \): Fixed KL regularization weight.

The outcome-reward component applies a normalized group-relative advantage
\[
A_\text{out}^{(i)} = \frac{R^{(i)} - \mu_G}{\sigma_G + \varepsilon_\mathrm{std}}
\]
with gating \( m_i = 1[A_\text{out}^{(i)} > 0] \) to permit distillation only on successful trajectories. For each sequence position, the student distribution \( p_{i,t}(a) \) is contrasted with the teacher \( q_{i,t}(a) \) via the reverse KL:
\[
\ell_{i, t}^{\mathrm{OPD}}(\theta) = \sum_{a \in V} p_{i, t}(a) \log \frac{p_{i, t}(a)}{\mathrm{SG}[q_{i, t}(a)]}
\]
where SG denotes “stop-gradient”.

The reference-policy KL term may be computed as forward or reverse, unnormalized KL to avoid bias during rollout sampling.

## 3. Training Algorithm

The SDPG training procedure involves the following steps for each batch:

1. **Rollout Sampling:** For each input \( x \), sample \( G \) responses under the current policy.
2. **Advantage Computation:** For each rollout, compute the verifier reward, group mean, std, normalized advantage, and positive-advantage gate.
3. **Loss Evaluation:** For each token, evaluate the negative log-likelihood (“outcome”) loss, self-distillation KL (if \( m_i = 1 \)), and reference KL.
4. **Aggregate and Update:** Compute the total batch loss and update policy parameters.

Explicit pseudocode is provided as follows:

```python
for k = 1…T:
    Sample batch {(x,c)} from dataset D
    for each x in batch:
        Sample G rollouts {y^{(i)}} ∼ π_θ(·|x)
        Compute rewards R^{(i)} and group-based stats μ_G, σ_G
        Compute A_out^{(i)} = (R^{(i)}−μ_G)/(σ_G+ε_std)
        m_i = 1 if A_out^{(i)} > 0 else 0
        for each i, t:
            s_{i,t} = (x, y^{(i)}_{<t})
            p_{i,t} = π_θ(·|s_{i,t})
            q_{i,t} = π_θ(·|c, s_{i,t})  # Stop-grad
            l_OPD = sum_a p_{i,t}(a) * log(p_{i,t}(a)/q_{i,t}(a))
            l_out = -SG[A_out^{(i)}] * log p_{i,t}(y^{(i)}_t)
            l_KL = D_KL(p_{i,t} ∥ π_ref(·|s_{i,t}))
    β = β_base·min(1, k/T_warm)·min(1, (T−k)/T_decay)
    L = (1/Σ|y|)Σ_{i,t} [l_out + β·m_i·l_OPD + α·l_KL]
    Update θ by AdamW step
```

## 4. Theoretical Properties

SDPG’s self-distillation term—full-vocabulary reverse KL between the student and context-enriched teacher—yields a per-token, locally equivalent, variance-reduced policy gradient. The student-side gradient at token \( t \) is:

\[
\sum_{a} p_t(a) \log \frac{p_t(a)}{q_t(a)}
\]
which matches an on-policy policy gradient with a centered log-ratio advantage:
\[
A_{\mathrm{OPD},t}(a) = \mathrm{SG} \left[ D_{\mathrm{KL}}(p_t\|q_t) - \log \frac{p_t(a)}{q_t(a)} \right]
\]
and zero mean under \( p_t \).

Positive-advantage gating ensures that distillation does not reinforce locally plausible but globally invalid sequences. The scheduled decay of \( \beta \) phases out reliance on privileged teaching signals, enabling exploration and effective student deployment. Light KL anchoring (\( \alpha > 0 \)) is necessary for entropy stability; omission leads to response drift or runaway policy entropy.

## 5. Empirical Results

SDPG was benchmarked on math reasoning tasks (DAPO-Math-17k) using Qwen3-4B and Qwen3-1.7B. Privileged context was generated by Gemini 2.5 Pro (“correct answer + chain of thought”). Baselines included GRPO (standard group-relative PPO), RLSD (reward-reweighted self-distillation), and OPCD (pure on-policy context distillation, 1.7B only).

Key findings:

- Both SDPG-URKL and SDPG-UFKL outperform GRPO and RLSD at both model scales and on all main math benchmarks (AIME 2024, AIME 2025, AMC 23; pass@1, mean@32).
- SDPG achieves faster convergence and reaches reward plateaus several hundred steps earlier compared to baselines.
- Entropy is stably maintained (\(\approx 0.4 - 0.6\)) throughout SDPG training, while RLSD’s entropy collapses by step 250.
- Response length is moderated in SDPG models; baselines experience verbosity collapse or underproduction.
- Ablation: removing KL anchoring (\( \alpha = 0 \)) preserves early convergence but induces output drift; removing self-distillation (\( \beta = 0 \)) eliminates early benchmark gains.

## 6. Implementation Details

The SDPG experiments were implemented as follows:

- **Optimization:** AdamW, learning rate \(1\text{e-6}\), weight decay \(0.1\), momentum \((0.9, 0.999)\), gradient clip \(1.0\).
- **Batching:** Global batch size \(128\) prompts, \(G=8\) rollouts per prompt, temperature \(1.0\).
- **Precision and Parallelism:** FSDP + bfloat16, rollout engine via vLLM, 8 × NVIDIA H100 GPUs.
- **Sequence length:** Max prompt \(2048\), max response \(4096\) (dynamic batching).
- **Self-distillation schedule:** \(\beta_{\text{base}}=1\text{e-3}\), warmup \(50\) steps, decay \(350\) steps, total \(T=400\).
- **Verifier:** \(\varepsilon_\text{std}=1\text{e-6}\); PPO clip thresholds \((0.2, 0.2)\).
- **Reference policy:** Fixed initialization or checkpoint, \(\alpha=1\text{e-3}\).

The code is available at https://github.com/lauyikfung/SDPG.

## 7. Context, Related Approaches, and Significance

SDPG can be viewed as a principled extension of self-distilled policy optimization (SDPO) frameworks [2606.03620], combining reverse-KL self-distillation (per-token and on-policy) with outcome-driven reinforcement learning and stability-improving anchors. Alternative approaches, such as Physics-Guided Policy Optimization (PGPO), apply information-modulated step-size control to self-distillation, but do not couple outcome-reward policy gradient with verifier-gated self-distillation or utilize reference policy anchoring.

Theoretical advances in SDPG include the identification of local equivalence between the self-distillation KL gradient and a variance-reduced, centered log-ratio advantage policy gradient. Empirically, SDPG demonstrates improved stability, faster convergence, and higher benchmark accuracy in sparse-reward long-sequence tasks compared to RLVR, SDPO, and reward-reweighted self-distillation alternatives [2606.04036].

Source: https://www.emergentmind.com/topics/self-distilled-policy-gradient-sdpg