pytorch-optimizer 3.1.1__tar.gz → 3.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/PKG-INFO +42 -12
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/README.md +35 -7
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pyproject.toml +54 -49
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/__init__.py +89 -10
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/types.py +2 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/rex.py +1 -1
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/a2grad.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adabelief.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adabound.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adadelta.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adafactor.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adahessian.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adai.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adalite.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adam_mini.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamax.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamg.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamod.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamp.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adams.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamw.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adan.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adanorm.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adapnm.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adashift.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adasmooth.py +1 -0
- pytorch_optimizer-3.2.0/pytorch_optimizer/optimizer/ademamix.py +149 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/aggmo.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/aida.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/alig.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/amos.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/apollo.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/avagrad.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/came.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/dadapt.py +5 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/diffgrad.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/fadam.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/fromage.py +1 -1
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/galore.py +6 -1
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/gravity.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/grokfast.py +3 -2
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/kate.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lamb.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lars.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lion.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lomo.py +2 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lookahead.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/madgrad.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/msvag.py +7 -1
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/nero.py +7 -1
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/novograd.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/padam.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/pid.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/pnm.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/prodigy.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/qhadam.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/qhm.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/radam.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/ranger.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/ranger21.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/rotograd.py +1 -1
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/schedulefree.py +2 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sgd.py +4 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sgdp.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/shampoo.py +2 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/shampoo_utils.py +1 -1
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sm3.py +1 -0
- pytorch_optimizer-3.2.0/pytorch_optimizer/optimizer/soap.py +341 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sophia.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/srmm.py +8 -1
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/swats.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/tiger.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/trac.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/utils.py +151 -4
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/yogi.py +1 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/LICENSE +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/__init__.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/exception.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/optimizer.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/scheduler.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/__init__.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/bi_tempered.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/cross_entropy.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/dice.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/f1.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/focal.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/jaccard.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/ldam.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/lovasz.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/tversky.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/__init__.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/chebyshev.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/cosine_anealing.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/experimental/__init__.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/experimental/deberta_v3_lr_scheduler.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/linear_warmup.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/proportion.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/wsd.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/__init__.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/agc.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/fp16.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/gc.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/pcgrad.py +0 -0
- {pytorch_optimizer-3.1.1 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sam.py +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pytorch_optimizer
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: optimizer & lr scheduler & objective function collections in PyTorch
|
|
5
5
|
Home-page: https://github.com/kozistr/pytorch_optimizer
|
|
6
6
|
License: Apache-2.0
|
|
7
|
-
Keywords: pytorch,deep-learning,optimizer,lr scheduler,A2Grad,ASGD,AccSGD,AdaBelief,AdaBound,AdaDelta,AdaFactor,AdaMax,AdamG,AdaMod,AdaNorm,AdaPNM,AdaSmooth,AdaHessian,Adai,Adalite,AdaLomo,AdamMini,AdamP,AdamS,Adan,AggMo,Aida,AliG,Amos,Apollo,AvaGrad,bSAM,CAME,DAdaptAdaGrad,DAdaptAdam,DAdaptAdan,DAdaptSGD,DAdaptLion,DiffGrad,FAdam,Fromage,GaLore,Gravity,GrokFast,GSAM,Kate,Lamb,LARS,Lion,LOMO,Lookahead,MADGRAD,MSVAG,Nero,NovoGrad,PAdam,PCGrad,PID,PNM,Prodigy,QHAdam,QHM,RAdam,Ranger,Ranger21,RotoGrad,SAM,ScheduleFreeSGD,ScheduleFreeAdamW,SGDP,Shampoo,ScalableShampoo,SGDW,SignSGD,SM3,SopihaH,SRMM,StableAdamW,SWATS,Tiger,TRAC,WSAM,Yogi,BCE,BCEFocal,Focal,FocalCosine,SoftF1,Dice,LDAM,Jaccard,Bi-Tempered,Tversky,FocalTversky,LovaszHinge,bitsandbytes,WSD,QGaLore
|
|
7
|
+
Keywords: pytorch,deep-learning,optimizer,lr scheduler,A2Grad,ASGD,AccSGD,AdaBelief,AdaBound,AdaDelta,AdaFactor,AdaMax,AdamG,AdaMod,AdaNorm,AdaPNM,AdaSmooth,AdEMAMix,AdaHessian,Adai,Adalite,AdaLomo,AdamMini,AdamP,AdamS,Adan,AggMo,Aida,AliG,Amos,Apollo,AvaGrad,bSAM,CAME,DAdaptAdaGrad,DAdaptAdam,DAdaptAdan,DAdaptSGD,DAdaptLion,DiffGrad,FAdam,Fromage,GaLore,Gravity,GrokFast,GSAM,Kate,Lamb,LARS,Lion,LOMO,Lookahead,MADGRAD,MSVAG,Nero,NovoGrad,PAdam,PCGrad,PID,PNM,Prodigy,QHAdam,QHM,RAdam,Ranger,Ranger21,RotoGrad,SAM,ScheduleFreeSGD,ScheduleFreeAdamW,SGDP,Shampoo,ScalableShampoo,SGDW,SignSGD,SM3,SOAP,SopihaH,SRMM,StableAdamW,SWATS,Tiger,TRAC,WSAM,Yogi,BCE,BCEFocal,Focal,FocalCosine,SoftF1,Dice,LDAM,Jaccard,Bi-Tempered,Tversky,FocalTversky,LovaszHinge,bitsandbytes,WSD,QGaLore
|
|
8
8
|
Author: kozistr
|
|
9
9
|
Author-email: kozistr@gmail.com
|
|
10
10
|
Maintainer: kozistr
|
|
11
11
|
Maintainer-email: kozistr@gmail.com
|
|
12
|
-
Requires-Python: >=3.8
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
13
|
Classifier: Development Status :: 5 - Production/Stable
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
15
|
Classifier: Intended Audience :: Education
|
|
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.10
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.11
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
26
|
Classifier: Programming Language :: Python :: 3.6
|
|
26
27
|
Classifier: Programming Language :: Python :: 3.7
|
|
27
28
|
Classifier: Topic :: Scientific/Engineering
|
|
@@ -30,8 +31,9 @@ Classifier: Topic :: Software Development
|
|
|
30
31
|
Classifier: Topic :: Software Development :: Libraries
|
|
31
32
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
32
33
|
Provides-Extra: bitsandbytes
|
|
33
|
-
Requires-Dist: bitsandbytes (>=0.
|
|
34
|
-
Requires-Dist: numpy ; python_version
|
|
34
|
+
Requires-Dist: bitsandbytes (>=0.44,<0.45) ; extra == "bitsandbytes"
|
|
35
|
+
Requires-Dist: numpy (<=1.24.4) ; python_version < "3.9"
|
|
36
|
+
Requires-Dist: numpy (>1.24.4) ; python_version >= "3.9"
|
|
35
37
|
Requires-Dist: torch (>=1.10) ; python_version >= "3.8"
|
|
36
38
|
Project-URL: Documentation, https://pytorch-optimizers.readthedocs.io/en/latest
|
|
37
39
|
Project-URL: Repository, https://github.com/kozistr/pytorch_optimizer
|
|
@@ -49,7 +51,7 @@ Description-Content-Type: text/markdown
|
|
|
49
51
|
|
|
50
52
|
**pytorch-optimizer** is optimizer & lr scheduler collections in PyTorch.
|
|
51
53
|
I just re-implemented (speed & memory tweaks, plug-ins) the algorithm while based on the original paper. Also, It includes useful and practical optimization ideas.
|
|
52
|
-
Currently, **
|
|
54
|
+
Currently, **77 optimizers (+ `bitsandbytes`, `qgalore`, `torchao`)**, **16 lr schedulers**, and **13 loss functions** are supported!
|
|
53
55
|
|
|
54
56
|
Highly inspired by [pytorch-optimizer](https://github.com/jettify/pytorch-optimizer).
|
|
55
57
|
|
|
@@ -66,16 +68,12 @@ So, please double-check the license before using it at your work.
|
|
|
66
68
|
$ pip3 install pytorch-optimizer
|
|
67
69
|
```
|
|
68
70
|
|
|
69
|
-
From `v2.12.0`, `v3.1.0`, you can use `bitsandbytes`, `q-galore-torch` optimizers respectively!
|
|
70
|
-
please check [the bnb requirements](https://github.com/TimDettmers/bitsandbytes?tab=readme-ov-file#tldr), [q-galore-torch installation](https://github.com/VITA-Group/Q-GaLore?tab=readme-ov-file#install-q-galore-optimizer)
|
|
71
|
+
From `v2.12.0`, `v3.1.0`, you can use `bitsandbytes`, `q-galore-torch`, `torchao` optimizers respectively!
|
|
72
|
+
please check [the bnb requirements](https://github.com/TimDettmers/bitsandbytes?tab=readme-ov-file#tldr), [q-galore-torch installation](https://github.com/VITA-Group/Q-GaLore?tab=readme-ov-file#install-q-galore-optimizer), [torchao installation](https://github.com/pytorch/ao?tab=readme-ov-file#installation)
|
|
71
73
|
before installing it.
|
|
72
74
|
|
|
73
75
|
From `v3.0.0`, drop `Python 3.7` support. However, you can still use this package with `Python 3.7` by installing with `--ignore-requires-python` option.
|
|
74
76
|
|
|
75
|
-
```bash
|
|
76
|
-
$ pip install "pytorch-optimizer[bitsandbytes]"
|
|
77
|
-
```
|
|
78
|
-
|
|
79
77
|
### Simple Usage
|
|
80
78
|
|
|
81
79
|
```python
|
|
@@ -133,6 +131,16 @@ from pytorch_optimizer import get_supported_optimizers
|
|
|
133
131
|
supported_optimizers = get_supported_optimizers()
|
|
134
132
|
```
|
|
135
133
|
|
|
134
|
+
or you can also search them with the filter(s).
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
>>> get_supported_optimizers('adam*')
|
|
138
|
+
['adamax', 'adamg', 'adammini', 'adamod', 'adamp', 'adams', 'adamw']
|
|
139
|
+
|
|
140
|
+
>>> get_supported_optimizers(['adam*', 'ranger*'])
|
|
141
|
+
['adamax', 'adamg', 'adammini', 'adamod', 'adamp', 'adams', 'adamw', 'ranger', 'ranger21']
|
|
142
|
+
```
|
|
143
|
+
|
|
136
144
|
| Optimizer | Description | Official Code | Paper | Citation |
|
|
137
145
|
|---------------|---------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
|
|
138
146
|
| AdaBelief | *Adapting Step-sizes by the Belief in Observed Gradients* | [github](https://github.com/juntang-zhuang/Adabelief-Optimizer) | <https://arxiv.org/abs/2010.07468> | [cite](https://ui.adsabs.harvard.edu/abs/2020arXiv201007468Z/exportcitation) |
|
|
@@ -212,6 +220,8 @@ supported_optimizers = get_supported_optimizers()
|
|
|
212
220
|
| AdamMini | *Use Fewer Learning Rates To Gain More* | [github](https://github.com/zyushun/Adam-mini) | <https://arxiv.org/abs/2406.16793> | [cite](https://github.com/zyushun/Adam-mini?tab=readme-ov-file#citation) |
|
|
213
221
|
| TRAC | *Adaptive Parameter-free Optimization* | [github](https://github.com/ComputationalRobotics/TRAC) | <https://arxiv.org/abs/2405.16642> | [cite](https://ui.adsabs.harvard.edu/abs/2024arXiv240516642M/exportcitation) |
|
|
214
222
|
| AdamG | *Towards Stability of Parameter-free Optimization* | | <https://arxiv.org/abs/2405.04376> | [cite](https://ui.adsabs.harvard.edu/abs/2024arXiv240504376P/exportcitation) |
|
|
223
|
+
| AdEMAMix | *Better, Faster, Older* | [github](https://github.com/nanowell/AdEMAMix-Optimizer-Pytorch) | <https://arxiv.org/abs/2409.03137> | [cite](https://github.com/nanowell/AdEMAMix-Optimizer-Pytorch?tab=readme-ov-file#reference) |
|
|
224
|
+
| SOAP | *Improving and Stabilizing Shampoo using Adam* | [github](https://github.com/nikhilvyas/SOAP) | <https://arxiv.org/abs/2409.11321> | [cite](https://ui.adsabs.harvard.edu/abs/2024arXiv240911321V/exportcitation) |
|
|
215
225
|
|
|
216
226
|
## Supported LR Scheduler
|
|
217
227
|
|
|
@@ -223,6 +233,16 @@ from pytorch_optimizer import get_supported_lr_schedulers
|
|
|
223
233
|
supported_lr_schedulers = get_supported_lr_schedulers()
|
|
224
234
|
```
|
|
225
235
|
|
|
236
|
+
or you can also search them with the filter(s).
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
>>> get_supported_lr_schedulers('cosine*')
|
|
240
|
+
['cosine', 'cosine_annealing', 'cosine_annealing_with_warm_restart', 'cosine_annealing_with_warmup']
|
|
241
|
+
|
|
242
|
+
>>> get_supported_lr_schedulers(['cosine*', '*warm*'])
|
|
243
|
+
['cosine', 'cosine_annealing', 'cosine_annealing_with_warm_restart', 'cosine_annealing_with_warmup', 'warmup_stable_decay']
|
|
244
|
+
```
|
|
245
|
+
|
|
226
246
|
| LR Scheduler | Description | Official Code | Paper | Citation |
|
|
227
247
|
|-----------------|---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|----------------------------------------------------------------------------------------------------|
|
|
228
248
|
| Explore-Exploit | *Wide-minima Density Hypothesis and the Explore-Exploit Learning Rate Schedule* | | <https://arxiv.org/abs/2003.03977> | [cite](https://ui.adsabs.harvard.edu/abs/2020arXiv200303977I/exportcitation) |
|
|
@@ -240,6 +260,16 @@ from pytorch_optimizer import get_supported_loss_functions
|
|
|
240
260
|
supported_loss_functions = get_supported_loss_functions()
|
|
241
261
|
```
|
|
242
262
|
|
|
263
|
+
or you can also search them with the filter(s).
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
>>> get_supported_loss_functions('*focal*')
|
|
267
|
+
['bcefocalloss', 'focalcosineloss', 'focalloss', 'focaltverskyloss']
|
|
268
|
+
|
|
269
|
+
>>> get_supported_loss_functions(['*focal*', 'bce*'])
|
|
270
|
+
['bcefocalloss', 'bceloss', 'focalcosineloss', 'focalloss', 'focaltverskyloss']
|
|
271
|
+
```
|
|
272
|
+
|
|
243
273
|
| Loss Functions | Description | Official Code | Paper | Citation |
|
|
244
274
|
|-----------------|-------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|------------------------------------|------------------------------------------------------------------------------|
|
|
245
275
|
| Label Smoothing | *Rethinking the Inception Architecture for Computer Vision* | | <https://arxiv.org/abs/1512.00567> | [cite](https://ui.adsabs.harvard.edu/abs/2015arXiv151200567S/exportcitation) |
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
**pytorch-optimizer** is optimizer & lr scheduler collections in PyTorch.
|
|
12
12
|
I just re-implemented (speed & memory tweaks, plug-ins) the algorithm while based on the original paper. Also, It includes useful and practical optimization ideas.
|
|
13
|
-
Currently, **
|
|
13
|
+
Currently, **77 optimizers (+ `bitsandbytes`, `qgalore`, `torchao`)**, **16 lr schedulers**, and **13 loss functions** are supported!
|
|
14
14
|
|
|
15
15
|
Highly inspired by [pytorch-optimizer](https://github.com/jettify/pytorch-optimizer).
|
|
16
16
|
|
|
@@ -27,16 +27,12 @@ So, please double-check the license before using it at your work.
|
|
|
27
27
|
$ pip3 install pytorch-optimizer
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
From `v2.12.0`, `v3.1.0`, you can use `bitsandbytes`, `q-galore-torch` optimizers respectively!
|
|
31
|
-
please check [the bnb requirements](https://github.com/TimDettmers/bitsandbytes?tab=readme-ov-file#tldr), [q-galore-torch installation](https://github.com/VITA-Group/Q-GaLore?tab=readme-ov-file#install-q-galore-optimizer)
|
|
30
|
+
From `v2.12.0`, `v3.1.0`, you can use `bitsandbytes`, `q-galore-torch`, `torchao` optimizers respectively!
|
|
31
|
+
please check [the bnb requirements](https://github.com/TimDettmers/bitsandbytes?tab=readme-ov-file#tldr), [q-galore-torch installation](https://github.com/VITA-Group/Q-GaLore?tab=readme-ov-file#install-q-galore-optimizer), [torchao installation](https://github.com/pytorch/ao?tab=readme-ov-file#installation)
|
|
32
32
|
before installing it.
|
|
33
33
|
|
|
34
34
|
From `v3.0.0`, drop `Python 3.7` support. However, you can still use this package with `Python 3.7` by installing with `--ignore-requires-python` option.
|
|
35
35
|
|
|
36
|
-
```bash
|
|
37
|
-
$ pip install "pytorch-optimizer[bitsandbytes]"
|
|
38
|
-
```
|
|
39
|
-
|
|
40
36
|
### Simple Usage
|
|
41
37
|
|
|
42
38
|
```python
|
|
@@ -94,6 +90,16 @@ from pytorch_optimizer import get_supported_optimizers
|
|
|
94
90
|
supported_optimizers = get_supported_optimizers()
|
|
95
91
|
```
|
|
96
92
|
|
|
93
|
+
or you can also search them with the filter(s).
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
>>> get_supported_optimizers('adam*')
|
|
97
|
+
['adamax', 'adamg', 'adammini', 'adamod', 'adamp', 'adams', 'adamw']
|
|
98
|
+
|
|
99
|
+
>>> get_supported_optimizers(['adam*', 'ranger*'])
|
|
100
|
+
['adamax', 'adamg', 'adammini', 'adamod', 'adamp', 'adams', 'adamw', 'ranger', 'ranger21']
|
|
101
|
+
```
|
|
102
|
+
|
|
97
103
|
| Optimizer | Description | Official Code | Paper | Citation |
|
|
98
104
|
|---------------|---------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
|
|
99
105
|
| AdaBelief | *Adapting Step-sizes by the Belief in Observed Gradients* | [github](https://github.com/juntang-zhuang/Adabelief-Optimizer) | <https://arxiv.org/abs/2010.07468> | [cite](https://ui.adsabs.harvard.edu/abs/2020arXiv201007468Z/exportcitation) |
|
|
@@ -173,6 +179,8 @@ supported_optimizers = get_supported_optimizers()
|
|
|
173
179
|
| AdamMini | *Use Fewer Learning Rates To Gain More* | [github](https://github.com/zyushun/Adam-mini) | <https://arxiv.org/abs/2406.16793> | [cite](https://github.com/zyushun/Adam-mini?tab=readme-ov-file#citation) |
|
|
174
180
|
| TRAC | *Adaptive Parameter-free Optimization* | [github](https://github.com/ComputationalRobotics/TRAC) | <https://arxiv.org/abs/2405.16642> | [cite](https://ui.adsabs.harvard.edu/abs/2024arXiv240516642M/exportcitation) |
|
|
175
181
|
| AdamG | *Towards Stability of Parameter-free Optimization* | | <https://arxiv.org/abs/2405.04376> | [cite](https://ui.adsabs.harvard.edu/abs/2024arXiv240504376P/exportcitation) |
|
|
182
|
+
| AdEMAMix | *Better, Faster, Older* | [github](https://github.com/nanowell/AdEMAMix-Optimizer-Pytorch) | <https://arxiv.org/abs/2409.03137> | [cite](https://github.com/nanowell/AdEMAMix-Optimizer-Pytorch?tab=readme-ov-file#reference) |
|
|
183
|
+
| SOAP | *Improving and Stabilizing Shampoo using Adam* | [github](https://github.com/nikhilvyas/SOAP) | <https://arxiv.org/abs/2409.11321> | [cite](https://ui.adsabs.harvard.edu/abs/2024arXiv240911321V/exportcitation) |
|
|
176
184
|
|
|
177
185
|
## Supported LR Scheduler
|
|
178
186
|
|
|
@@ -184,6 +192,16 @@ from pytorch_optimizer import get_supported_lr_schedulers
|
|
|
184
192
|
supported_lr_schedulers = get_supported_lr_schedulers()
|
|
185
193
|
```
|
|
186
194
|
|
|
195
|
+
or you can also search them with the filter(s).
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
>>> get_supported_lr_schedulers('cosine*')
|
|
199
|
+
['cosine', 'cosine_annealing', 'cosine_annealing_with_warm_restart', 'cosine_annealing_with_warmup']
|
|
200
|
+
|
|
201
|
+
>>> get_supported_lr_schedulers(['cosine*', '*warm*'])
|
|
202
|
+
['cosine', 'cosine_annealing', 'cosine_annealing_with_warm_restart', 'cosine_annealing_with_warmup', 'warmup_stable_decay']
|
|
203
|
+
```
|
|
204
|
+
|
|
187
205
|
| LR Scheduler | Description | Official Code | Paper | Citation |
|
|
188
206
|
|-----------------|---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|----------------------------------------------------------------------------------------------------|
|
|
189
207
|
| Explore-Exploit | *Wide-minima Density Hypothesis and the Explore-Exploit Learning Rate Schedule* | | <https://arxiv.org/abs/2003.03977> | [cite](https://ui.adsabs.harvard.edu/abs/2020arXiv200303977I/exportcitation) |
|
|
@@ -201,6 +219,16 @@ from pytorch_optimizer import get_supported_loss_functions
|
|
|
201
219
|
supported_loss_functions = get_supported_loss_functions()
|
|
202
220
|
```
|
|
203
221
|
|
|
222
|
+
or you can also search them with the filter(s).
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
>>> get_supported_loss_functions('*focal*')
|
|
226
|
+
['bcefocalloss', 'focalcosineloss', 'focalloss', 'focaltverskyloss']
|
|
227
|
+
|
|
228
|
+
>>> get_supported_loss_functions(['*focal*', 'bce*'])
|
|
229
|
+
['bcefocalloss', 'bceloss', 'focalcosineloss', 'focalloss', 'focaltverskyloss']
|
|
230
|
+
```
|
|
231
|
+
|
|
204
232
|
| Loss Functions | Description | Official Code | Paper | Citation |
|
|
205
233
|
|-----------------|-------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|------------------------------------|------------------------------------------------------------------------------|
|
|
206
234
|
| Label Smoothing | *Rethinking the Inception Architecture for Computer Vision* | | <https://arxiv.org/abs/1512.00567> | [cite](https://ui.adsabs.harvard.edu/abs/2015arXiv151200567S/exportcitation) |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "pytorch_optimizer"
|
|
3
|
-
version = "3.
|
|
3
|
+
version = "3.2.0"
|
|
4
4
|
description = "optimizer & lr scheduler & objective function collections in PyTorch"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
authors = ["kozistr <kozistr@gmail.com>"]
|
|
@@ -11,15 +11,15 @@ repository = "https://github.com/kozistr/pytorch_optimizer"
|
|
|
11
11
|
documentation = "https://pytorch-optimizers.readthedocs.io/en/latest"
|
|
12
12
|
keywords = [
|
|
13
13
|
"pytorch", "deep-learning", "optimizer", "lr scheduler", "A2Grad", "ASGD", "AccSGD", "AdaBelief", "AdaBound",
|
|
14
|
-
"AdaDelta", "AdaFactor", "AdaMax", "AdamG", "AdaMod", "AdaNorm", "AdaPNM", "AdaSmooth", "
|
|
15
|
-
"Adalite", "AdaLomo", "AdamMini", "AdamP", "AdamS", "Adan", "AggMo", "Aida", "AliG", "Amos", "Apollo",
|
|
16
|
-
"bSAM", "CAME", "DAdaptAdaGrad", "DAdaptAdam", "DAdaptAdan", "DAdaptSGD", "DAdaptLion", "DiffGrad",
|
|
17
|
-
"Fromage", "GaLore", "Gravity", "GrokFast", "GSAM", "Kate", "Lamb", "LARS", "Lion", "LOMO", "Lookahead",
|
|
18
|
-
"MSVAG", "Nero", "NovoGrad", "PAdam", "PCGrad", "PID", "PNM", "Prodigy", "QHAdam", "QHM", "RAdam",
|
|
19
|
-
"Ranger21", "RotoGrad", "SAM", "ScheduleFreeSGD", "ScheduleFreeAdamW", "SGDP", "Shampoo",
|
|
20
|
-
"
|
|
21
|
-
"Focal", "FocalCosine", "SoftF1", "Dice", "LDAM", "Jaccard", "Bi-Tempered",
|
|
22
|
-
"LovaszHinge", "bitsandbytes", "WSD", "QGaLore",
|
|
14
|
+
"AdaDelta", "AdaFactor", "AdaMax", "AdamG", "AdaMod", "AdaNorm", "AdaPNM", "AdaSmooth", "AdEMAMix", "AdaHessian",
|
|
15
|
+
"Adai", "Adalite", "AdaLomo", "AdamMini", "AdamP", "AdamS", "Adan", "AggMo", "Aida", "AliG", "Amos", "Apollo",
|
|
16
|
+
"AvaGrad", "bSAM", "CAME", "DAdaptAdaGrad", "DAdaptAdam", "DAdaptAdan", "DAdaptSGD", "DAdaptLion", "DiffGrad",
|
|
17
|
+
"FAdam", "Fromage", "GaLore", "Gravity", "GrokFast", "GSAM", "Kate", "Lamb", "LARS", "Lion", "LOMO", "Lookahead",
|
|
18
|
+
"MADGRAD", "MSVAG", "Nero", "NovoGrad", "PAdam", "PCGrad", "PID", "PNM", "Prodigy", "QHAdam", "QHM", "RAdam",
|
|
19
|
+
"Ranger", "Ranger21", "RotoGrad", "SAM", "ScheduleFreeSGD", "ScheduleFreeAdamW", "SGDP", "Shampoo",
|
|
20
|
+
"ScalableShampoo", "SGDW", "SignSGD", "SM3", "SOAP", "SopihaH", "SRMM", "StableAdamW", "SWATS", "Tiger", "TRAC",
|
|
21
|
+
"WSAM", "Yogi", "BCE", "BCEFocal", "Focal", "FocalCosine", "SoftF1", "Dice", "LDAM", "Jaccard", "Bi-Tempered",
|
|
22
|
+
"Tversky", "FocalTversky", "LovaszHinge", "bitsandbytes", "WSD", "QGaLore",
|
|
23
23
|
]
|
|
24
24
|
classifiers = [
|
|
25
25
|
"License :: OSI Approved :: Apache Software License",
|
|
@@ -35,6 +35,7 @@ classifiers = [
|
|
|
35
35
|
"Programming Language :: Python :: 3.10",
|
|
36
36
|
"Programming Language :: Python :: 3.11",
|
|
37
37
|
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Programming Language :: Python :: 3.13",
|
|
38
39
|
"Operating System :: OS Independent",
|
|
39
40
|
"Topic :: Scientific/Engineering",
|
|
40
41
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
@@ -44,10 +45,13 @@ classifiers = [
|
|
|
44
45
|
]
|
|
45
46
|
|
|
46
47
|
[tool.poetry.dependencies]
|
|
47
|
-
python = ">=3.8
|
|
48
|
-
numpy =
|
|
48
|
+
python = ">=3.8"
|
|
49
|
+
numpy = [
|
|
50
|
+
{ version = ">1.24.4", python = ">=3.9" },
|
|
51
|
+
{ version = "<=1.24.4", python = "<3.9" },
|
|
52
|
+
]
|
|
49
53
|
torch = { version = ">=1.10", python = ">=3.8", source = "torch" }
|
|
50
|
-
bitsandbytes = { version = "^0.
|
|
54
|
+
bitsandbytes = { version = "^0.44", optional = true }
|
|
51
55
|
|
|
52
56
|
[tool.poetry.dev-dependencies]
|
|
53
57
|
isort = { version = "^5", python = ">=3.8" }
|
|
@@ -65,20 +69,13 @@ url = "https://download.pytorch.org/whl/cpu"
|
|
|
65
69
|
priority = "explicit"
|
|
66
70
|
|
|
67
71
|
[tool.ruff]
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
lint.ignore = [
|
|
73
|
-
"B905", "D100", "D102", "D104", "D105", "D107", "D203", "D213", "D413", "PIE790", "PLR0912", "PLR0913", "PLR0915",
|
|
74
|
-
"PLR2004", "RUF013", "Q003",
|
|
72
|
+
src = [
|
|
73
|
+
"pytorch_optimizer",
|
|
74
|
+
"tests",
|
|
75
|
+
"examples",
|
|
75
76
|
]
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
79
|
-
lint.flake8-quotes.docstring-quotes = "double"
|
|
80
|
-
lint.flake8-quotes.inline-quotes = "single"
|
|
81
|
-
lint.pylint.max-args = 7
|
|
77
|
+
target-version = "py312"
|
|
78
|
+
line-length = 119
|
|
82
79
|
exclude = [
|
|
83
80
|
".git",
|
|
84
81
|
".github",
|
|
@@ -92,32 +89,40 @@ exclude = [
|
|
|
92
89
|
".venv",
|
|
93
90
|
"__pypackages__",
|
|
94
91
|
]
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
|
|
93
|
+
[tool.ruff.lint]
|
|
94
|
+
select = [
|
|
95
|
+
"A", "B", "C4", "D", "E", "F", "G", "I", "N", "S", "T", "ISC", "ICN", "W", "INP", "PIE", "T20", "RET", "SIM",
|
|
96
|
+
"TID", "ARG", "ERA", "RUF", "YTT", "PL", "Q"
|
|
97
|
+
]
|
|
98
|
+
ignore = [
|
|
99
|
+
"B905", "D100", "D102", "D104", "D105", "D107", "D203", "D213", "D413", "PIE790", "PLR0912", "PLR0913", "PLR0915",
|
|
100
|
+
"PLR2004", "RUF013", "Q003", "ARG002",
|
|
101
|
+
]
|
|
102
|
+
fixable = ["ALL"]
|
|
103
|
+
unfixable = ["F401"]
|
|
104
|
+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
105
|
+
flake8-quotes.docstring-quotes = "double"
|
|
106
|
+
flake8-quotes.inline-quotes = "single"
|
|
107
|
+
|
|
108
|
+
[tool.ruff.lint.extend-per-file-ignores]
|
|
109
|
+
"hubconf.py" = ["D", "INP001"]
|
|
110
|
+
"examples/visualize_optimizers.py" = ["D103", "D400", "D415"]
|
|
111
|
+
"**/__init__.py" = ["F401"]
|
|
112
|
+
"{tests,examples}/*.py" = ["D", "S101"]
|
|
113
|
+
|
|
114
|
+
[tool.ruff.lint.isort]
|
|
115
|
+
combine-as-imports = false
|
|
116
|
+
detect-same-package = true
|
|
117
|
+
force-sort-within-sections = false
|
|
118
|
+
known-first-party = ["pytorch_optimizer"]
|
|
119
|
+
|
|
120
|
+
[tool.ruff.lint.pylint]
|
|
121
|
+
max-args = 7
|
|
97
122
|
|
|
98
123
|
[tool.ruff.format]
|
|
99
124
|
quote-style = "single"
|
|
100
125
|
|
|
101
|
-
[tool.ruff.lint.per-file-ignores]
|
|
102
|
-
"./pytorch_optimizer/__init__.py" = ["F401"]
|
|
103
|
-
"./pytorch_optimizer/lr_scheduler/__init__.py" = ["F401"]
|
|
104
|
-
"./hubconf.py" = ["D", "INP001"]
|
|
105
|
-
"./examples/visualize_optimizers.py" = ["D103", "D400", "D415"]
|
|
106
|
-
"./tests/__init__.py" = ["D"]
|
|
107
|
-
"./tests/constants.py" = ["D"]
|
|
108
|
-
"./tests/utils.py" = ["D"]
|
|
109
|
-
"./tests/test_base.py" = ["D", "S101"]
|
|
110
|
-
"./tests/test_utils.py" = ["D", "S101", "ERA001"]
|
|
111
|
-
"./tests/test_gradients.py" = ["D", "S101"]
|
|
112
|
-
"./tests/test_optimizers.py" = ["D", "S101"]
|
|
113
|
-
"./tests/test_optimizer_parameters.py" = ["D", "S101"]
|
|
114
|
-
"./tests/test_general_optimizer_parameters.py" = ["D", "S101"]
|
|
115
|
-
"./tests/test_lr_schedulers.py" = ["D", "S101"]
|
|
116
|
-
"./tests/test_lr_scheduler_parameters.py" = ["D", "S101"]
|
|
117
|
-
"./tests/test_create_optimizer.py" = ["D"]
|
|
118
|
-
"./tests/test_loss_functions.py" = ["D", "S101"]
|
|
119
|
-
"./tests/test_load_modules.py" = ["D", "S101"]
|
|
120
|
-
|
|
121
126
|
[tool.pytest.ini_options]
|
|
122
127
|
testpaths = "tests"
|
|
123
128
|
|
|
@@ -128,5 +133,5 @@ omit = [
|
|
|
128
133
|
]
|
|
129
134
|
|
|
130
135
|
[build-system]
|
|
131
|
-
requires = ["poetry-core>=1.
|
|
136
|
+
requires = ["poetry-core>=1.4.0"]
|
|
132
137
|
build-backend = "poetry.core.masonry.api"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# ruff: noqa
|
|
2
|
+
import fnmatch
|
|
2
3
|
from importlib.util import find_spec
|
|
3
|
-
from typing import Dict, List
|
|
4
|
+
from typing import Dict, List, Optional, Sequence, Set, Union
|
|
4
5
|
|
|
5
6
|
import torch.cuda
|
|
6
7
|
from torch import nn
|
|
@@ -54,6 +55,7 @@ from pytorch_optimizer.optimizer.adanorm import AdaNorm
|
|
|
54
55
|
from pytorch_optimizer.optimizer.adapnm import AdaPNM
|
|
55
56
|
from pytorch_optimizer.optimizer.adashift import AdaShift
|
|
56
57
|
from pytorch_optimizer.optimizer.adasmooth import AdaSmooth
|
|
58
|
+
from pytorch_optimizer.optimizer.ademamix import AdEMAMix
|
|
57
59
|
from pytorch_optimizer.optimizer.agc import agc
|
|
58
60
|
from pytorch_optimizer.optimizer.aggmo import AggMo
|
|
59
61
|
from pytorch_optimizer.optimizer.aida import Aida
|
|
@@ -113,12 +115,14 @@ from pytorch_optimizer.optimizer.shampoo_utils import (
|
|
|
113
115
|
power_iteration,
|
|
114
116
|
)
|
|
115
117
|
from pytorch_optimizer.optimizer.sm3 import SM3
|
|
118
|
+
from pytorch_optimizer.optimizer.soap import SOAP
|
|
116
119
|
from pytorch_optimizer.optimizer.sophia import SophiaH
|
|
117
120
|
from pytorch_optimizer.optimizer.srmm import SRMM
|
|
118
121
|
from pytorch_optimizer.optimizer.swats import SWATS
|
|
119
122
|
from pytorch_optimizer.optimizer.tiger import Tiger
|
|
120
123
|
from pytorch_optimizer.optimizer.trac import TRAC
|
|
121
124
|
from pytorch_optimizer.optimizer.utils import (
|
|
125
|
+
CPUOffloadOptimizer,
|
|
122
126
|
clip_grad_norm,
|
|
123
127
|
disable_running_stats,
|
|
124
128
|
enable_running_stats,
|
|
@@ -132,6 +136,7 @@ from pytorch_optimizer.optimizer.yogi import Yogi
|
|
|
132
136
|
|
|
133
137
|
HAS_BNB: bool = find_spec('bitsandbytes') is not None
|
|
134
138
|
HAS_Q_GALORE: bool = find_spec('q-galore-torch') is not None
|
|
139
|
+
HAS_TORCHAO: bool = find_spec('torchao') is not None
|
|
135
140
|
|
|
136
141
|
OPTIMIZER_LIST: List[OPTIMIZER] = [
|
|
137
142
|
AdamW,
|
|
@@ -208,6 +213,8 @@ OPTIMIZER_LIST: List[OPTIMIZER] = [
|
|
|
208
213
|
AdamMini,
|
|
209
214
|
AdaLOMO,
|
|
210
215
|
AdamG,
|
|
216
|
+
AdEMAMix,
|
|
217
|
+
SOAP,
|
|
211
218
|
]
|
|
212
219
|
OPTIMIZERS: Dict[str, OPTIMIZER] = {str(optimizer.__name__).lower(): optimizer for optimizer in OPTIMIZER_LIST}
|
|
213
220
|
|
|
@@ -297,6 +304,15 @@ def load_bnb_optimizer(optimizer: str) -> OPTIMIZER: # pragma: no cover
|
|
|
297
304
|
return optim.RMSprop32bit
|
|
298
305
|
if 'sgd32bit' in optimizer:
|
|
299
306
|
return optim.SGD32bit
|
|
307
|
+
if 'ademamix8bit' in optimizer:
|
|
308
|
+
return optim.AdEMAMix8bit
|
|
309
|
+
if 'ademamix32bit' in optimizer:
|
|
310
|
+
return optim.AdEMAMix32bit
|
|
311
|
+
if 'paged_ademamix8bit' in optimizer:
|
|
312
|
+
return optim.PagedAdEMAMix8bit
|
|
313
|
+
if 'paged_ademamix32bit' in optimizer:
|
|
314
|
+
return optim.PagedAdEMAMix32bit
|
|
315
|
+
|
|
300
316
|
raise NotImplementedError(f'[-] not implemented optimizer : {optimizer}')
|
|
301
317
|
|
|
302
318
|
|
|
@@ -310,19 +326,40 @@ def load_q_galore_optimizer(optimizer: str) -> OPTIMIZER: # pragma: no cover
|
|
|
310
326
|
raise NotImplementedError(f'[-] not implemented optimizer : {optimizer}')
|
|
311
327
|
|
|
312
328
|
|
|
329
|
+
def load_ao_optimizer(optimizer: str) -> OPTIMIZER: # pragma: no cover
|
|
330
|
+
r"""load TorchAO optimizer instance."""
|
|
331
|
+
from torchao.prototype import low_bit_optim
|
|
332
|
+
|
|
333
|
+
if 'adamw8bit' in optimizer:
|
|
334
|
+
return low_bit_optim.AdamW8bit
|
|
335
|
+
if 'adamw4bit' in optimizer:
|
|
336
|
+
return low_bit_optim.AdamW4bit
|
|
337
|
+
if 'adamwfp8' in optimizer:
|
|
338
|
+
return low_bit_optim.AdamWFp8
|
|
339
|
+
|
|
340
|
+
raise NotImplementedError(f'[-] not implemented optimizer : {optimizer}')
|
|
341
|
+
|
|
342
|
+
|
|
313
343
|
def load_optimizer(optimizer: str) -> OPTIMIZER:
|
|
314
344
|
optimizer: str = optimizer.lower()
|
|
315
345
|
|
|
316
346
|
if optimizer.startswith('bnb'):
|
|
317
347
|
if HAS_BNB and torch.cuda.is_available():
|
|
318
348
|
return load_bnb_optimizer(optimizer) # pragma: no cover
|
|
319
|
-
raise ImportError(f'
|
|
349
|
+
raise ImportError(f'bitsandbytes and CUDA required for the optimizer {optimizer}')
|
|
320
350
|
if optimizer.startswith('q_galore'):
|
|
321
351
|
if HAS_Q_GALORE and torch.cuda.is_available():
|
|
322
352
|
return load_q_galore_optimizer(optimizer) # pragma: no cover
|
|
323
|
-
raise ImportError(f'
|
|
353
|
+
raise ImportError(f'bitsandbytes, q-galore-torch, and CUDA required for the optimizer {optimizer}')
|
|
354
|
+
if optimizer.startswith('torchao'):
|
|
355
|
+
if HAS_TORCHAO and torch.cuda.is_available():
|
|
356
|
+
return load_ao_optimizer(optimizer) # pragma: no cover
|
|
357
|
+
raise ImportError(
|
|
358
|
+
f'torchao required for the optimizer {optimizer}. '
|
|
359
|
+
'usage: https://github.com/pytorch/ao/tree/main/torchao/prototype/low_bit_optim#usage'
|
|
360
|
+
)
|
|
324
361
|
if optimizer not in OPTIMIZERS:
|
|
325
|
-
raise NotImplementedError(f'
|
|
362
|
+
raise NotImplementedError(f'not implemented optimizer : {optimizer}')
|
|
326
363
|
|
|
327
364
|
return OPTIMIZERS[optimizer]
|
|
328
365
|
|
|
@@ -380,13 +417,55 @@ def load_lr_scheduler(lr_scheduler: str) -> SCHEDULER:
|
|
|
380
417
|
return LR_SCHEDULERS[lr_scheduler]
|
|
381
418
|
|
|
382
419
|
|
|
383
|
-
def get_supported_optimizers() -> List[
|
|
384
|
-
|
|
420
|
+
def get_supported_optimizers(filters: Optional[Union[str, List[str]]] = None) -> List[str]:
|
|
421
|
+
r"""Return list of available optimizer names, sorted alphabetically.
|
|
422
|
+
|
|
423
|
+
:param filters: Optional[Union[str, List[str]]]. wildcard filter string that works with fmatch. if None, it will
|
|
424
|
+
return the whole list.
|
|
425
|
+
"""
|
|
426
|
+
if filters is None:
|
|
427
|
+
return sorted(OPTIMIZERS.keys())
|
|
428
|
+
|
|
429
|
+
include_filters: Sequence[str] = filters if isinstance(filters, (tuple, list)) else [filters]
|
|
430
|
+
|
|
431
|
+
filtered_list: Set[str] = set()
|
|
432
|
+
for include_filter in include_filters:
|
|
433
|
+
filtered_list.update(fnmatch.filter(OPTIMIZERS.keys(), include_filter))
|
|
385
434
|
|
|
435
|
+
return sorted(filtered_list)
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
def get_supported_lr_schedulers(filters: Optional[Union[str, List[str]]] = None) -> List[str]:
|
|
439
|
+
r"""Return list of available lr scheduler names, sorted alphabetically.
|
|
440
|
+
|
|
441
|
+
:param filters: Optional[Union[str, List[str]]]. wildcard filter string that works with fmatch. if None, it will
|
|
442
|
+
return the whole list.
|
|
443
|
+
"""
|
|
444
|
+
if filters is None:
|
|
445
|
+
return sorted(LR_SCHEDULERS.keys())
|
|
446
|
+
|
|
447
|
+
include_filters: Sequence[str] = filters if isinstance(filters, (tuple, list)) else [filters]
|
|
448
|
+
|
|
449
|
+
filtered_list: Set[str] = set()
|
|
450
|
+
for include_filter in include_filters:
|
|
451
|
+
filtered_list.update(fnmatch.filter(LR_SCHEDULERS.keys(), include_filter))
|
|
452
|
+
|
|
453
|
+
return sorted(filtered_list)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
def get_supported_loss_functions(filters: Optional[Union[str, List[str]]] = None) -> List[str]:
|
|
457
|
+
r"""Return list of available loss function names, sorted alphabetically.
|
|
458
|
+
|
|
459
|
+
:param filters: Optional[Union[str, List[str]]]. wildcard filter string that works with fmatch. if None, it will
|
|
460
|
+
return the whole list.
|
|
461
|
+
"""
|
|
462
|
+
if filters is None:
|
|
463
|
+
return sorted(LOSS_FUNCTIONS.keys())
|
|
386
464
|
|
|
387
|
-
|
|
388
|
-
return list(LR_SCHEDULER_LIST.values())
|
|
465
|
+
include_filters: Sequence[str] = filters if isinstance(filters, (tuple, list)) else [filters]
|
|
389
466
|
|
|
467
|
+
filtered_list: Set[str] = set()
|
|
468
|
+
for include_filter in include_filters:
|
|
469
|
+
filtered_list.update(fnmatch.filter(LOSS_FUNCTIONS.keys(), include_filter))
|
|
390
470
|
|
|
391
|
-
|
|
392
|
-
return LOSS_FUNCTION_LIST
|
|
471
|
+
return sorted(filtered_list)
|
|
@@ -52,7 +52,7 @@ class REXScheduler(LRScheduler):
|
|
|
52
52
|
|
|
53
53
|
return self.min_lr + (self.max_lr - self.min_lr) * ((1.0 - progress) / (1.0 - progress / 2.0))
|
|
54
54
|
|
|
55
|
-
def step(self, epoch: Optional[int] = None) -> float:
|
|
55
|
+
def step(self, epoch: Optional[int] = None) -> float:
|
|
56
56
|
value: float = self.get_linear_lr()
|
|
57
57
|
|
|
58
58
|
self.step_t += 1
|