-
Notifications
You must be signed in to change notification settings - Fork 45
Fixed reporting of single value of loss and ppl across devices. #496
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
quic-meetkuma
commented
Jul 7, 2025
- Fixed reporting of single value of loss and ppl across devices.
- Minor refactoring changes and variable name changes to make it consistent.
Signed-off-by: meetkuma <[email protected]>
|
||
if local_rank == 0: |
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.
local_rank will be None in non ddp case. Hence, it will not update the tensorboard in non DDP case. Defining following method in helper.py and calling it over here will help:
def is_rank_zero():
return int(os.getenv("LOCAL_RANK", 0)) == 0
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.
Good catch, will update!
# Update the learning rate as needed | ||
lr_scheduler.step() | ||
|
||
if train_config.run_validation: | ||
if train_config.enable_ddp: | ||
dist.barrier() |
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.
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.
It is code refactoring. Moved inside evaluation function.
eval_epoch_loss = ( | ||
0.0 if eval_loss == 0.0 else eval_loss / (step + 1 - num_dummy_samples / train_config.val_batch_size) | ||
) | ||
eval_loss = 0.0 if eval_loss == 0.0 else eval_loss / (step + 1 - num_dummy_samples / train_config.val_batch_size) |
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.
Since we are using the variable name train_epoch_loss for the average train loss of the epoch, it will be good to keep the name eval_epoch_loss for the average evaluation loss of the epoch to maintain uniformity.
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.
Check the other variables being returned from this function. Made the names consistent.
Signed-off-by: meetkuma <[email protected]>
dist.all_reduce(eval_loss, op=dist.ReduceOp.SUM) | ||
eval_loss /= get_num_ddp_devices() | ||
dist.all_reduce(eval_metric, op=dist.ReduceOp.SUM) | ||
eval_metric /= get_num_ddp_devices() |
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.
will it not make each json files have same data for train_epoch_loss, train_epoch_metric and val_epoch_loss and val_epoch_metric?
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.
train_epoch_loss and train_epoch_metric are all_reduced after they are populated at L357.
For this eval_loss and eval_metric, you are right. I will move this all reduce after L386.