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

SAM Callback Update - Check If Optimizer Is Utilized #193

Merged

Conversation

melo-gonzo
Copy link
Collaborator

This PR addresses #188 where some optimizers parameter gradients would be None due to the optimizer not being used. This is due to each batch of data not necessarily containing data that will be used for each output head. A check is put in place to see if the current optimizer is used by checking what datasets are present in the current batch. If the optimizer is used then SAM runs as normal, otherwise SAM is skipped.

@@ -773,25 +773,42 @@ def extract_optimizer_specific_loss(self, task, optimizer, loss):
loss = loss[key]
return loss

def is_optimizer_used(self, task, optimizer):
# Check if only one optimizer is used (singel task)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo on single task

@laserkelvin laserkelvin merged commit f83248c into IntelLabs:main Apr 19, 2024
2 of 3 checks passed
@melo-gonzo melo-gonzo deleted the sam-callback-multidata-optimizer-fix branch June 11, 2024 16:57
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.

2 participants