Skip to content

Fix torch.__version__ for PEP440#15682

Merged
Kangyan-Zhou merged 3 commits intosgl-project:mainfrom
swiss-ai:fix/torch__version__
Jan 29, 2026
Merged

Fix torch.__version__ for PEP440#15682
Kangyan-Zhou merged 3 commits intosgl-project:mainfrom
swiss-ai:fix/torch__version__

Conversation

@EduardDurech
Copy link
Copy Markdown
Contributor

https://peps.python.org/pep-0440

>>> "2.10"<"2.6"
True

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @EduardDurech, 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 how PyTorch version numbers are handled throughout the codebase. The primary goal is to eliminate potential bugs arising from incorrect string-based version comparisons, particularly when dealing with versions like '2.10' versus '2.6'. By adopting the packaging.version library, the system now performs accurate, PEP 440 compliant version checks, leading to more reliable and future-proof compatibility logic for different PyTorch releases.

Highlights

  • Robust Version Parsing: Introduced the packaging.version.parse utility to correctly interpret torch.__version__ strings, ensuring adherence to PEP 440 standards for version comparison.
  • Consistent Version Checks: Replaced direct string comparisons and startswith checks of torch.__version__ with comparisons against a pre-parsed torch_release object, preventing lexicographical comparison errors.
  • Improved PyTorch Compatibility Logic: Ensured that version-specific code paths, such as those related to torch._inductor and process group options, are correctly activated based on the actual PyTorch version.

🧠 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.

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 correctly addresses the issue of improper version string comparison by using packaging.version.parse as per PEP 440. The changes are sound. I've provided a couple of suggestions to improve maintainability by reducing code duplication and redundant imports. Overall, this is a good fix.

Comment thread python/sglang/srt/compilation/compiler_interface.py Outdated
Comment thread python/sglang/srt/utils/common.py Outdated
Copy link
Copy Markdown
Contributor

@kartikx kartikx left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, these changes are helpful.

The torch_release util can also help in other locations that are manually parsing the release.

For example:

@EduardDurech
Copy link
Copy Markdown
Contributor Author

@kartikx updated all instances, if anyone has any suggestions please contribute review, I don't have time to maintain the PR (also if this could be merged? 😃)

@mickqian mickqian removed the diffusion SGLang Diffusion label Dec 30, 2025
@kartikx
Copy link
Copy Markdown
Contributor

kartikx commented Jan 5, 2026

The changes look good to me, however I do not have CI perms.

@fzyzcjy Can you please take a look since you have also been doing refactoring changes recently?

Comment thread python/sglang/srt/server_args.py Outdated
@kartikx
Copy link
Copy Markdown
Contributor

kartikx commented Jan 5, 2026

/gemini review

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@Kangyan-Zhou
Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@github-actions github-actions Bot added run-ci diffusion SGLang Diffusion labels Jan 5, 2026
@EduardDurech
Copy link
Copy Markdown
Contributor Author

@Kangyan-Zhou @kartikx could one of you guys rerun the CLI and bring this up to admins? It's crazy such a basic, fundamental, standard PR takes a month to merge...

@EduardDurech
Copy link
Copy Markdown
Contributor Author

The CI is broken, I'm no longer maintaining this PR, if SGLang doesn't merge it SGLang's problem

@Kangyan-Zhou Kangyan-Zhou merged commit 1b6798a into sgl-project:main Jan 29, 2026
73 of 94 checks passed
@Kangyan-Zhou
Copy link
Copy Markdown
Collaborator

Kangyan-Zhou commented Jan 29, 2026

@Kangyan-Zhou @kartikx could one of you guys rerun the CLI and bring this up to admins? It's crazy such a basic, fundamental, standard PR takes a month to merge...

Yes we also realized our review process is completely broken, and are working to improve it asap. Sry for the long review and merge process.

@EduardDurech
Copy link
Copy Markdown
Contributor Author

@Kangyan-Zhou thank you, I know you guys have a lot and it's difficult to manage 1.5k PRs but it blocks us quite often for doing development, is it possible to have a fast-track or some internal chat with you guys when we want to do PRs? We're doing things at scale (>10k GH200) and fully transparent with data, models, repos, we have our model PR'd to SGLang and are constantly training new versions https://huggingface.co/swiss-ai, it would be nice if we could have a bit more contact with you guys because I'm waiting on average 1 month for PRs now and have to rebase

We're quite active with SGLang and multiple people, we'd like to contribute but the current workflow is very unappealing for contributors, some example PRs

#9156
https://github.com/sgl-project/sglang/issues?q=is%3Apr%20author%3Anathanrchn
https://github.com/sgl-project/sglang/issues?q=is%3Apr%20author%3AEduardDurech

Thank you

@Kangyan-Zhou
Copy link
Copy Markdown
Collaborator

@EduardDurech could you please join sglang slack and dm me? Thanks!

get_sp_group,
get_ulysses_parallel_world_size,
)
from sglang.srt.utils.common import torch_release
Copy link
Copy Markdown
Collaborator

@mickqian mickqian Jan 30, 2026

Choose a reason for hiding this comment

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

please avoid importing sglang.srt in multimodal_gen

Copy link
Copy Markdown
Contributor Author

@EduardDurech EduardDurech Jan 30, 2026

Choose a reason for hiding this comment

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

@mickqian would you like me to make a version utils? Or just duplicate the torch vesrion in https://github.com/sgl-project/sglang/blob/main/python/sglang/multimodal_gen/utils.py?

charlesHsuGG pushed a commit to charlesHsuGG/sglang that referenced this pull request Jan 30, 2026
Chen-0210 pushed a commit to Chen-0210/sglang that referenced this pull request Jan 30, 2026
sfiisf pushed a commit to sfiisf/sglang that referenced this pull request Feb 5, 2026
Johnsonms pushed a commit to Johnsonms/sglang that referenced this pull request Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants