[Feature] Self-Distillation Policy Optimization (SDPO) for Megatron GRPO

Open
#10,587 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start by reading the existing Megatron GRPO rollout, reward, advantage, and loss paths, then compare the proposed behavior with the linked SDPO paper and reference implementation. The request spans a fused Triton loss, EMA teacher checkpointing, reward feedback and generation APIs, backend handling, docs, an example, and tests. Done means those pieces work together with the listed parallelism modes and unsupported cases fail clearly.

Written by the indexing model from the issue text.

Description

enhancement
Checklist / 检查清单
  • I have searched existing issues, and this is a new feature request. / 我已经搜索过现有的 issues,确认这是一个新的 Feature Request。
Feature Request Description / Feature Request 描述

SDPO (Hübotter et al., 2026, "Reinforcement Learning via Self-Distillation") is a GRPO variant for tasks where the environment returns rich textual feedback (runtime errors, judge comments, ...) besides a scalar reward. The same policy, reprompted with a successful sibling rollout and/or the feedback of its own attempt, acts as its own teacher: its next-token distributions are distilled into the policy on the policy's own sampled responses. No external teacher or reward model is needed, and the advantage term is replaced by a distillation loss (generalized JSD over the student's top-K tokens plus a tail bucket). The authors' reference implementation (https://github.com/lasgroup/SDPO) is verl-based research code; this would be an independent implementation on the Megatron backend.

I would like to add it to the Megatron GRPO backend, reusing the existing GRPO rollout/reward/advantage code:

  • --loss_type sdpo for megatron rlhf --rlhf_type grpo, with a fused Triton LM-head loss (no full logits materialised), supporting DP / TP (sequence parallel, padding-free) / PP / EP and full fine-tuning; an EMA teacher that reuses the reference-model slot (fp32 master in host RAM, saved with checkpoints).
  • Reward functions may return {'rewards': [...], 'feedback': [...]} (plain lists keep working for every GRPO variant).
  • --reward_rollout_generator: reward functions receive a handle to generate text with the policy's own vLLM (colocated or server), e.g. to write the feedback.
  • --sdpo_grpo_weight: the SDPO + GRPO mix of the paper (Section 4.5).
  • English and Chinese docs (translated using Claude Sonnet 5.5), an example plugin and script, unit tests.

The HF/transformers backend would raise a clear NotImplementedError for now; context parallel, LoRA with the EMA teacher and the trust-region teacher of the paper are not part of the first version.

Pull Request / Pull Request 信息

I plan to submit one pull request with the above (I will link this issue). It is developed with AI assistance and I reviewed every changed line myself.

Dominant language
Python
Stars
16.2k
Forks
1.8k
Avg merge
1d 14h
Merged PRs (30d)
68

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelscope/ms-swift

All issues in modelscope/ms-swift

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.