[Kernel] Set sgl_per_token_group_quant_8bit_v2 as default choice (#22467)
This commit is contained in:
@@ -3,7 +3,7 @@ import subprocess
|
||||
import warnings
|
||||
from contextlib import ExitStack, contextmanager
|
||||
from enum import IntEnum
|
||||
from typing import Any
|
||||
from typing import Any, Optional
|
||||
|
||||
|
||||
@contextmanager
|
||||
@@ -341,7 +341,6 @@ class Envs:
|
||||
SGLANG_FORCE_FP8_MARLIN = EnvBool(False)
|
||||
SGLANG_MOE_NVFP4_DISPATCH = EnvBool(False)
|
||||
SGLANG_NVFP4_CKPT_FP8_GEMM_IN_ATTN = EnvBool(False)
|
||||
SGLANG_PER_TOKEN_GROUP_QUANT_8BIT_V2 = EnvBool(False)
|
||||
SGLANG_NVFP4_CKPT_FP8_NEXTN_MOE = EnvBool(False)
|
||||
SGLANG_QUANT_ALLOW_DOWNCASTING = EnvBool(False)
|
||||
SGLANG_FP8_IGNORED_LAYERS = EnvStr("")
|
||||
@@ -552,12 +551,15 @@ envs = Envs()
|
||||
EnvField._allow_set_name = False
|
||||
|
||||
|
||||
def _print_deprecated_env(new_name: str, old_name: str):
|
||||
def _print_deprecated_env(old_name: str, new_name: Optional[str] = None):
|
||||
if old_name in os.environ:
|
||||
warnings.warn(
|
||||
f"Environment variable {old_name} will be deprecated, please use {new_name} instead"
|
||||
)
|
||||
os.environ[new_name] = os.environ[old_name]
|
||||
if new_name is None:
|
||||
warnings.warn(f"Environment variable {old_name} has been deprecated.")
|
||||
else:
|
||||
warnings.warn(
|
||||
f"Environment variable {old_name} will be deprecated, please use {new_name} instead"
|
||||
)
|
||||
os.environ[new_name] = os.environ[old_name]
|
||||
|
||||
|
||||
def _warn_deprecated_env_to_cli_flag(env_name: str, suggestion: str):
|
||||
@@ -570,14 +572,15 @@ def _warn_deprecated_env_to_cli_flag(env_name: str, suggestion: str):
|
||||
|
||||
|
||||
def _convert_SGL_to_SGLANG():
|
||||
_print_deprecated_env("SGLANG_LOG_GC", "SGLANG_GC_LOG")
|
||||
_print_deprecated_env("SGLANG_GC_LOG", "SGLANG_LOG_GC")
|
||||
_print_deprecated_env(
|
||||
"SGLANG_MOE_NVFP4_DISPATCH", "SGLANG_CUTEDSL_MOE_NVFP4_DISPATCH"
|
||||
"SGLANG_CUTEDSL_MOE_NVFP4_DISPATCH", "SGLANG_MOE_NVFP4_DISPATCH"
|
||||
)
|
||||
_print_deprecated_env(
|
||||
"SGLANG_ENABLE_TP_MEMORY_INBALANCE_CHECK",
|
||||
"SGL_DISABLE_TP_MEMORY_INBALANCE_CHECK",
|
||||
"SGLANG_ENABLE_TP_MEMORY_INBALANCE_CHECK",
|
||||
)
|
||||
_print_deprecated_env("SGLANG_PER_TOKEN_GROUP_QUANT_8BIT_V2")
|
||||
_deprecated_ms_to_s = {
|
||||
"SGLANG_QUEUED_TIMEOUT_MS": "SGLANG_REQ_WAITING_TIMEOUT",
|
||||
"SGLANG_FORWARD_TIMEOUT_MS": "SGLANG_REQ_RUNNING_TIMEOUT",
|
||||
|
||||
@@ -324,10 +324,6 @@ def _per_token_group_quant_8bit_raw(
|
||||
return x_q, x_s
|
||||
|
||||
|
||||
# backward compatibility
|
||||
per_token_group_quant_fp8 = _per_token_group_quant_8bit_raw
|
||||
|
||||
|
||||
def _per_token_group_quant_8bit_fuse_silu_and_mul(
|
||||
x: torch.Tensor,
|
||||
group_size: int,
|
||||
@@ -507,6 +503,11 @@ def sglang_per_token_group_quant_fp8(
|
||||
scale_ue8m0=scale_ue8m0,
|
||||
)
|
||||
|
||||
# Enable v2 kernel by default on supported group sizes
|
||||
_V2_KERNEL_SUPPORTED_GROUP_SIZES = [16, 32, 64, 128]
|
||||
if enable_v2 is None:
|
||||
enable_v2 = group_size in _V2_KERNEL_SUPPORTED_GROUP_SIZES
|
||||
|
||||
if x.shape[0] > 0:
|
||||
# Temporary
|
||||
if enable_sgl_per_token_group_quant_8bit:
|
||||
@@ -606,6 +607,12 @@ def sglang_per_token_quant_fp8(
|
||||
return x_q, x_s
|
||||
|
||||
|
||||
if _is_cuda:
|
||||
per_token_group_quant_fp8 = sglang_per_token_group_quant_fp8
|
||||
else:
|
||||
per_token_group_quant_fp8 = _per_token_group_quant_8bit_raw
|
||||
|
||||
|
||||
@triton.jit
|
||||
def _static_quant_fp8(
|
||||
# Pointers to inputs and output
|
||||
|
||||
Reference in New Issue
Block a user