Skip to content

Fix test_return_routed_experts to use response-level sglext#18274

Merged
Kangyan-Zhou merged 1 commit intomainfrom
fix-routed-experts-test-sglext-location
Feb 5, 2026
Merged

Fix test_return_routed_experts to use response-level sglext#18274
Kangyan-Zhou merged 1 commit intomainfrom
fix-routed-experts-test-sglext-location

Conversation

@alisonshao
Copy link
Collaborator

Summary

  • Fix test_return_routed_experts.py to access sglext at response level instead of sgl_ext in choices

PR #17648 moved the sgl_ext field from choices[0] to the response level and renamed it to sglext (no underscore). The test was not updated accordingly, causing CI failures.

Test plan

  • CI passes for stage-c-test-large-4-gpu suite

🔗 Failure example

PR #17648 moved the sgl_ext field from choices[0] to the response
level and renamed it to sglext. The test was not updated accordingly,
causing CI failures.

Changes:
- Access response.get("sglext") instead of choices[0].get("sgl_ext")
- Update field name from sgl_ext to sglext (no underscore)

Failure example: https://github.com/sgl-project/sglang/actions/runs/21653054987/job/62421861711
@alisonshao
Copy link
Collaborator Author

/rerun stage-c-test-large-4-gpu

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @alisonshao, 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 resolves a critical CI failure by updating a test case that extracts routed experts from an OpenAI response. The core issue stemmed from a recent API modification where the sglext field was moved from nested within choices to the top-level response object and renamed. The updated test now correctly reflects this new structure, ensuring accurate validation of the API's behavior.

Highlights

  • Test Fix for OpenAI Response Structure: The test test_return_routed_experts.py has been updated to correctly parse the sglext field from OpenAI-like responses. Previously, it expected sgl_ext within choices[0], but a recent change (PR [HiCache] feat: Add detailed cache hit breakdown for HiCache in sglext and Prometheus metrics #17648) moved this field to the top-level response and renamed it to sglext.
  • CI Failure Resolution: This change directly addresses CI failures caused by the outdated test logic, ensuring the test now aligns with the current API response structure.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • test/registered/rl/test_return_routed_experts.py
    • Modified the extract_routed_experts_from_openai_response function to retrieve the sglext field directly from the response object.
    • Removed the logic that iterated through choices as sglext is no longer expected within this array.
    • Updated variable names from sgl_ext to sglext and adjusted corresponding error messages to reflect the new field name and location.
Activity
  • The pull request was created by alisonshao.
  • The author provided a detailed summary explaining the problem and the fix.
  • A test plan was included, specifying that CI passes for the stage-c-test-large-4-gpu suite.
  • A link to a failure example was provided for context.
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.

@alisonshao
Copy link
Collaborator Author

/rerun-stage stage-c-test-large-4-gpu

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

✅ Triggered stage-c-test-large-4-gpu to run independently (skipping dependencies).

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

🔗 View workflow run

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 correctly fixes a test that was failing due to a recent API change where sglext was moved to the response level. The change is straightforward and addresses the issue described. I've added one suggestion to improve the robustness of the data extraction logic in the test, making it less brittle to unexpected response formats.

Comment on lines +219 to +224
sglext = response.get("sglext", None)
if sglext is None:
raise ValueError("OpenAI response missing sglext.")
routed_experts = sglext.get("routed_experts", None)
if routed_experts is None:
raise ValueError("OpenAI response sgl_ext missing routed_experts.")
raise ValueError("OpenAI response sglext missing routed_experts.")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current implementation for extracting routed_experts could be more robust. If sglext exists but is not a dictionary (e.g., a string), the call to sglext.get() on line 222 would raise an AttributeError. It's better to validate the type of sglext to provide a clearer error message and handle malformed responses gracefully. This also makes the code slightly more concise.

Suggested change
sglext = response.get("sglext", None)
if sglext is None:
raise ValueError("OpenAI response missing sglext.")
routed_experts = sglext.get("routed_experts", None)
if routed_experts is None:
raise ValueError("OpenAI response sgl_ext missing routed_experts.")
raise ValueError("OpenAI response sglext missing routed_experts.")
sglext = response.get("sglext")
if not isinstance(sglext, dict):
raise ValueError("OpenAI response missing or has an invalid 'sglext' field.")
routed_experts = sglext.get("routed_experts")
if routed_experts is None:
raise ValueError("OpenAI response 'sglext' is missing 'routed_experts'.")

@Kangyan-Zhou Kangyan-Zhou merged commit c910829 into main Feb 5, 2026
86 of 92 checks passed
@Kangyan-Zhou Kangyan-Zhou deleted the fix-routed-experts-test-sglext-location branch February 5, 2026 04:16
@ishandhanani
Copy link
Collaborator

Apologies @Kangyan-Zhou and @alisonshao - I should have caught this. Thank you for the fix

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.

3 participants