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

Add manual optimization to core task #1796

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

clement-pages
Copy link
Collaborator

This PR adds:

  • manual_optimization to pyannote.audio.core.Task
  • gradient attribute to pyannote's tasks, which is a dict of gradient arguments: gradient clipping (val and algo), and gradient batch accumulation. (needed by manual_optimisation

Comment on lines +253 to +255
"clip_val": 5.0,
"clip_algorithm": "norm",
"accumulate_batches": 1,
Copy link
Member

@hbredin hbredin Nov 26, 2024

Choose a reason for hiding this comment

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

Shouldn't we instead try to grab these values from trainer options directly?
Maybe trainer is exposed as an attribute of model?

Copy link
Member

@hbredin hbredin Nov 26, 2024

Choose a reason for hiding this comment

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

Yep, looks like you could use something like

self.model.trainer.{accumulate_grad_batches, gradient_clip_val, gradient_clip_algorithm}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Passing accumulate_grad_batches, gradient_clip_val or gradient_clip_algorithm to the Trainer will raise a MisconfigurationException if we set automatic_optimization=False.

lightning_fabric.utilities.exceptions.MisconfigurationException: Automatic gradient clipping is not supported for manual optimization. Remove `Trainer(gradient_clip_val=5.0)` or switch to automatic optimization.

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