Skip to content

Commit

Permalink
remove attrgetter
Browse files Browse the repository at this point in the history
  • Loading branch information
kzawora-intel committed Sep 25, 2024
1 parent 1ec36c6 commit 4e42825
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions vllm/worker/habana_model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1940,22 +1940,17 @@ def execute_model(
return [output]

def shutdown_inc(self):
from operator import attrgetter
can_finalize_inc = False
try:
is_inc_used = attrgetter("model_config.quantization")(
self) == 'inc'
is_model_initialized = attrgetter("model.model")(self) is not None
is_inc_initialized = attrgetter("inc_initialized_successfully")(
self)
can_finalize_inc = is_inc_used and is_model_initialized and \
is_inc_initialized
except AttributeError:
pass
with contextlib.suppress(AttributeError):
can_finalize_inc = (self.model_config.quantization == 'inc') and \
(self.model.model is not None) and \
self.inc_initialized_successfully and \
not getattr(self, "_is_inc_finalized", False)
if can_finalize_inc:
from neural_compressor.torch.quantization import (
finalize_calibration)
finalize_calibration(self.model.model)
self._is_inc_finalized = True

def __del__(self):
self.shutdown_inc()

0 comments on commit 4e42825

Please sign in to comment.