Skip to content

[BUG] fix sglang veRL GptOSS rollout problem#14099

Open
yiakwy-xpu-ml-framework-team wants to merge 3 commits intosgl-project:mainfrom
yiakwy-xpu-ml-framework-team:fix_torch_storage_bug
Open

[BUG] fix sglang veRL GptOSS rollout problem#14099
yiakwy-xpu-ml-framework-team wants to merge 3 commits intosgl-project:mainfrom
yiakwy-xpu-ml-framework-team:fix_torch_storage_bug

Conversation

@yiakwy-xpu-ml-framework-team
Copy link
Contributor

Motivation

When support GptOSS with Megatron (NVIDIA/Megatron-LM#2383, verl-project/verl#4323)

We found that using SGLang as rollout backend produces many problems :

23aa48af14f183270ac14dca16cdd3a8

After digging it out we made pytroch patch to avoid pidfd_getfd from torch and docker security settings.

Modifications

Accuracy Tests

  • pytorch patch file
  • tp_worker

Benchmarking and Profiling

Checklist

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @yiakwy-xpu-ml-framework-team, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses critical issues encountered when using SGLang as a rollout backend, particularly in environments like Docker or when integrated with Megatron-LM, which manifest as problems with PyTorch's inter-process communication and CUDA memory sharing. The changes introduce robust handling for multiprocessing and shared CUDA tensor creation, aiming to improve stability and compatibility by circumventing pidfd_getfd related failures.

Highlights

  • Multiprocessing Configuration: Adjusted PyTorch multiprocessing settings in tp_worker.py to use a file_system sharing strategy and fork start method, along with a prctl call to set PR_SET_PTRACER_ANY, to mitigate issues in restricted environments like Docker.
  • PyTorch Monkey-Patching for CUDA Tensors: Implemented a safe fallback mechanism in patch_torch.py for PyTorch's CUDA tensor sharing (_new_shared_cuda and _rebuild_cuda_tensor). This patch prevents pidfd_getfd failures by attempting to allocate shared CUDA memory and, if it fails, falling back to creating shared CPU storage which can then be moved to GPU.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces patches to address multiprocessing issues, particularly in containerized environments, by modifying torch.multiprocessing behavior. The changes in tp_worker.py adjust multiprocessing settings, while patch_torch.py provides a fallback for CUDA tensor sharing to prevent pidfd_getfd errors. While the approach is sound, the implementation includes some debugging code that should be removed and uses overly broad exception handling, which could be improved for better robustness and maintainability.

@yiakwy-xpu-ml-framework-team yiakwy-xpu-ml-framework-team changed the title [Fix] fix sglang rollout problem [BUG] fix sglang veRL GptOSS rollout problem Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant