Skip to content

Commit

Permalink
Full Scheme support
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul-tuli committed May 23, 2024
1 parent 524b4a1 commit e6d8734
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sparseml/modifiers/quantization/gptq/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class GPTQModifier(Modifier):
not be updated. Leave None to not disable observers during QAT. Default is None
:param num_calibration_steps: Number of steps to run post training calibration for.
When None, the entire calibration_dataloader is used
:param scheme: [Used, if a quantization modifier is not specified], the quantization
scheme to apply to the model, this is a dictionary that supports all keys from
QuantizationScheme except targets, which will be set to the targets parameter
set at the modifier level.
"""

sequential_update: Optional[bool] = False
Expand All @@ -79,6 +83,7 @@ class GPTQModifier(Modifier):
ignore: List[str] = Field(default_factory=list)
disable_quantization_observer_epoch: Optional[float] = None
num_calibration_steps: Optional[int] = None
scheme: Optional[Dict[str, Any]] = None
compressible_layers_: Optional[List] = None
quantization_modifier_: Any = None

Expand Down Expand Up @@ -156,6 +161,14 @@ def _build_quant_modifier(self, framework):
if getattr(self, key, False)
}

if self.scheme is not None:
# takes precedence over config_groups
targets = self.targets or ["Linear"]
config_group = QuantizationScheme.model_validate(
{"targets": targets, **self.scheme}
)
quant_args["config_groups"] = {"config_group_0": config_group}

if "config_groups" not in quant_args:
default_quant_scheme = QuantizationScheme.default_scheme(
targets=self.targets
Expand Down

0 comments on commit e6d8734

Please sign in to comment.