pecos icon indicating copy to clipboard operation
pecos copied to clipboard

Replace deprecated AdamW from transformers with torch.optim.AdamW

Open Lakshmi-bashyam opened this issue 6 months ago • 0 comments

The codebase currently imports AdamW from transformers:

from transformers import AdamW

However, this import has been deprecated and removed in recent Transformer versions (as noted in Hugging Face issue #36954) ([GitHub]). Users now encounter:

ImportError: cannot import name 'AdamW' from 'transformers'

Additionally, a FutureWarning explicitly states:

“This implementation of AdamW is deprecated and will be removed in a future version. Use the PyTorch implementation torch.optim.AdamW instead.” ([GitHub], [Hugging Face Forums])

Suggested change:

- from transformers import AdamW
+ from torch.optim import AdamW

This change ensures compatibility with future versions of the transformers library and avoids deprecation warnings during training.

Lakshmi-bashyam avatar Jul 14 '25 11:07 Lakshmi-bashyam