Skip to content

refactor remote instance info dict#14971

Closed
amysaq2023 wants to merge 2 commits intosgl-project:mainfrom
amysaq2023:amy/refactor-remote-instance-info-dict
Closed

refactor remote instance info dict#14971
amysaq2023 wants to merge 2 commits intosgl-project:mainfrom
amysaq2023:amy/refactor-remote-instance-info-dict

Conversation

@amysaq2023
Copy link
Copy Markdown
Contributor

@amysaq2023 amysaq2023 commented Dec 12, 2025

Address comments in #13125 (comment) and #13125 (comment)

Checklist

Signed-off-by: Anqi Shen <amy.saq@antgroup.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @amysaq2023, 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 refactors the internal handling of remote instance transfer engine information within the SGLang framework. By introducing a dedicated utility function for parsing this data from scheduler outputs and adjusting the data flow in key entrypoints, the changes aim to improve code modularity, reduce redundancy, and streamline the management of configuration details related to remote weight loading. This addresses previous feedback and enhances the maintainability of the system.

Highlights

  • Centralized Parsing Logic: Introduced a new utility function parse_remote_instance_transfer_engine_info_from_scheduler_infos to centralize the extraction of remote instance transfer engine details from a list of scheduler information.
  • Refactored Data Flow: Modified _launch_subprocesses in engine.py and http_server.py to return a list of all scheduler_infos instead of pre-parsed remote_instance_transfer_engine_info, allowing for more flexible post-processing.
  • Simplified Scheduler Output: The run_scheduler_process in scheduler.py now uses a single result_dict to send scheduler information, conditionally including remote instance transfer engine details, which simplifies the conditional logic.
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
Copy Markdown
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 refactors the logic for parsing remote_instance_transfer_engine_info by moving it into a dedicated utility function. This is a good change that improves code organization and reduces duplication. The changes in engine.py, http_server.py, and scheduler.py correctly adopt this new utility function. My feedback includes a suggestion to make the new utility function more Pythonic and to remove some commented-out code for better maintainability.

Comment thread python/sglang/srt/entrypoints/engine.py Outdated
Comment on lines +187 to +199
def parse_remote_instance_transfer_engine_info_from_scheduler_infos(scheduler_infos):
remote_instance_transfer_engine_info = {}
for data in scheduler_infos:
if (
"tp_rank" in data
and "remote_instance_transfer_engine_session_id" in data
and "remote_instance_transfer_engine_weights_info_dict" in data
):
remote_instance_transfer_engine_info[data["tp_rank"]] = (
data["remote_instance_transfer_engine_session_id"],
data["remote_instance_transfer_engine_weights_info_dict"],
)
return remote_instance_transfer_engine_info
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The implementation of this function can be made more concise and Pythonic by using a dictionary comprehension. This improves readability and reduces verbosity.

Suggested change
def parse_remote_instance_transfer_engine_info_from_scheduler_infos(scheduler_infos):
remote_instance_transfer_engine_info = {}
for data in scheduler_infos:
if (
"tp_rank" in data
and "remote_instance_transfer_engine_session_id" in data
and "remote_instance_transfer_engine_weights_info_dict" in data
):
remote_instance_transfer_engine_info[data["tp_rank"]] = (
data["remote_instance_transfer_engine_session_id"],
data["remote_instance_transfer_engine_weights_info_dict"],
)
return remote_instance_transfer_engine_info
def parse_remote_instance_transfer_engine_info_from_scheduler_infos(scheduler_infos):
required_keys = {
"tp_rank",
"remote_instance_transfer_engine_session_id",
"remote_instance_transfer_engine_weights_info_dict",
}
return {
data["tp_rank"]: (
data["remote_instance_transfer_engine_session_id"],
data["remote_instance_transfer_engine_weights_info_dict"],
)
for data in scheduler_infos
if required_keys.issubset(data)
}

This commit address comments in
sgl-project#13125 (comment),
sgl-project#13125 (comment)

Signed-off-by: Anqi Shen <amy.saq@antgroup.com>
@amysaq2023 amysaq2023 force-pushed the amy/refactor-remote-instance-info-dict branch from 5073fe7 to 1562ee0 Compare December 12, 2025 09:20
@amysaq2023 amysaq2023 changed the title Amy/refactor remote instance info dict refactor remote instance info dict Dec 12, 2025
@amysaq2023 amysaq2023 closed this Dec 13, 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