Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPTQModifier Nits and Code Clarity #1068

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/llmcompressor/modifiers/quantization/gptq/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class GPTQModifier(Modifier, HooksMixin):
- run_sequential / run_layer_sequential / run_basic
- make_empty_hessian
- accumulate_hessian
- quantize_weight
- on_sequential_batch_end
- quantize_weight
- on_finalize
- remove_hooks()
- model.apply(freeze_module_quantization)
Expand Down Expand Up @@ -191,7 +192,7 @@ def on_initialize_structure(self, state: State, **kwargs):
if self._quantization_modifier:
self._quantization_modifier.on_initialize_structure(state, **kwargs)

def on_initialize(self, state: "State", **kwargs) -> bool:
def on_initialize(self, state: State, **kwargs) -> bool:
"""
Initialize and run the GPTQ algorithm on the current state

Expand Down Expand Up @@ -271,7 +272,7 @@ def on_initialize(self, state: "State", **kwargs) -> bool:
run_basic(state.model, state.data.calib, self)
return True

def on_finalize(self, state: "State", **kwargs) -> bool:
def on_finalize(self, state: State, **kwargs) -> bool:
"""
disable the quantization observers used by the OBCQ algorithm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def setUp(self):
setup_modifier_factory()

def test_create_default_quant_modifier(self):
kwargs = dict(block_size=128)

modifier = GPTQModifier(**kwargs)
modifier = GPTQModifier(block_size=128)
assert modifier._quantization_modifier is None

testing_harness = LifecyleTestingHarness(model=LinearNet())
Expand Down Expand Up @@ -106,8 +104,7 @@ def test_set_quant_if_modifer_already_exists(self):
modifier.initialize(testing_harness.get_state())
assert qat_active(testing_harness.get_state().model)

kwargs = dict(block_size=128)
modifier = GPTQModifier(**kwargs)
modifier = GPTQModifier(block_size=128)
assert not modifier._quantization_modifier

modifier.on_initialize_structure(testing_harness.get_state())
Expand Down Expand Up @@ -142,9 +139,7 @@ def setUp(self):
self.quant_config = {"QuantizationModifier": self.quant_kwargs}

def test_set_quant_in_gptq(self):
kwargs = dict(block_size=128, quantize=self.quant_config)

modifier = GPTQModifier(**kwargs)
modifier = GPTQModifier(block_size=128, quantize=self.quant_config)
assert modifier._quantization_modifier is None

testing_harness = LifecyleTestingHarness(model=LinearNet())
Expand Down
Loading