-
Notifications
You must be signed in to change notification settings - Fork 54
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
Refine INC shutdown code #335
Conversation
vllm/worker/habana_model_runner.py
Outdated
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 | ||
if can_finalize_inc: | ||
from neural_compressor.torch.quantization import ( | ||
finalize_calibration) | ||
finalize_calibration(self.model.model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I thought attrgetter can handle AttributeErrors ...
So what's the point of using it at the moment? Since we're catching the exception, couldn't we do:
try:
is_inc_used = self.model_config.quantization == 'inc'
is_model_initialized = self.model.model is not None
is_inc_initialized = self.inc_initialized_successfully
can_finalize_inc = is_inc_used and is_model_initialized and \
is_inc_initialized
except AttributeError:
pass
or even better:
can_finalize_inc = (self.model_config.quantization == 'inc') and \
(self.model.model is not None) and \
self.inc_initialized_succesfully
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed + added protection against double shutdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR removes debug printouts in INC shutdown method and covers the case where application exits before model is initialized properly.