[Quantization][Autoround][XPU] Add W4A16(moe) / MXFP4(linear/moe) Support (#47124)
Signed-off-by: lkk12014402 <kaokao.lv@intel.com> Signed-off-by: lkk <33276950+lkk12014402@users.noreply.github.com> Signed-off-by: Kunshang Ji <kunshang.ji@intel.com> Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
@@ -72,7 +72,10 @@ class INCConfig(QuantizationConfig):
|
||||
f"Unsupported weight_bits: {weight_bits}, "
|
||||
f"currently only support {self.SUPPORTED_BITS}."
|
||||
)
|
||||
if data_type not in self.SUPPORTED_DTYPES:
|
||||
# auto-round mxfp data_type is e.g. "mx_fp4" / "mx_fp4e2m1"; match the
|
||||
# "mx_fp" family by substring like auto_round.compressors.is_mx_fp.
|
||||
is_mxfp = "mx_fp" in data_type
|
||||
if data_type not in self.SUPPORTED_DTYPES and not is_mxfp:
|
||||
raise ValueError(
|
||||
f"Unsupported data_type: {data_type}, "
|
||||
f"currently only support {self.SUPPORTED_DTYPES}."
|
||||
@@ -111,11 +114,19 @@ class INCConfig(QuantizationConfig):
|
||||
f"group_size={self.group_size}, sym={self.sym})"
|
||||
)
|
||||
|
||||
@property
|
||||
def is_mxfp(self) -> bool:
|
||||
# auto-round mxfp data_type is the "mx_fp" family (e.g. "mx_fp",
|
||||
# "mx_fp4e2m1"); match by substring like auto_round.compressors.is_mx_fp.
|
||||
return "mx_fp" in self.data_type
|
||||
|
||||
@property
|
||||
def is_mxfp8(self) -> bool:
|
||||
# MXFP4 and MXFP8 share data_type "mx_fp" and differ only by bit width.
|
||||
return self.is_mxfp and self.weight_bits == self.MXFP8_BITS
|
||||
|
||||
def _validate_supported_quantization(self) -> None:
|
||||
if self.data_type == self.MXFP8_DATA_TYPE:
|
||||
assert self.weight_bits == self.MXFP8_BITS, (
|
||||
f"INC MXFP8 only supports bits=8, but found bits={self.weight_bits}."
|
||||
)
|
||||
if self.is_mxfp8:
|
||||
assert self.group_size == self.MXFP8_GROUP_SIZE, (
|
||||
"INC MXFP8 only supports group_size=32, "
|
||||
f"but found group_size={self.group_size}."
|
||||
@@ -130,14 +141,14 @@ class INCConfig(QuantizationConfig):
|
||||
"INC MXFP8 only supports backend='auto', "
|
||||
f"but found backend={self.backend!r}."
|
||||
)
|
||||
elif self.packing_format == self.MXFP8_PACKING_FORMAT:
|
||||
elif self.packing_format == self.MXFP8_PACKING_FORMAT and not self.is_mxfp:
|
||||
raise ValueError(
|
||||
f"packing_format={self.MXFP8_PACKING_FORMAT!r} requires "
|
||||
f"data_type={self.MXFP8_DATA_TYPE!r}."
|
||||
f"an {self.MXFP8_DATA_TYPE!r} data_type."
|
||||
)
|
||||
|
||||
def _validate_raw_config(self, config: dict[str, Any]) -> None:
|
||||
if self.data_type != self.MXFP8_DATA_TYPE:
|
||||
if not self.is_mxfp8:
|
||||
return
|
||||
|
||||
expected_fields = {
|
||||
|
||||
Reference in New Issue
Block a user