feat: add opd/tropd metrics for super v3.5 - #4011
Conversation
Signed-off-by: Khushi Bhardwaj <kbhardwaj@nvidia.com>
|
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 <kbhardwaj@nvidia.com>
|
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 <kbhardwaj@nvidia.com>
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 <noreply@anthropic.com> Signed-off-by: Yi-Fu Wu <yifu.wu@gmail.com>
Signed-off-by: Khushi Bhardwaj <kbhardwaj@nvidia.com>
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: