Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ runtime_common = [

srt = [
"sglang[runtime_common]",
"sgl-kernel==0.2.3",
"sgl-kernel==0.2.4",
"torch==2.7.1",
"torchaudio==2.7.1",
"torchvision==0.22.1",
Expand Down
2 changes: 1 addition & 1 deletion python/sglang/srt/entrypoints/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def _set_envs_and_config(server_args: ServerArgs):
if _is_cuda:
assert_pkg_version(
"sgl-kernel",
"0.2.3",
"0.2.4",
"Please reinstall the latest version with `pip install sgl-kernel --force-reinstall`",
)
Comment on lines 651 to 655
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 pyproject.toml file pins sgl-kernel to an exact version (==0.2.4), but assert_pkg_version only checks for a minimum version (>=0.2.4). This could lead to issues if a user has a newer, potentially incompatible, version of sgl-kernel installed.

To ensure consistency and prevent potential runtime errors from incompatible future versions (especially since sgl-kernel is pre-1.0), it's better to enforce an exact version match at runtime.

I suggest replacing assert_pkg_version with an inline check for exact version equality. This makes the runtime check match the dependency specification in pyproject.toml.

Note: You will need to add the following imports at the top of the file:

from importlib.metadata import PackageNotFoundError, version
from packaging.version import parse as parse_version
Suggested change
assert_pkg_version(
"sgl-kernel",
"0.2.3",
"0.2.4",
"Please reinstall the latest version with `pip install sgl-kernel --force-reinstall`",
)
# Enforce exact version match to align with pyproject.toml
pkg = "sgl-kernel"
required_version = "0.2.4"
try:
from importlib.metadata import PackageNotFoundError, version
from packaging.version import parse as parse_version
installed_version = version(pkg)
if parse_version(installed_version) != parse_version(required_version):
raise RuntimeError(
f"Incorrect version for {pkg} installed. "
f"Required: {required_version}, Found: {installed_version}. "
f"Please `pip install sgl-kernel=={required_version} --force-reinstall`"
)
except PackageNotFoundError:
raise RuntimeError(
f"{pkg} is not installed. "
f"Please `pip install sgl-kernel=={required_version} --force-reinstall`"
)


Expand Down
Loading