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

Just import torch AdamW instead #36177

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Just import torch AdamW instead #36177

wants to merge 6 commits into from

Conversation

Rocketknight1
Copy link
Member

@Rocketknight1 Rocketknight1 commented Feb 13, 2025

Transformers added an AdamW implementation before Torch supported it. However, Torch supports it now so there's not really much point in maintaining our own version!

This PR deletes our AdamW class, but imports torch.optim.AdamW in the same file, to ensure that imports that depended on it still work.

Fixes #35504

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Rocketknight1
Copy link
Member Author

Ready for core maintainer review @ArthurZucker @Cyrilvallez

@@ -604,119 +604,14 @@ def scheduler_hook(param):
)


class AdamW(Optimizer):
class AdamW(TorchAdamW):
Copy link
Collaborator

Choose a reason for hiding this comment

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

as long as you are sure all paramrs are the same for init, let'sgo! 🤗

Copy link
Collaborator

Choose a reason for hiding this comment

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

we can also deprecate this one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, actually - the old one was already deprecated! Maybe we should just remove it entirely, since we've been showing a deprecation warning for a long time now?

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.

Subtle difference with Pytorch AdamW?
3 participants