Repository navigation
feat: add opd/tropd metrics for super v3.5 - #4011
Conversation
Signed-off-by: Khushi Bhardwaj <[email protected]>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Signed-off-by: Khushi Bhardwaj <[email protected]>
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Signed-off-by: Khushi Bhardwaj <[email protected]>
yfw
left a comment
There was a problem hiding this comment.
Reviewed against base super-v3.5-posttraining (95d3cc3) at head 4dbc04c, with the merge criteria "flag-off behavior identical to base" and "new implementation correct".
Flag-off: every changed line on the default-flags path was traced and matches base — the alpha == 1.0 estimator branch (metrics get the same raw-gap tensor), _opd_seq_error_logging_fields vs the legacy masking formula (exact parity incl. the [:, 1:] slices), lm_policy.get_topk_logits torch.cat → from_batches (equal for equal-length shards; the removed "flattens" comment was already stale at base), the Megatron get_logprobs restructuring, TeacherWorkerGroup.get_topk_logits vs its sibling, and the async loop wiring. The one exception is the unconditional _opd_seq_error_logging_fields call (inline comment at grpo.py:5428), which is also what turns 15 async test_grpo.py tests red.
Correctness of the new code: TROPD math checked numerically (logaddexp form == closed form for α ∈ {1, 0.5, 0.2, 1e-3}), masked baseline finite on an all-masked batch, next-token→input-position alignment consistent with the repo's logprob convention, distributed_vocab_logsumexp matches torch.logsumexp on CPU (TP>1 path is the PR's GPU test). Remaining items are inline.
Lint: pre-commit run --all-files fails on two PR files: pyrefly at opd.py:73 (inline) and ruff-format/isort in opd_diagnostics.py:26-28 (a blank line after import torch — running pre-commit fixes it).
Smaller notes, no inline comment:
use_orm_advantage/orm_advantage_weight(opd.py:71-72) have no readers anywhere innemo_rl/; the only YAML setting them predates this PR and loads fine viaextra="allow". Consider dropping them, or a validator rejecting non-default values, souse_orm_advantage: truecannot silently do nothing.- The online top-k payload stores raw logits in bf16 and later subtracts the fp32
V_logsumexp, while its description calls the resulting probabilities "exact". With the shippeddefer_fp32_logits: truethe logits are already bf16 so nothing is lost there; for fp32-logit configs consider storinglogits - lse(as the fused path does) or softening the wording. topk_stats_max_tokenssubsamples after the full[B, S, k]top-k transfer to the driver, so it bounds the saved payload but not host memory.
Not verified here: no CUDA/Megatron/vLLM in the review environment, so the CP+packing V_logsumexp gather, the fused Megatron top-k path, and test_distributed_vocab_logsumexp were read-verified only; test_grpo.py numbers come from a scratch copy that only neutralizes the Ray-actor autouse fixture.
Generated by Claude Code
compute_teacher_topk built the teacher batch from input_ids/input_lengths only, so a VLM teacher either failed on media placeholder tokens or scored a different input than the student. Mirror _compute_teacher_logprobs: thread multimodal_data through the call, track row_indices through DP padding, and select the media rows per teacher. The row-selection logic is shared via _attach_multimodal_rows so the two teacher paths cannot drift. Adds two tests mirroring the existing multimodal logprob tests. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
Signed-off-by: Khushi Bhardwaj <[email protected]>
…k capture Port of super-v3.5-posttraining 7251b00 (#4011), restricted to what main lacks. TROPD (proximal_teacher_alpha, subtract_global_baseline) is already on main via #4357 and is NOT re-added; the TROPD hunks of the original were resolved to main's versions. Ported: - nemo_rl/algorithms/opd_diagnostics.py: per-sample, per-token and top-k OPD diagnostics (teacher/student gap, agreement, entropy, KL proxies), gated by on_policy_distillation.log_sample_stats / log_token_stats / log_topk_stats with per-metric log periods; payloads are written next to the step's train_data jsonl (opd_*_stats_step*.{jsonl,pt}). - OnPolicyDistillationConfig gains the log_* knobs, topk_stats_mode ("student_online_teacher_deferred" | "online"), topk_stats_k and topk_stats_max_tokens; assert_topk_stats_supported rejects combinations that cannot run (DTensor backend, fused linear logprobs, online mode without non-colocated teachers). - Megatron backend: LogprobsPostProcessor(topk=...) captures student top-k logprobs in the same forward as prev_logprobs; TopkLogitsPostProcessor (return_logsumexp=True) returns the full-vocabulary logsumexp (distributed_vocab_logsumexp, TP-sharded, CP/packed aware) so top-k logits can be normalised on the driver. Policy.get_logprobs(topk=) and get_topk_logits(return_logsumexp=) are threaded through lm_policy, TeacherWorkerGroup.get_topk_logits and the DTensor workers (which raise NotImplementedError for the new options). - AsyncTrajectoryCollector.compute_teacher_topk: per-teacher-group top-k for a driver-selected batch, reusing the per-agent routing of _compute_teacher_logprobs; multimodal rows are attached through the shared _attach_multimodal_rows helper. - async_grpo_train wiring and pyrefly include. Differences from the original: main trims logprobs/top-k outputs to the pre-dense-padding original_seq_length and uses CPU int tuples for packed offsets -- both kept; the fused top-k result is attached next to main's pinned-memory logprobs copy; TeacherWorkerGroup.get_topk_logits copies sequence_packing_args like main's get_logprobs instead of mutating them; fetch_returned_only (not in main's worker-group API) is dropped; the example yaml, reference config and launcher changes of the original are not included (already on main / out of scope). The deleted legacy dtensor_policy_worker.py hunk is dropped. (cherry picked from commit 7251b00) Co-Authored-By: Claude Fable 5.1 <[email protected]> (cherry picked from commit dadd267)
…k capture Port of super-v3.5-posttraining 7251b00 (#4011), restricted to what main lacks. TROPD (proximal_teacher_alpha, subtract_global_baseline) is already on main via #4357 and is NOT re-added; the TROPD hunks of the original were resolved to main's versions. Ported: - nemo_rl/algorithms/opd_diagnostics.py: per-sample, per-token and top-k OPD diagnostics (teacher/student gap, agreement, entropy, KL proxies), gated by on_policy_distillation.log_sample_stats / log_token_stats / log_topk_stats with per-metric log periods; payloads are written next to the step's train_data jsonl (opd_*_stats_step*.{jsonl,pt}). - OnPolicyDistillationConfig gains the log_* knobs, topk_stats_mode ("student_online_teacher_deferred" | "online"), topk_stats_k and topk_stats_max_tokens; assert_topk_stats_supported rejects combinations that cannot run (DTensor backend, fused linear logprobs, online mode without non-colocated teachers). - Megatron backend: LogprobsPostProcessor(topk=...) captures student top-k logprobs in the same forward as prev_logprobs; TopkLogitsPostProcessor (return_logsumexp=True) returns the full-vocabulary logsumexp (distributed_vocab_logsumexp, TP-sharded, CP/packed aware) so top-k logits can be normalised on the driver. Policy.get_logprobs(topk=) and get_topk_logits(return_logsumexp=) are threaded through lm_policy, TeacherWorkerGroup.get_topk_logits and the DTensor workers (which raise NotImplementedError for the new options). - AsyncTrajectoryCollector.compute_teacher_topk: per-teacher-group top-k for a driver-selected batch, reusing the per-agent routing of _compute_teacher_logprobs; multimodal rows are attached through the shared _attach_multimodal_rows helper. - async_grpo_train wiring and pyrefly include. Differences from the original: main trims logprobs/top-k outputs to the pre-dense-padding original_seq_length and uses CPU int tuples for packed offsets -- both kept; the fused top-k result is attached next to main's pinned-memory logprobs copy; TeacherWorkerGroup.get_topk_logits copies sequence_packing_args like main's get_logprobs instead of mutating them; fetch_returned_only (not in main's worker-group API) is dropped; the example yaml, reference config and launcher changes of the original are not included (already on main / out of scope). The deleted legacy dtensor_policy_worker.py hunk is dropped. (cherry picked from commit 7251b00) Co-Authored-By: Claude Fable 5.1 <[email protected]> (cherry picked from commit dadd267) Signed-off-by: adithyare <[email protected]>
…k capture Port of super-v3.5-posttraining 7251b00 (#4011), restricted to what main lacks. TROPD (proximal_teacher_alpha, subtract_global_baseline) is already on main via #4357 and is NOT re-added; the TROPD hunks of the original were resolved to main's versions. Ported: - nemo_rl/algorithms/opd_diagnostics.py: per-sample, per-token and top-k OPD diagnostics (teacher/student gap, agreement, entropy, KL proxies), gated by on_policy_distillation.log_sample_stats / log_token_stats / log_topk_stats with per-metric log periods; payloads are written next to the step's train_data jsonl (opd_*_stats_step*.{jsonl,pt}). - OnPolicyDistillationConfig gains the log_* knobs, topk_stats_mode ("student_online_teacher_deferred" | "online"), topk_stats_k and topk_stats_max_tokens; assert_topk_stats_supported rejects combinations that cannot run (DTensor backend, fused linear logprobs, online mode without non-colocated teachers). - Megatron backend: LogprobsPostProcessor(topk=...) captures student top-k logprobs in the same forward as prev_logprobs; TopkLogitsPostProcessor (return_logsumexp=True) returns the full-vocabulary logsumexp (distributed_vocab_logsumexp, TP-sharded, CP/packed aware) so top-k logits can be normalised on the driver. Policy.get_logprobs(topk=) and get_topk_logits(return_logsumexp=) are threaded through lm_policy, TeacherWorkerGroup.get_topk_logits and the DTensor workers (which raise NotImplementedError for the new options). - AsyncTrajectoryCollector.compute_teacher_topk: per-teacher-group top-k for a driver-selected batch, reusing the per-agent routing of _compute_teacher_logprobs; multimodal rows are attached through the shared _attach_multimodal_rows helper. - async_grpo_train wiring and pyrefly include. Differences from the original: main trims logprobs/top-k outputs to the pre-dense-padding original_seq_length and uses CPU int tuples for packed offsets -- both kept; the fused top-k result is attached next to main's pinned-memory logprobs copy; TeacherWorkerGroup.get_topk_logits copies sequence_packing_args like main's get_logprobs instead of mutating them; fetch_returned_only (not in main's worker-group API) is dropped; the example yaml, reference config and launcher changes of the original are not included (already on main / out of scope). The deleted legacy dtensor_policy_worker.py hunk is dropped. (cherry picked from commit 7251b00) Co-Authored-By: Claude Fable 5.1 <[email protected]> (cherry picked from commit dadd267) Signed-off-by: adithyare <[email protected]>
…(decision 79) - SWE agent loop passes end to end with a scripted model Gym source: upstream 7bfccecc1 (normalize response tools for replay, NVIDIA-NeMo#3190) as a patch file under gym_patches/, applied to the submodule and the measurement checkout by tools/apply_gym_patches.sh (idempotent, 'check' mode). Plugin: alpha_vllm_model also drops the tool-result 'name' and 'provider_specific_fields' before validation (same targets as upstream NVIDIA-NeMo#4011/NVIDIA-NeMo#4483); its server venv gets nemo-gym from the package index, so a source patch would not reach it. Raising the Gym pin was rejected: every Gym containing the fixes pins vllm 0.29, and uv lock fails in a scratch copy (torchvision 0.28 vs 0.26, then transformers >=5.10.4 vs <5.9; Ray 2.58 vs 2.56.1). Verified: plugin tests 9 (2 negative controls), Gym test_openai_utils 180, R3 tallies unchanged, scripted-model loop on the installed configuration 4/4 reward 1 (student_stub7). Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01JjdZctFTn2wkcheCmz3xKN Signed-off-by: potatowarriors <[email protected]>
What does this PR do?
Adds proximal on-policy distillation (TROPD), comprehensive OPD diagnostics, and Super 3.5 HSG run support to GRPO.
The TROPD advantage is computed as:
log(α · π_teacher + (1 - α) · π_student) - log(π_student)This PR:
on_policy_distillationconfiguration.proximal_teacher_alpha: 1.0.Usage
Configure TROPD through the top-level
on_policy_distillationblock:Additional Information
Validation completed: