Patch sleep mode properly for trl #3492
Merged
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.
trl update seems to have broken GRPO for a while now. This should fix it.
What is happening?
Initially we patched _prepare_inputs() so that llm generate call takes place in that function and we sleep vllm after the function. But newer (since September) trl versions seem to have
_generate_and_score_completionswhich themselves call vllm's .generate and then immediately proceed to forward pass the inputs.What to do?
So we need to call sleep() before the forward pass is called. Hence the only logical place being right after
self.llm.generateException:
Since v0.23.0, trl has a sleep and wakeup support. So we do not want to perform any additional calls that may incur latency. Hence this check
Sample UnslothGRPOTrainer.py file after this patch