[CT] Support Humming for WNA16 MoE (#48918)
Signed-off-by: yiliu30 <yi4.liu@intel.com> Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: OpenAI Codex <noreply@openai.com> Co-authored-by: Misha Goin <mgoin64@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
OpenAI Codex
OpenAI Codex
Misha Goin
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
c676232313
commit
54dd98be28
@@ -40,6 +40,9 @@ from vllm.model_executor.layers.fused_moe.utils import (
|
||||
swiglu_limit_func,
|
||||
)
|
||||
from vllm.model_executor.layers.quantization.utils.quant_utils import (
|
||||
INT4_DTYPE,
|
||||
INT8_DTYPE,
|
||||
GroupShape,
|
||||
QuantKey,
|
||||
kFp8Dynamic128Sym,
|
||||
kFp8DynamicTokenSym,
|
||||
@@ -58,6 +61,7 @@ from vllm.model_executor.layers.quantization.utils.quant_utils import (
|
||||
kNvfp4Static,
|
||||
)
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.scalar_type import ScalarType
|
||||
from vllm.utils.import_utils import has_humming
|
||||
from vllm.v1.worker.workspace import current_workspace_manager
|
||||
|
||||
@@ -76,6 +80,29 @@ if TYPE_CHECKING:
|
||||
logger = init_logger(__name__)
|
||||
|
||||
|
||||
def _is_supported_wna16_weight_key(weight_key: QuantKey | None) -> bool:
|
||||
if weight_key is None or weight_key.scale2 is not None:
|
||||
return False
|
||||
|
||||
group_shape = weight_key.scale.group_shape
|
||||
if not (
|
||||
group_shape == GroupShape.PER_CHANNEL
|
||||
or (group_shape.row == 1 and group_shape.col > 0)
|
||||
):
|
||||
return False
|
||||
|
||||
dtype = weight_key.dtype
|
||||
if dtype in (INT4_DTYPE, INT8_DTYPE, torch.uint8):
|
||||
return True
|
||||
|
||||
return (
|
||||
isinstance(dtype, ScalarType)
|
||||
and dtype.is_integer()
|
||||
and not dtype.is_signed()
|
||||
and 2 <= dtype.size_bits <= 8
|
||||
)
|
||||
|
||||
|
||||
def get_humming_moe_gemm_type() -> str:
|
||||
env_gemm_type: str | None = envs.VLLM_HUMMING_MOE_GEMM_TYPE
|
||||
gemm_type = "indexed"
|
||||
@@ -267,7 +294,10 @@ class HummingExpertsBase(mk.FusedMoEExpertsModular):
|
||||
# mxfp8 (compressed-tensors / modelopt / online)
|
||||
(kMxfp8Static, kMxfp8Dynamic),
|
||||
]
|
||||
return (weight_key, activation_key) in SUPPORTED_W_A
|
||||
return (weight_key, activation_key) in SUPPORTED_W_A or (
|
||||
activation_key in (None, kFp8DynamicTokenSym)
|
||||
and _is_supported_wna16_weight_key(weight_key)
|
||||
)
|
||||
|
||||
@property
|
||||
def expects_unquantized_inputs(self) -> bool:
|
||||
|
||||
@@ -1104,9 +1104,21 @@ def _humming_wna16_weight_schema(
|
||||
"desc_act": quant_config.desc_act,
|
||||
"sym": quant_config.is_sym,
|
||||
}
|
||||
if isinstance(quant_config, QuantizationArgs):
|
||||
quant_type = getattr(quant_config.type, "value", quant_config.type)
|
||||
quant_strategy = getattr(quant_config.strategy, "value", quant_config.strategy)
|
||||
return {
|
||||
"quant_method": "compressed-tensors",
|
||||
"format": "pack-quantized",
|
||||
"type": str(quant_type),
|
||||
"num_bits": quant_config.num_bits,
|
||||
"strategy": str(quant_strategy),
|
||||
"group_size": quant_config.group_size,
|
||||
"symmetric": quant_config.symmetric,
|
||||
}
|
||||
raise TypeError(
|
||||
"Humming WNA16 checkpoint schema requires AutoAWQConfig or "
|
||||
"AutoGPTQConfig, "
|
||||
"Humming WNA16 checkpoint schema requires AutoAWQConfig, "
|
||||
"AutoGPTQConfig or QuantizationArgs, "
|
||||
f"got {type(quant_config).__name__}."
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user