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

Bump torch from 2.3.1+cpu to 2.4.0+cpu #414

Merged
merged 2 commits into from
Aug 1, 2024
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
70 changes: 12 additions & 58 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ranzen/hydra/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ class Config:
if (group := groups.get(entry.name)) is not None:
for var_name, var_class in group.items():
if not issubclass(var_class, typ): # type: ignore
typ_name = typ.__name__ # type: ignore
raise ValueError(
f"All variants should be subclasses of their entry's type: type"
f" `{var_class.__name__}` of variant `{entry.name}={var_name}` "
f"is not a subclass of `{typ.__name__}`."
f"is not a subclass of `{typ_name}`."
)
else:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion ranzen/torch/optimizers/adafactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import torch
from torch import Tensor
from torch.optim import Optimizer
from torch.optim.optimizer import Optimizer

from .common import LossClosure

Expand Down
4 changes: 2 additions & 2 deletions ranzen/torch/schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import torch
from torch import Tensor
from torch.optim import Optimizer
from torch.optim.lr_scheduler import CosineAnnealingLR, _LRScheduler
from torch.optim.optimizer import Optimizer

__all__ = [
"CosineLRWithLinearWarmup",
Expand Down Expand Up @@ -128,7 +128,7 @@ def scheduler(self) -> Union[LinearWarmupLR, CosineAnnealingLR]:
self._scheduler = CosineAnnealingLR(
optimizer=self.optimizer,
T_max=self.total_iters - self.warmup_iters + 1,
eta_min=self.lr_min,
eta_min=self.lr_min, # type: ignore
)
return self._scheduler

Expand Down
2 changes: 1 addition & 1 deletion tests/optimizers_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import torch
from torch import Tensor
from torch.optim import AdamW
from torch.optim.adamw import AdamW

from ranzen.torch.optimizers import Adafactor, LAMB, SAM

Expand Down
9 changes: 5 additions & 4 deletions tests/scheduler_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import torch
from torch import optim
from torch.optim.adamw import AdamW
from torch.optim.sgd import SGD

from ranzen.torch.schedulers import LinearWarmupLR

Expand All @@ -9,7 +10,7 @@ def test_linear_warmup_lr() -> None:
params = (torch.randn(1, 1, requires_grad=True),)
base_lr = 1.0
lr_start = 1.0e-1
optimizer = optim.SGD(params, lr=base_lr)
optimizer = SGD(params, lr=base_lr)
scheduler = LinearWarmupLR(optimizer=optimizer, lr_start=lr_start, warmup_iters=1)
for group in optimizer.param_groups:
assert group["lr"] == lr_start
Expand All @@ -22,7 +23,7 @@ def _step():
for group in optimizer.param_groups:
assert group["lr"] == base_lr

optimizer = optim.AdamW(params, lr=base_lr)
optimizer = AdamW(params, lr=base_lr)
scheduler = LinearWarmupLR(optimizer=optimizer, lr_start=lr_start, warmup_iters=0)
for group in optimizer.param_groups:
assert group["lr"] == base_lr
Expand All @@ -31,7 +32,7 @@ def _step():
for group in optimizer.param_groups:
assert group["lr"] == base_lr

optimizer = optim.AdamW(params, lr=base_lr)
optimizer = AdamW(params, lr=base_lr)
scheduler = LinearWarmupLR(optimizer=optimizer, lr_start=lr_start, warmup_iters=2)
_step()
expected_lr_after_one_step = lr_start + 0.5 * (base_lr - lr_start)
Expand Down
Loading