-
Notifications
You must be signed in to change notification settings - Fork 762
add RAFT #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DearAJ
wants to merge
4
commits into
microsoft:main
Choose a base branch
from
DearAJ:agent-lightning-raft
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+222
−1
Open
add RAFT #363
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the called update_actor function is still the RL one, not the one in "SFTTrainer"? not sure if verl has SFTTrainer...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verl does not have a SFTrainer. SFTrainer inherits from transformers.Trainer and requires the complete HuggingFace Trainer infrastructure, whereas VERL uses Ray distributed training and a custom worker group. Directly adopting SFTrainer would disrupt VERL's existing architecture. Additionally, SFTrainer and VERL use different data formats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. Then why SFT can be implemented in this way? Will update_actor actually compute SFT loss as we expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the derivation of SFT from PPO:
The standard PPO objective (with clipping) is defined as:
L = - E(min( rA, clip( r, 1-ϵ,1+ϵ )A ))
To adapt the PPO framework for Supervised Fine-Tuning (SFT) mode, we set the following neutral conditions:
Set advantages: A=1
Disable clipping: ϵ = 1.0
clip(r, 1-1, 1+0) = clip(r, 0, 2) ≈ r (r = exp(log_prob - old_log_prob), which is usually ranges in [0, 2])
When A=1 and clipping is disabled, the loss simplifies to:
L = - E(min( r, clip( r, 1-ϵ,1+ϵ ))) = -E(r)
logr = logπ(a|s)-logπold(a|s)
Therefore:
L = - E( exp(logπ(a|s)-logπold(a|s)))
In SFT, we directly optimize the current policy without relying on importance sampling. When the old policy is equal to (or very close to) the current policy, the PPO objective is replaced with the Negative Log-Likelihood loss, which is what we want to minimize:
L = - E( logπ(a|s))
For language models, this is the standard Cross-Entropy Loss.
Summary, by:
Setting A=1.0$to remove advantage weighting.
Disabling clipping to remove the PPO clipping mechanism.
The final loss effectively degenerates (or is replaced by) the standard Cross-Entropy Loss (Negative Log-Likelihood), which is the SFT loss.
Thus, the PPO framework, under these specific conditions, becomes equivalent to standard supervised learning (SFT).