Repository navigation
feat(rl): add score-centered policy gradients - #4
Closed
nanjiangwill wants to merge 1130 commits into
Closed
nanjiangwill wants to merge 1130 commits into
nanjiangwill wants to merge 1130 commits into
Conversation
…ad, trainer-owned adapter (radixark#3194)
…radixark#3291) Signed-off-by: Yusheng Su <yushengsu.thu@gmail.com>
…ang checkout (radixark#3588) Co-authored-by: Cursor Agent <cursoragent@cursor.com>
…s it (radixark#3587) --fully-async selects FullyAsyncRolloutFn, but naming that class through --rollout-function-path selected the same producer while leaving the mode off, so the run skipped every --fully-async check (colocate, partial rollout, legacy rollout v1, pause mode, multi-LoRA) and train.py's async-driver guard. Normalize the path spelling into the flag before validation runs. Only the exact class is recognized; a subclass still passes --fully-async explicitly.
…ion creation (radixark#3585) Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
…#3) * test(e2e): check sampling-support replay exactly under true-on-policy The sampling-support replay e2e compares trainer and rollout log-probs with a 0.03 tolerance on one rollout. Scoring over the full vocabulary instead of the replayed support shifts the mean by only about 0.037 on that data, so a milder top-p or a support wrong on some positions passes. Under true-on-policy the actor's support-normalized log-probs equal the rollout's exactly, and --ci-test asserts log_probs == rollout_log_probs on every rollout. Megatron still rejects --true-on-policy-mode, so the new test runs FSDP: Qwen3-0.6B, top-p 0.8 / top-k 32, 5 rollouts on two GPUs. It uses gsm8k with 1024 response tokens because dapo at 128 tokens truncates every response, which zeroes advantages and leaves the weights nearly unchanged across steps. The Megatron test stays as a smoke run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(e2e): drop tolerance-based replay test and gate KL and grad norm The Megatron sampling-support replay test checked log-probs only within 0.03 over one rollout. The true-on-policy FSDP test checks them exactly on every rollout, so the Megatron test is removed. The FSDP test now also declares history gates for train_rollout_kl, ppo_kl and grad_norm. ppo_kl compares the training forward with forward-only scoring, so it covers the replay mask on the loss path, which the --ci-test log-prob assertion does not reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(e2e): drop the grad_norm gate from the true-on-policy replay test grad_norm is not bit-reproducible across runs of this test and is 0 on steps where every prompt's samples share one reward, so its band carries little signal here. The exact log-prob and KL gates stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(e2e): note that exact replay log-probs hold through bf16 rounding SGLang's fp32 log(p / sum_S p) and the trainer's masked bf16 log_softmax can differ by one bf16 ulp on a small fraction of tokens. Record the measured rate and why it rarely trips --ci-test next to the check, so a nonzero train_rollout_logprob_abs_diff is not mistaken for a regression. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Implement score-centered policy gradients from arXiv:2609.20807 for FSDP and Megatron training.
At every generated-token prefix, the loss subtracts the sampler expectation of the trainer score. Sampler probabilities and optional importance weights are stop-gradient coefficients; gradients flow only through trainer log probabilities.
Dependencies
The branch includes bounded sampling-support replay. Exact-support score centering also uses sgl-project/sglang#40932, which returns the complete normalized sampler behavior distribution aligned with realized-support IDs.
Modes
--score-centering-head-sizedefaults to 128 and does not alter sampling.q; Miles normalizes trainer logitspon the same replayed support.Modeled-tail mode currently fails closed at non-unit temperature because SGLang's generic top-logprob response does not expose whether a remote server selected pre- or post-temperature semantics. Exact-support mode uses an explicit behavior-probability contract and supports any positive configured temperature.
Correctness boundaries
Validation
PYTHONPATH.git diff --checkpass.GPU end-to-end score-centering execution remains to be run.