Fix torch.__version__ for PEP440 (#15682)

This commit is contained in:
EduardDurech
2026-01-29 20:55:13 +01:00
committed by GitHub
parent 4f2b73baf6
commit 1b6798a6a4
8 changed files with 21 additions and 30 deletions

View File

@@ -11,6 +11,7 @@ from sglang.srt.environ import envs
from sglang.srt.layers import deep_gemm_wrapper
from sglang.srt.layers.quantization.fp8_kernel import sglang_per_token_group_quant_fp8
from sglang.srt.layers.quantization.mxfp4_tensor import MXFP4QuantizeUtil
from sglang.srt.utils.common import torch_release
if TYPE_CHECKING:
from sglang.srt.server_args import ServerArgs
@@ -80,17 +81,12 @@ TORCH_DEVICE_IDENTITY = None
def use_rowwise_torch_scaled_mm():
_TORCH_VERSION = torch.__version__.split("+")[0]
try:
_TORCH_VERSION_TUPLE = tuple(map(int, _TORCH_VERSION.split(".")[:3]))
except ValueError:
_TORCH_VERSION_TUPLE = (0, 0, 0)
if _is_hip:
# The condition to determine if it is on a platform that supports
# torch._scaled_mm rowwise feature.
# The condition is determined once as the operations
# are time consuming.
return get_device_capability() >= (9, 4) and _TORCH_VERSION_TUPLE >= (2, 7, 0)
return get_device_capability() >= (9, 4) and torch_release >= (2, 7)
return False