@@ -1560,10 +1560,6 @@ def normalize_quant_cfg_list(v: dict | list) -> list[QuantizerCfgEntry]:
15601560 - An empty entry ``{}``.
15611561 - An entry with only ``quantizer_name`` and no other keys — the only effect would be an
15621562 implicit ``enable=True``, which must be stated explicitly.
1563- - An entry with ``enable=True`` (explicit or implicit) whose ``cfg`` is not a non-empty
1564- ``dict`` or ``list`` — e.g. ``{"quantizer_name": "*", "cfg": {}}`` or
1565- ``{"quantizer_name": "*", "cfg": 42}``. An enabled quantizer must have a valid
1566- configuration.
15671563
15681564 **Normalization** — after conversion and validation every entry is put into canonical form:
15691565
@@ -1581,8 +1577,7 @@ def normalize_quant_cfg_list(v: dict | list) -> list[QuantizerCfgEntry]:
15811577
15821578 Raises:
15831579 ValueError: If any entry has only ``quantizer_name`` with neither ``cfg`` nor ``enable``,
1584- if ``enable=True`` with an empty or non-dict/list ``cfg``, or if the entry format
1585- is not recognized.
1580+ or if the entry format is not recognized.
15861581 """
15871582
15881583 def _warn_legacy ():
@@ -1659,12 +1654,6 @@ def _dict_to_entry(key: str, value) -> list[QuantizerCfgEntry]:
16591654 raise ValueError (f"Invalid quant_cfg entry: { raw !r} ." )
16601655
16611656 for entry in entries :
1662- # Normalize: empty cfg (empty dict or empty list) carries no information
1663- # and is equivalent to no cfg. Strip it so the validation below can
1664- # detect entries that have *neither* cfg nor enable.
1665- if "cfg" in entry and isinstance (entry ["cfg" ], (dict , list )) and len (entry ["cfg" ]) == 0 :
1666- del entry ["cfg" ]
1667-
16681657 # Validate: must carry at least one instruction beyond the path selector.
16691658 if "cfg" not in entry and "enable" not in entry :
16701659 raise ValueError (
@@ -1673,28 +1662,6 @@ def _dict_to_entry(key: str, value) -> list[QuantizerCfgEntry]:
16731662 "enable=True is not allowed; set it explicitly)."
16741663 )
16751664
1676- # Validate: when cfg is present and enable=True, cfg must be a non-empty
1677- # dict or list. An empty cfg would attempt to create a
1678- # QuantizerAttributeConfig with no actual configuration.
1679- cfg = entry .get ("cfg" )
1680- enable = entry .get ("enable" , True )
1681- if enable and cfg is not None :
1682- if isinstance (cfg , dict ):
1683- is_invalid = len (cfg ) == 0
1684- elif isinstance (cfg , list ):
1685- is_invalid = len (cfg ) == 0 or any (
1686- not isinstance (item , dict ) or len (item ) == 0 for item in cfg
1687- )
1688- else :
1689- is_invalid = True
1690- if is_invalid :
1691- raise ValueError (
1692- f"Invalid quant_cfg entry: { raw !r} — 'cfg' must be a non-empty dict "
1693- f"or a non-empty list of non-empty dicts when enabling a quantizer "
1694- f"(got { type (cfg ).__name__ } : { cfg !r} ). Either provide quantizer "
1695- "attributes in 'cfg' or remove 'cfg' and set 'enable' explicitly."
1696- )
1697-
16981665 # Normalize: make enable and cfg always explicit.
16991666 entry .setdefault ("enable" , True )
17001667 entry .setdefault ("cfg" , None )
0 commit comments