Skip to content

Conversation

@hzh0425
Copy link
Collaborator

@hzh0425 hzh0425 commented Nov 6, 2025

Motivation

Problem: When launching with --enable-expert-distribution-metrics in PD disaggregation mode, the scheduler crashed with AttributeError: 'Envs' object has no attribute 'SGLANG_EPLB_HEATMAP_COLLECTION_INTERVAL'.
Root Cause: Missing environment variable definition in Envs class for EPLB heatmap collection interval.

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

@hzh0425 hzh0425 requested a review from fzyzcjy as a code owner November 6, 2025 12:36
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hzh0425, 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 hotfix addresses a critical runtime error in the scheduler that occurred when attempting to collect expert distribution metrics. By defining a previously missing environment variable and adjusting its usage, the pull request ensures the stability of the system and proper functioning of metric collection for expert load balancing.

Highlights

  • Fixes Scheduler Crash: Resolves an AttributeError that occurred when launching with expert distribution metrics enabled in PD disaggregation mode, preventing the scheduler from crashing.
  • Adds Missing Environment Variable: Introduces the SGLANG_EPLB_HEATMAP_COLLECTION_INTERVAL environment variable to the Envs class, which was previously undefined.
  • Updates Metric Collection Logic: Modifies the conditional check for expert distribution metric collection to correctly retrieve and utilize the integer value of the newly added environment variable.
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 provides a hotfix for a crash related to expert distribution metrics. The fix correctly adds the missing SGLANG_EPLB_HEATMAP_COLLECTION_INTERVAL environment variable, resolving the AttributeError. Additionally, the pull request improves the code by refactoring the access to this environment variable to use the .get() method, which prevents a potential TypeError and makes the code more robust and readable. The changes are minimal, targeted, and correct, which is excellent for a hotfix. I have no further suggestions for improvement.

and self._collection_counter % envs.SGLANG_EPLB_HEATMAP_COLLECTION_INTERVAL
== 0
):
interval = envs.SGLANG_EPLB_HEATMAP_COLLECTION_INTERVAL.get()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use this one for parsing int env
from sglang.srt.utils import get_int_env_var

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

interval = get_int_env_var("SGLANG_EPLB_HEATMAP_COLLECTION_INTERVAL", 0)

Are you suggesting changing it to something like this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated @Fridge003

@Fridge003 Fridge003 merged commit ed5e905 into sgl-project:main Nov 7, 2025
13 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants