Skip to content

Ensure transformers is up to date #1479

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

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kaggle_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ torchao
torchinfo
torchmetrics
torchtune
transformers>=4.51.0
triton
tsfresh
vtk
Expand Down
5 changes: 2 additions & 3 deletions tests/test_transformers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

import torch
from transformers import AdamW
import torch.optim as optim
import transformers.pipelines # verify this import works


Expand All @@ -10,13 +10,12 @@ def assertListAlmostEqual(self, list1, list2, tol):
self.assertEqual(len(list1), len(list2))
for a, b in zip(list1, list2):
self.assertAlmostEqual(a, b, delta=tol)

def test_adam_w(self):
w = torch.tensor([0.1, -0.2, -0.1], requires_grad=True)
target = torch.tensor([0.4, 0.2, -0.5])
criterion = torch.nn.MSELoss()
# No warmup, constant schedule, no gradient clipping
optimizer = AdamW(params=[w], lr=2e-1, weight_decay=0.0)
optimizer = optim.AdamW(params=[w], lr=2e-1, weight_decay=0.0)
for _ in range(100):
loss = criterion(w, target)
loss.backward()
Expand Down