Fix circular import in quantization modules (#17372)
This commit is contained in:
@@ -31,7 +31,6 @@ from sglang.srt.layers.parameter import (
|
|||||||
RowvLLMParameter,
|
RowvLLMParameter,
|
||||||
_ColumnvLLMParameter,
|
_ColumnvLLMParameter,
|
||||||
)
|
)
|
||||||
from sglang.srt.layers.quantization.unquant import UnquantizedLinearMethod
|
|
||||||
from sglang.srt.layers.utils import pad_or_narrow_weight
|
from sglang.srt.layers.utils import pad_or_narrow_weight
|
||||||
from sglang.srt.utils import get_bool_env_var, is_cpu, is_hip, is_npu, set_weight_attrs
|
from sglang.srt.utils import get_bool_env_var, is_cpu, is_hip, is_npu, set_weight_attrs
|
||||||
|
|
||||||
@@ -165,6 +164,8 @@ class LinearBase(torch.nn.Module):
|
|||||||
self.params_dtype = params_dtype
|
self.params_dtype = params_dtype
|
||||||
self.quant_config = quant_config
|
self.quant_config = quant_config
|
||||||
if quant_config is None:
|
if quant_config is None:
|
||||||
|
from sglang.srt.layers.quantization.unquant import UnquantizedLinearMethod
|
||||||
|
|
||||||
self.quant_method: Optional[QuantizeMethodBase] = UnquantizedLinearMethod()
|
self.quant_method: Optional[QuantizeMethodBase] = UnquantizedLinearMethod()
|
||||||
else:
|
else:
|
||||||
self.quant_method = quant_config.get_quant_method(self, prefix=prefix)
|
self.quant_method = quant_config.get_quant_method(self, prefix=prefix)
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ from sglang.srt.layers.quantization.utils import get_scalar_types
|
|||||||
|
|
||||||
ScalarType, scalar_types = get_scalar_types()
|
ScalarType, scalar_types = get_scalar_types()
|
||||||
|
|
||||||
|
|
||||||
from sglang.srt.layers.linear import LinearBase, UnquantizedLinearMethod
|
|
||||||
from sglang.srt.layers.quantization.base_config import QuantizationConfig
|
from sglang.srt.layers.quantization.base_config import QuantizationConfig
|
||||||
|
|
||||||
|
|
||||||
@@ -217,11 +215,13 @@ class AutoRoundConfig(QuantizationConfig):
|
|||||||
return weight_bits < 16
|
return weight_bits < 16
|
||||||
|
|
||||||
def apply_awq_quant_layer(self, layer, prefix: str, backend: str = "auto"):
|
def apply_awq_quant_layer(self, layer, prefix: str, backend: str = "auto"):
|
||||||
|
from sglang.srt.layers.linear import LinearBase
|
||||||
from sglang.srt.layers.moe.fused_moe_triton import FusedMoE
|
from sglang.srt.layers.moe.fused_moe_triton import FusedMoE
|
||||||
from sglang.srt.layers.quantization.marlin_utils import (
|
from sglang.srt.layers.quantization.marlin_utils import (
|
||||||
check_marlin_supported,
|
check_marlin_supported,
|
||||||
check_moe_marlin_supports_layer,
|
check_moe_marlin_supports_layer,
|
||||||
)
|
)
|
||||||
|
from sglang.srt.layers.quantization.unquant import UnquantizedLinearMethod
|
||||||
from sglang.srt.layers.vocab_parallel_embedding import ParallelLMHead
|
from sglang.srt.layers.vocab_parallel_embedding import ParallelLMHead
|
||||||
|
|
||||||
weight_bits, group_size, sym = self.get_layer_config(layer, prefix)
|
weight_bits, group_size, sym = self.get_layer_config(layer, prefix)
|
||||||
@@ -299,11 +299,13 @@ class AutoRoundConfig(QuantizationConfig):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def apply_gptq_quant_layer(self, layer, prefix: str, backend: str = "auto"):
|
def apply_gptq_quant_layer(self, layer, prefix: str, backend: str = "auto"):
|
||||||
|
from sglang.srt.layers.linear import LinearBase
|
||||||
from sglang.srt.layers.moe.fused_moe_triton import FusedMoE
|
from sglang.srt.layers.moe.fused_moe_triton import FusedMoE
|
||||||
from sglang.srt.layers.quantization.marlin_utils import (
|
from sglang.srt.layers.quantization.marlin_utils import (
|
||||||
check_marlin_supported,
|
check_marlin_supported,
|
||||||
check_moe_marlin_supports_layer,
|
check_moe_marlin_supports_layer,
|
||||||
)
|
)
|
||||||
|
from sglang.srt.layers.quantization.unquant import UnquantizedLinearMethod
|
||||||
from sglang.srt.layers.vocab_parallel_embedding import ParallelLMHead
|
from sglang.srt.layers.vocab_parallel_embedding import ParallelLMHead
|
||||||
|
|
||||||
weight_bits, group_size, sym = self.get_layer_config(layer, prefix)
|
weight_bits, group_size, sym = self.get_layer_config(layer, prefix)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import regex as re
|
|||||||
import torch
|
import torch
|
||||||
from torch.nn.parameter import Parameter
|
from torch.nn.parameter import Parameter
|
||||||
|
|
||||||
from sglang.srt.layers.linear import LinearBase, UnquantizedLinearMethod
|
from sglang.srt.layers.linear import LinearBase
|
||||||
from sglang.srt.layers.parameter import ModelWeightParameter, PerTensorScaleParameter
|
from sglang.srt.layers.parameter import ModelWeightParameter, PerTensorScaleParameter
|
||||||
from sglang.srt.layers.quantization.base_config import (
|
from sglang.srt.layers.quantization.base_config import (
|
||||||
LinearMethodBase,
|
LinearMethodBase,
|
||||||
@@ -20,6 +20,7 @@ from sglang.srt.layers.quantization.petit_utils import (
|
|||||||
prepare_nvfp4_layer_for_petit,
|
prepare_nvfp4_layer_for_petit,
|
||||||
verify_petit_nvfp4_supported,
|
verify_petit_nvfp4_supported,
|
||||||
)
|
)
|
||||||
|
from sglang.srt.layers.quantization.unquant import UnquantizedLinearMethod
|
||||||
from sglang.srt.layers.quantization.utils import is_layer_skipped
|
from sglang.srt.layers.quantization.utils import is_layer_skipped
|
||||||
from sglang.srt.utils import is_hip
|
from sglang.srt.utils import is_hip
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from typing import Any, List, Optional, cast
|
|||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from sglang.srt.layers.linear import LinearBase, UnquantizedLinearMethod
|
from sglang.srt.layers.linear import LinearBase
|
||||||
from sglang.srt.layers.quantization.base_config import ( # noqa: E501
|
from sglang.srt.layers.quantization.base_config import ( # noqa: E501
|
||||||
LinearMethodBase,
|
LinearMethodBase,
|
||||||
QuantizationConfig,
|
QuantizationConfig,
|
||||||
@@ -20,6 +20,7 @@ from sglang.srt.layers.quantization.quark.schemes import (
|
|||||||
QuarkW8A8Fp8,
|
QuarkW8A8Fp8,
|
||||||
)
|
)
|
||||||
from sglang.srt.layers.quantization.quark.utils import deep_compare, should_ignore_layer
|
from sglang.srt.layers.quantization.quark.utils import deep_compare, should_ignore_layer
|
||||||
|
from sglang.srt.layers.quantization.unquant import UnquantizedLinearMethod
|
||||||
from sglang.srt.layers.radix_attention import RadixAttention
|
from sglang.srt.layers.radix_attention import RadixAttention
|
||||||
from sglang.srt.utils import get_device_capability
|
from sglang.srt.utils import get_device_capability
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import torch
|
|||||||
from torch.nn import Module
|
from torch.nn import Module
|
||||||
from torch.nn.parameter import Parameter
|
from torch.nn.parameter import Parameter
|
||||||
|
|
||||||
from sglang.srt.layers.linear import UnquantizedLinearMethod
|
|
||||||
from sglang.srt.layers.quantization.base_config import (
|
from sglang.srt.layers.quantization.base_config import (
|
||||||
FusedMoEMethodBase,
|
FusedMoEMethodBase,
|
||||||
QuantizationConfig,
|
QuantizationConfig,
|
||||||
|
|||||||
Reference in New Issue
Block a user