Open
Conversation
Co-authored-by: t.ianzhencong <t.ianzhencong@gmail.com>
|
Is this commit missing this?: |
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.
What does this PR do?
This PR fixes an Out of Memory (OOM) issue occurring during multi-turn interaction processing, specifically when using
multi_turn_interaction(related to verl-project#2189). The bug was caused by insufficient GPU memory during SGLang's memory operations, similar to the OOM issue fixed in verl-project#1911.The fix re-introduces strategic
get_torch_device().empty_cache()calls around memory-intensive operations within theSGLangRolloutworker to ensure GPU cache is cleared before memory allocation, preventing OOM crashes.Checklist Before Starting
[{modules}] {type}: {description}(This will be checked by the CI)[sglang, worker] fix: OOM in multi-turn interactionTest
This fix allows the
multi_turn_interactionscenarios that previously crashed due to OOM to run successfully.API and Usage Example
No API changes were made. The fix is internal to memory management.
Design & Code Changes
High-Level Design:
The core design principle is to proactively clear the GPU memory cache (
torch.cuda.empty_cache()) before and after critical memory-intensive operations within the SGLang rollout worker. This ensures that sufficient memory is available for SGLang's internal memory management (e.g.,resume_memory_occupation) and prevents memory accumulation that leads to OOM.Specific Changes:
Added
get_torch_device().empty_cache()calls inverl/workers/rollout/sglang_rollout/sglang_rollout.pyat the following points:interaction.generate_response: To clear cache around the main interaction processing loop.asyncio.gather(*tool_reward_tasks).asyncio.gather(*tool_creation_coroutines)in_handle_pending_state.interaction.start_interactionin_handle_pending_state.Checklist Before Submitting
Important
Please check all the following items before requesting a review, otherwise the reviewer might deprioritize this PR for review.
pre-commit install && pre-commit run --all-files --show-diff-on-failure --color=alwaysci-requestchannel in theverlSlack workspace. (If not accessible, please try the Feishu group (飞书群).)Learn more about Cursor Agents