[Bugfix] compressed-tensors WNA16 MoE: don't assume a "Linear" config group (#29761)
Signed-off-by: Joe Rowell <joerowell4@gmail.com> Co-authored-by: Jiminator <jimmysh341@gmail.com> Co-authored-by: Jimmy Shong <69131491+Jiminator@users.noreply.github.com>
This commit is contained in:
co-authored by
Jiminator
Jimmy Shong
parent
30c9801b39
commit
eb75d990f7
@@ -682,10 +682,12 @@ class CompressedTensorsConfig(QuantizationConfig):
|
||||
logger.info_once(
|
||||
"Using CompressedTensorsMxInt4MoE with flashinfer_trtllm backend"
|
||||
)
|
||||
return CompressedTensorsMxInt4MoE(self)
|
||||
return CompressedTensorsMxInt4MoE(self, weight_quant=weight_quant)
|
||||
elif _is_hip:
|
||||
logger.info_once("Using CompressedTensorsWNA16TritonMoE (ROCm)")
|
||||
return CompressedTensorsWNA16TritonMoE(self)
|
||||
return CompressedTensorsWNA16TritonMoE(
|
||||
self, weight_quant=weight_quant
|
||||
)
|
||||
else:
|
||||
moe_backend = get_moe_runner_backend()
|
||||
if moe_backend.is_triton():
|
||||
@@ -693,9 +695,11 @@ class CompressedTensorsConfig(QuantizationConfig):
|
||||
"Using CompressedTensorsWNA16TritonMoE "
|
||||
"(moe_runner_backend=triton)"
|
||||
)
|
||||
return CompressedTensorsWNA16TritonMoE(self)
|
||||
return CompressedTensorsWNA16TritonMoE(
|
||||
self, weight_quant=weight_quant
|
||||
)
|
||||
logger.info_once("Using CompressedTensorsWNA16MarlinMoEMethod")
|
||||
return CompressedTensorsWNA16MoE(self)
|
||||
return CompressedTensorsWNA16MoE(self, weight_quant=weight_quant)
|
||||
else:
|
||||
if (
|
||||
self._is_dynamic_token_w4(weight_quant, input_quant)
|
||||
|
||||
+8
-2
@@ -25,6 +25,8 @@ logger = logging.getLogger(__name__)
|
||||
__all__ = ["CompressedTensorsMxInt4MoE"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from compressed_tensors.quantization import QuantizationArgs
|
||||
|
||||
from sglang.srt.layers.moe.token_dispatcher import (
|
||||
CombineInput,
|
||||
StandardDispatchOutput,
|
||||
@@ -46,9 +48,13 @@ if is_flashinfer_available():
|
||||
|
||||
|
||||
class CompressedTensorsMxInt4MoE(CompressedTensorsMoEScheme):
|
||||
def __init__(self, quant_config: CompressedTensorsConfig):
|
||||
def __init__(
|
||||
self, quant_config: CompressedTensorsConfig, weight_quant: QuantizationArgs
|
||||
):
|
||||
self.quant_config = quant_config
|
||||
config = self.quant_config.target_scheme_map["Linear"].get("weights")
|
||||
# Per-layer scheme already resolved by get_moe_scheme(); reuse it directly
|
||||
# (mixed-precision MoE has no "Linear" config group to fall back on).
|
||||
config = weight_quant
|
||||
self.num_bits = config.num_bits
|
||||
self.packed_factor = 32 // config.num_bits
|
||||
self.strategy = config.strategy
|
||||
|
||||
+11
-2
@@ -28,6 +28,8 @@ from sglang.srt.layers.quantization.utils import replace_parameter
|
||||
from sglang.srt.utils import get_bool_env_var, is_cuda, is_hip, set_weight_attrs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from compressed_tensors.quantization import QuantizationArgs
|
||||
|
||||
from sglang.srt.layers.moe.token_dispatcher import (
|
||||
CombineInput,
|
||||
StandardDispatchOutput,
|
||||
@@ -62,9 +64,16 @@ class GPTQMarlinState(Enum):
|
||||
|
||||
class CompressedTensorsWNA16MoE(CompressedTensorsMoEScheme):
|
||||
|
||||
def __init__(self, quant_config: CompressedTensorsConfig, num_gpu_experts=-1):
|
||||
def __init__(
|
||||
self,
|
||||
quant_config: CompressedTensorsConfig,
|
||||
weight_quant: QuantizationArgs,
|
||||
num_gpu_experts: int = -1,
|
||||
):
|
||||
self.quant_config = quant_config
|
||||
config = self.quant_config.target_scheme_map["Linear"].get("weights")
|
||||
# Per-layer scheme already resolved by get_moe_scheme(); reuse it directly
|
||||
# (mixed-precision MoE has no "Linear" config group to fall back on).
|
||||
config = weight_quant
|
||||
self.num_bits = config.num_bits
|
||||
self.packed_factor = 32 // config.num_bits
|
||||
self.strategy = config.strategy
|
||||
|
||||
Reference in New Issue
Block a user