Repository navigation
Conversation
yph22
requested review from
HollowMan6,
PeterSH6,
eric-haibin-lin,
tongyx361,
vermouth1992 and
wuxibin89
as code owners
October 14, 2026 05:26
Contributor
Collaborator
|
Hi @yph22 , I think that this PR has substantial overlap with #7855 cc @wuxibin89 |
Port the authors' tail-residualized reverse-KL gradient estimator and append the observed prompt token to the existing sparse teacher payload. Reuse the current agent-loop and padding paths, with CPU gradient and integration coverage and documented full-support sampling assumptions. Co-authored-by: OpenAI Codex
Co-authored-by: OpenAI Codex
verl-project#7855 landed the forward-direction tail bucket (forward_kl_topk_tail), which overlaps structurally with ResOPD. Reorganize to sit alongside it rather than ahead of the existing variants: - Move the ResOPD section from the top of Loss Variants to after GKD/PG OPD, and restore the original "We implement three OPD variants." lead-in. - Rewrite the estimator using the document's own notation (pi_theta / nu) instead of p/q, and state explicitly how it relates to forward_kl_topk_tail: both coarse-grain the vocabulary into the teacher top-k support plus one tail bucket, but ResOPD targets reverse KL and samples the within-tail residual that the forward-direction mode drops. - Split configuration into its own Usage subsection, next to GKD/PG OPD. - Register resopd in the loss_mode list, document its three metrics, and add the paper to the bibliography as [9]. - Explain why ResOPD clamps tail masses at machine epsilon rather than reusing tail_mass_eps: in forward_kl_topk_tail that epsilon is an objective parameter carrying gradient, while here it only guards log(0) inside a detached coefficient. No change to the estimator or its gradient. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Author
|
Thanks for pointing this out. I’ve updated this PR against the latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Add
distillation.distillation_loss.loss_mode=resopd, implementing ResOPD: Tail Residualization for Sparse On-Policy Distillation from the implementation. ResOPD integrates the teacher top-k head and aggregate tail analytically and samples only the within-tail residual, estimating the full-vocabulary reverse-KL gradient.Use an existing synchronous OPD configuration with:
See
docs/algo/opd.mdfor the complete configuration overrides.Duplicate-work check
Searched ResOPD, distillation, and tail residual; inspected the related PRs and #6676 discussion.
Test
Python 3.12.12, PyTorch 2.10.0, CPU only, one thread:
Coverage: independent per-action gradient formula and expected full reverse-KL gradient (all five actions, four support sizes, three seeds), teacher detachment, low precision, negative surrogate values, teacher requests, causal response masking, sequence-parallel slicing/padding, and unchanged legacy parser behavior. Teacher RPC and SP ranks are mocked; no model weights are loaded.
All 14 configured pre-commit hooks passed on the changed files, including generated-config verification, Ruff, mypy, license and compilation checks.
git diff --checkand the PR-title validator passed. An AST comparison confirms thatresopd_losshas identical logic to the authors' release.An end-to-end GPU training run of this upstream port has not been performed. CPU validation used PyTorch 2.10.0, rather than the current upstream lock's 2.13.0; the repository dependency files are unchanged.
Checklist Before Submitting
*_on_cpu.pyworkflow.AI assistance: this port and its tests were prepared with OpenAI Codex assistance at the ResOPD author's request.