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

Log multiple losses #1375

Merged
merged 19 commits into from
Aug 24, 2022
Merged

Conversation

Landanjs
Copy link
Contributor

@Landanjs Landanjs commented Aug 6, 2022

Resolves CO-842. Adds logic to log multiple losses. Also, adds loss dictionary to DeepLabv3+ as an example. A couple of scenarios:

1. Scalar tensor loss

This will be logged as loss/train/total. Bert example:

2. Tuple of tensor losses

Individual losses will be logged as 'loss/train/loss{i}' where i is the index of the individual loss. There will also be 'loss/train/total' which is the sum of the individual losses.

3. Dictionary of losses without total key

Individual losses will be logged as 'loss/train/{loss_name}'. There will also be 'loss/train/total' which is the sum of the individual losses.

4. Dictionary of losses with total key

Individual losses will be logged as 'loss/train/{loss_name}'. Loss given at 'loss/train/total' will be used as the loss for the backpropagation, individual losses are not summed when 'total' is present.

Questions

  • Assumes returned loss is a torch.Tensor, is this fine?
  • Should these different scenarios be documented somewhere?

@Landanjs Landanjs marked this pull request as ready for review August 8, 2022 21:10
@Landanjs Landanjs requested review from eracah and a team as code owners August 8, 2022 21:10
@Landanjs

This comment was marked as outdated.

@abhi-mosaic
Copy link
Contributor

abhi-mosaic commented Aug 8, 2022

Is there any way we can get rid of the trailing / when there is only 1 loss value, like loss/train instead of loss/train/ ? I'm just wondering if there could be some parsing issues later on.

[EDIT] or wait maybe it has to be that way for WandB to put plots together in the same place? Hmmm
I wonder if we can add a default like loss/train/total that always gets logged... would match the notation a bit better too.

Also, I wonder if we can drop the _loss suffix for things like loss/train/dice rather than loss/train/dice_loss, as it seems a bit repetitive.

@Landanjs
Copy link
Contributor Author

Landanjs commented Aug 8, 2022

Thanks for the suggestion Abhi, good points! Yeah, that would be cleaner, let me try to set it up 🙂

Hmmm that might actually make the closure stuff easier as well!

@Landanjs Landanjs requested a review from a team as a code owner August 9, 2022 17:39
composer/trainer/trainer.py Outdated Show resolved Hide resolved
composer/trainer/trainer.py Outdated Show resolved Hide resolved
@Landanjs Landanjs requested a review from abhi-mosaic August 9, 2022 22:47
Copy link
Contributor

@eracah eracah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

''

@eracah eracah requested review from eracah and removed request for eracah August 15, 2022 23:43
@mvpatel2000
Copy link
Contributor

I don't understand pyright same :')

Copy link
Contributor

@abhi-mosaic abhi-mosaic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me!!

@Landanjs I'm assuming you have some convergence tests on DeepLabV3 that work? And hopefully we have some trainer tests that do loss as a Tensor, tuple, dict?

Approving now for velocity and trusting you on the tests :)

@Landanjs
Copy link
Contributor Author

I added some convergence tests for tuple losses and dict losses with 'total'. TBH I do not know how to make logging, but I'm running DeepLabv3 and ResNet experiments (wandb here group by group). The results appear to be align with dev.

@Landanjs Landanjs removed the request for review from eracah August 22, 2022 19:52
@Landanjs
Copy link
Contributor Author

I mentioned this to Evan, but just for the record, it looks like i need someone from @mosaicml/composer-team-eng to review as well

@Landanjs Landanjs requested a review from eracah August 23, 2022 19:55
composer/models/deeplabv3/model.py Outdated Show resolved Hide resolved
composer/trainer/trainer.py Show resolved Hide resolved
@Landanjs Landanjs merged commit 8f0d760 into mosaicml:dev Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants