Skip to content

Commit

Permalink
Merge pull request #271 from kozistr/fix/kwargs
Browse files Browse the repository at this point in the history
[Fix] Add missing kwargs
  • Loading branch information
kozistr authored Aug 15, 2024
2 parents a8eb19c + 480bd4c commit 5a65b51
Show file tree
Hide file tree
Showing 70 changed files with 126 additions and 15 deletions.
5 changes: 5 additions & 0 deletions docs/changelogs/v3.1.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Change Log

### Bug

* Add `**kwargs` to the parameters for dummy placeholder. (#270, #271)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ lint.select = [
]
lint.ignore = [
"B905", "D100", "D102", "D104", "D105", "D107", "D203", "D213", "D413", "PIE790", "PLR0912", "PLR0913", "PLR0915",
"PLR2004", "RUF013", "Q003",
"PLR2004", "RUF013", "Q003", "ARG002",
]
lint.fixable = ["ALL"]
lint.unfixable = ["F401"]
Expand Down
2 changes: 1 addition & 1 deletion pytorch_optimizer/lr_scheduler/rex.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_linear_lr(self) -> float:

return self.min_lr + (self.max_lr - self.min_lr) * ((1.0 - progress) / (1.0 - progress / 2.0))

def step(self, epoch: Optional[int] = None) -> float: # noqa: ARG002
def step(self, epoch: Optional[int] = None) -> float:
value: float = self.get_linear_lr()

self.step_t += 1
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/a2grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(
lips: float = 10.0,
rho: float = 0.5,
variant: str = 'uni',
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_non_negative(lips, 'lips')
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adabelief.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(
adanorm: bool = False,
adam_debias: bool = False,
eps: float = 1e-16,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adabound.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
ams_bound: bool = False,
adam_debias: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adadelta.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(
weight_decouple: bool = False,
fixed_decay: bool = False,
eps: float = 1e-6,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_range(rho, 'rho', 0.0, 1.0)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adafactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(
eps1: float = 1e-30,
eps2: float = 1e-3,
momentum_dtype: torch.dtype = torch.bfloat16,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adahessian.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
hessian_distribution: HUTCHINSON_G = 'rademacher',
adam_debias: bool = False,
eps: float = 1e-16,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adai.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
dampening: float = 1.0,
use_gc: bool = False,
eps: float = 1e-3,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adalite.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
tau: float = 1.0,
eps1: float = 1e-6,
eps2: float = 1e-10,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adam_mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(
num_heads: int = 32,
num_query_groups: Optional[int] = None,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adamax.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
adanorm: bool = False,
adam_debias: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adamg.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
weight_decouple: bool = False,
fixed_decay: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adamod.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
fixed_decay: bool = False,
adam_debias: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(
adanorm: bool = False,
adam_debias: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adams.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(
adanorm: bool = False,
adam_debias: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adamw.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(
weight_decay: float = 1e-2,
weight_decouple: bool = True,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adan.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
r: float = 0.95,
adanorm: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adanorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(
ams_bound: bool = False,
adam_debias: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adapnm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(
adanorm: bool = False,
adam_debias: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adashift.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
keep_num: int = 10,
reduce_func: Optional[Callable] = torch.max,
eps: float = 1e-10,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/adasmooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(
weight_decouple: bool = False,
fixed_decay: bool = False,
eps: float = 1e-6,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/aggmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(
weight_decay: float = 0.0,
weight_decouple: bool = False,
fixed_decay: bool = False,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/aida.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(
adanorm: bool = False,
adam_debias: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/alig.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(
projection_fn: Optional[Callable] = None,
momentum: float = 0.0,
adjusted_momentum: bool = False,
**kwargs,
):
self.validate_learning_rate(max_lr)
self.validate_range(momentum, 'momentum', 0.0, 1.0)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/amos.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
c_coef: float = 0.25,
d_coef: float = 0.25,
eps: float = 1e-18,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_range(momentum, 'momentum', 0.0, 1.0, range_type='[)')
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/apollo.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(
weight_decay_type: str = 'l2',
warmup_steps: int = 500,
eps: float = 1e-4,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_range(beta, 'beta', 0.0, 1.0, range_type='[]')
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/avagrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
fixed_decay: bool = False,
adam_debias: bool = False,
eps: float = 1e-1,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/came.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
ams_bound: bool = False,
eps1: float = 1e-30,
eps2: float = 1e-16,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
5 changes: 5 additions & 0 deletions pytorch_optimizer/optimizer/dadapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(
weight_decouple: bool = False,
fixed_decay: bool = False,
eps: float = 0.0,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_range(momentum, 'momentum', 0.0, 1.0, range_type='[)')
Expand Down Expand Up @@ -266,6 +267,7 @@ def __init__(
fixed_decay: bool = False,
bias_correction: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down Expand Up @@ -423,6 +425,7 @@ def __init__(
weight_decay: float = 0.0,
weight_decouple: bool = False,
fixed_decay: bool = False,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_range(momentum, 'momentum', 0.0, 1.0, range_type='[)')
Expand Down Expand Up @@ -560,6 +563,7 @@ def __init__(
d0: float = 1e-6,
growth_rate: float = float('inf'),
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down Expand Up @@ -721,6 +725,7 @@ def __init__(
weight_decay: float = 0.0,
weight_decouple: bool = False,
fixed_decay: bool = False,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/diffgrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
adanorm: bool = False,
adam_debias: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/fadam.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
eps: float = 1e-8,
momentum_dtype: torch.dtype = torch.float32,
fim_dtype: torch.dtype = torch.float32,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
2 changes: 1 addition & 1 deletion pytorch_optimizer/optimizer/fromage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Fromage(BaseOptimizer):
norms to lie within 2x their initial norms. This regularises the model class.
"""

def __init__(self, params: PARAMETERS, lr: float = 1e-2, p_bound: Optional[float] = None):
def __init__(self, params: PARAMETERS, lr: float = 1e-2, p_bound: Optional[float] = None, **kwargs):
self.validate_learning_rate(lr)

self.p_bound = p_bound
Expand Down
7 changes: 6 additions & 1 deletion pytorch_optimizer/optimizer/galore.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ class GaLoreProjector:
"""

def __init__(
self, rank: int = 128, update_proj_gap: int = 50, scale: float = 1.0, projection_type: PROJECTION_TYPE = 'std'
self,
rank: int = 128,
update_proj_gap: int = 50,
scale: float = 1.0,
projection_type: PROJECTION_TYPE = 'std',
**kwargs,
):
self.rank = rank
self.update_proj_gap = update_proj_gap
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(
lr: float = 1e-2,
alpha: float = 0.01,
beta: float = 0.9,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_range(alpha, 'alpha', 0.0, 1.0)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/grokfast.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def __init__(
fixed_decay: bool = False,
normalize_lr: bool = True,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/kate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(
weight_decouple: bool = True,
fixed_decay: bool = False,
eps: float = 1e-8,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_range(delta, 'delta', 0.0, 1.0, '[)')
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/lamb.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(
adanorm: bool = False,
adam_debias: bool = False,
eps: float = 1e-6,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/lars.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(
dampening: float = 0.0,
trust_coefficient: float = 1e-3,
nesterov: bool = False,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_non_negative(weight_decay, 'weight_decay')
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/lion.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
use_gc: bool = False,
r: float = 0.95,
adanorm: bool = False,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_betas(betas)
Expand Down
2 changes: 2 additions & 0 deletions pytorch_optimizer/optimizer/lomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
lr: float = 1e-3,
clip_grad_norm: Optional[float] = None,
clip_grad_value: Optional[float] = None,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_non_negative(clip_grad_norm, 'clip_grad_norm')
Expand Down Expand Up @@ -228,6 +229,7 @@ def __init__(
clip_grad_value: Optional[float] = None,
eps1: float = 1e-30,
eps2: float = 1e-3,
**kwargs,
) -> None: # fmt: skip
self.validate_learning_rate(lr)
self.validate_non_negative(weight_decay, 'weight_decay')
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/lookahead.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(
k: int = 5,
alpha: float = 0.5,
pullback_momentum: str = 'none',
**kwargs,
) -> None:
self.validate_positive(k, 'k')
self.validate_range(alpha, 'alpha', 0.0, 1.0)
Expand Down
1 change: 1 addition & 0 deletions pytorch_optimizer/optimizer/madgrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
weight_decay: float = 0.0,
weight_decouple: bool = False,
eps: float = 1e-6,
**kwargs,
):
self.validate_learning_rate(lr)
self.validate_non_negative(weight_decay, 'weight_decay')
Expand Down
Loading

0 comments on commit 5a65b51

Please sign in to comment.