[Feature][NPU]: add runtime support for AutoRound quantized models (#16699)
Co-authored-by: root <root@localhost.localdomain> Co-authored-by: ronnie_zheng <zl19940307@163.com>
This commit is contained in:
@@ -64,10 +64,9 @@ WEIGHT_LOADER_V2_SUPPORTED = [
|
||||
"GPTQMarlin24LinearMethod",
|
||||
"TPUInt8LinearMethod",
|
||||
"GPTQLinearMethod",
|
||||
"GPTQLinearAscendMethod",
|
||||
"GPTQMoEAscendMethod",
|
||||
"FBGEMMFp8LinearMethod",
|
||||
"GPTQLinearAscendMethod",
|
||||
"GPTQMoEAscendMethod",
|
||||
"ModelOptFp8LinearMethod",
|
||||
"ModelOptFp4LinearMethod",
|
||||
"IPEXAWQLinearMethod",
|
||||
|
||||
@@ -14,6 +14,9 @@ from sglang.srt.layers.quantization.utils import get_scalar_types
|
||||
ScalarType, scalar_types = get_scalar_types()
|
||||
|
||||
from sglang.srt.layers.quantization.base_config import QuantizationConfig
|
||||
from sglang.srt.utils import is_npu
|
||||
|
||||
_is_npu = is_npu()
|
||||
|
||||
|
||||
class AutoRoundConfig(QuantizationConfig):
|
||||
@@ -301,6 +304,11 @@ class AutoRoundConfig(QuantizationConfig):
|
||||
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.quantization.gptq import (
|
||||
GPTQConfig,
|
||||
GPTQLinearAscendMethod,
|
||||
GPTQMoEAscendMethod,
|
||||
)
|
||||
from sglang.srt.layers.quantization.marlin_utils import (
|
||||
check_marlin_supported,
|
||||
check_moe_marlin_supports_layer,
|
||||
@@ -323,6 +331,24 @@ class AutoRoundConfig(QuantizationConfig):
|
||||
group_size,
|
||||
sym,
|
||||
)
|
||||
if _is_npu:
|
||||
quant_args = GPTQConfig(
|
||||
weight_bits=weight_bits,
|
||||
group_size=group_size,
|
||||
lm_head_quantized=False,
|
||||
desc_act=False,
|
||||
dynamic={},
|
||||
)
|
||||
quant_args.sym = sym
|
||||
|
||||
if isinstance(layer, FusedMoE):
|
||||
return GPTQMoEAscendMethod(quant_args)
|
||||
|
||||
if isinstance(layer, (LinearBase, ParallelLMHead)):
|
||||
return GPTQLinearAscendMethod(quant_args)
|
||||
|
||||
return None
|
||||
|
||||
if backend == "auto" or "marlin" in backend:
|
||||
GPTQ_TYPE_MAP = {
|
||||
(4, True): scalar_types.uint4b8,
|
||||
|
||||
Reference in New Issue
Block a user