feat: add online DPO training#2456
Open
taivu1998 wants to merge 1 commit into
Open
Conversation
Signed-off-by: taivu1998 <46636857+taivu1998@users.noreply.github.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
Adds a first Online DPO training path that samples two policy responses per prompt, scores them through NeMo RL environments, converts the higher/lower reward responses into chosen/rejected preference pairs, and trains with the existing DPO loss.
Closes #1816.
What Changed
examples/run_online_dpo.pyas the Online DPO entrypoint.nemo_rl/algorithms/online_dpo.pywith rollout collection, online preference-pair construction, reference logprob calculation, DPO training, validation, checkpointing, and resume state.examples/configs/online_dpo.yamlas the exemplar config and source of defaults.Initial Scope
The implementation is intentionally narrow to keep the first version predictable:
Unsupported surfaces are rejected during setup instead of being silently accepted.
Validation
Passed locally:
uvx ruff check nemo_rl/algorithms/online_dpo.py examples/run_online_dpo.py tests/unit/algorithms/test_online_dpo.pyuvx ruff format --check nemo_rl/algorithms/online_dpo.py examples/run_online_dpo.py tests/unit/algorithms/test_online_dpo.pybash -n tests/functional/online_dpo.shbash -n tests/functional/L1_Functional_Tests_GPU.shgit diff --cached --check/usr/local/bin/python3.13 -m py_compile nemo_rl/algorithms/online_dpo.py examples/run_online_dpo.py tests/unit/algorithms/test_online_dpo.pyexamples/configs/online_dpo.yamlCould not run the focused pytest locally because the default
/usr/local/bin/python3.13is not inspectable byuvon this machine (platform.mac_ver()returns empty), the available uv-managed Python is 3.13.12 while this repo requires>=3.13.13, and the direct 3.13.13 interpreter does not have project dependencies such astorchandpytest.