-
Notifications
You must be signed in to change notification settings - Fork 44
[QEff Finetune]: Use logger in place of print statements in finetuning scripts #371
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Mamta Singh <quic_mamtsing@quicinc.com>
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.
we can merge this?
Signed-off-by: Mamta Singh <168400541+quic-mamta@users.noreply.github.com>
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.
Overall, it is a good change, Mamta! Let us try to include more things as suggested.
@@ -63,6 +65,6 @@ def get_data_collator(dataset_processer, dataset_config): | |||
try: | |||
return getattr(module, func_name)(dataset_processer) | |||
except AttributeError: |
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.
This is for all the cases like L62.
Whenever we are raising some exceptions, it is good to log the raised exception, otherwise dumped file logs would represent different picture than the console logs.
We can override the logger to have a custom log function as below.
import logging
class CustomLogger(logging.Logger):
def raise_runtimeerror(self, message):
self.error(message)
raise RuntimeError(message)
logging.setLoggerClass(CustomLogger)
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG, filename='app.log', filemode='a',
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
What do you say?
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.
Address this one as well.
@@ -113,26 +114,26 @@ def train( | |||
for epoch in range(train_config.num_epochs): | |||
if loss_0_counter.item() == train_config.convergence_counter: | |||
if train_config.enable_ddp: | |||
print( | |||
logger.info( |
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.
One important change is required.
We need to log on console only for rank == 0 in case of ddp. Otherwise in 64x ddp or 48x ddp will fill the console with lot of information which is not user friendly.
Signed-off-by: Mamta Singh <mamtsing@blr-ubuntu-g293-22.qualcomm.com>
Use logger in place of print statements in finetuning scripts