pytorch-optimizer 3.1.2__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.2 → pytorch_optimizer-3.2.0}/PKG-INFO +41 -12
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/README.md +34 -7
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pyproject.toml +48 -43
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/__init__.py +87 -10
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/types.py +2 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/grokfast.py +2 -2
- pytorch_optimizer-3.2.0/pytorch_optimizer/optimizer/soap.py +341 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/utils.py +151 -4
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/LICENSE +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/__init__.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/exception.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/optimizer.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/base/scheduler.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/__init__.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/bi_tempered.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/cross_entropy.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/dice.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/f1.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/focal.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/jaccard.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/ldam.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/lovasz.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/loss/tversky.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/__init__.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/chebyshev.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/cosine_anealing.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/experimental/__init__.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/experimental/deberta_v3_lr_scheduler.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/linear_warmup.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/proportion.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/rex.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/lr_scheduler/wsd.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/__init__.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/a2grad.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adabelief.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adabound.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adadelta.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adafactor.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adahessian.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adai.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adalite.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adam_mini.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamax.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamg.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamod.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamp.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adams.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adamw.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adan.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adanorm.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adapnm.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adashift.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/adasmooth.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/ademamix.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/agc.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/aggmo.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/aida.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/alig.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/amos.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/apollo.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/avagrad.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/came.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/dadapt.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/diffgrad.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/fadam.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/fp16.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/fromage.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/galore.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/gc.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/gravity.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/kate.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lamb.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lars.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lion.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lomo.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/lookahead.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/madgrad.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/msvag.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/nero.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/novograd.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/padam.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/pcgrad.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/pid.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/pnm.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/prodigy.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/qhadam.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/qhm.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/radam.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/ranger.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/ranger21.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/rotograd.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sam.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/schedulefree.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sgd.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sgdp.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/shampoo.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/shampoo_utils.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sm3.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/sophia.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/srmm.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/swats.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/tiger.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/trac.py +0 -0
- {pytorch_optimizer-3.1.2 → pytorch_optimizer-3.2.0}/pytorch_optimizer/optimizer/yogi.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,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,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) |
|
|
@@ -213,6 +221,7 @@ supported_optimizers = get_supported_optimizers()
|
|
|
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) |
|
|
215
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) |
|
|
216
225
|
|
|
217
226
|
## Supported LR Scheduler
|
|
218
227
|
|
|
@@ -224,6 +233,16 @@ from pytorch_optimizer import get_supported_lr_schedulers
|
|
|
224
233
|
supported_lr_schedulers = get_supported_lr_schedulers()
|
|
225
234
|
```
|
|
226
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
|
+
|
|
227
246
|
| LR Scheduler | Description | Official Code | Paper | Citation |
|
|
228
247
|
|-----------------|---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|----------------------------------------------------------------------------------------------------|
|
|
229
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) |
|
|
@@ -241,6 +260,16 @@ from pytorch_optimizer import get_supported_loss_functions
|
|
|
241
260
|
supported_loss_functions = get_supported_loss_functions()
|
|
242
261
|
```
|
|
243
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
|
+
|
|
244
273
|
| Loss Functions | Description | Official Code | Paper | Citation |
|
|
245
274
|
|-----------------|-------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|------------------------------------|------------------------------------------------------------------------------|
|
|
246
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) |
|
|
@@ -174,6 +180,7 @@ supported_optimizers = get_supported_optimizers()
|
|
|
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) |
|
|
176
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) |
|
|
177
184
|
|
|
178
185
|
## Supported LR Scheduler
|
|
179
186
|
|
|
@@ -185,6 +192,16 @@ from pytorch_optimizer import get_supported_lr_schedulers
|
|
|
185
192
|
supported_lr_schedulers = get_supported_lr_schedulers()
|
|
186
193
|
```
|
|
187
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
|
+
|
|
188
205
|
| LR Scheduler | Description | Official Code | Paper | Citation |
|
|
189
206
|
|-----------------|---------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|----------------------------------------------------------------------------------------------------|
|
|
190
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) |
|
|
@@ -202,6 +219,16 @@ from pytorch_optimizer import get_supported_loss_functions
|
|
|
202
219
|
supported_loss_functions = get_supported_loss_functions()
|
|
203
220
|
```
|
|
204
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
|
+
|
|
205
232
|
| Loss Functions | Description | Official Code | Paper | Citation |
|
|
206
233
|
|-----------------|-------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|------------------------------------|------------------------------------------------------------------------------|
|
|
207
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>"]
|
|
@@ -17,9 +17,9 @@ keywords = [
|
|
|
17
17
|
"FAdam", "Fromage", "GaLore", "Gravity", "GrokFast", "GSAM", "Kate", "Lamb", "LARS", "Lion", "LOMO", "Lookahead",
|
|
18
18
|
"MADGRAD", "MSVAG", "Nero", "NovoGrad", "PAdam", "PCGrad", "PID", "PNM", "Prodigy", "QHAdam", "QHM", "RAdam",
|
|
19
19
|
"Ranger", "Ranger21", "RotoGrad", "SAM", "ScheduleFreeSGD", "ScheduleFreeAdamW", "SGDP", "Shampoo",
|
|
20
|
-
"ScalableShampoo", "SGDW", "SignSGD", "SM3", "SopihaH", "SRMM", "StableAdamW", "SWATS", "Tiger", "TRAC",
|
|
21
|
-
"Yogi", "BCE", "BCEFocal", "Focal", "FocalCosine", "SoftF1", "Dice", "LDAM", "Jaccard", "Bi-Tempered",
|
|
22
|
-
"FocalTversky", "LovaszHinge", "bitsandbytes", "WSD", "QGaLore",
|
|
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", "ARG002",
|
|
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
|
|
@@ -114,12 +115,14 @@ from pytorch_optimizer.optimizer.shampoo_utils import (
|
|
|
114
115
|
power_iteration,
|
|
115
116
|
)
|
|
116
117
|
from pytorch_optimizer.optimizer.sm3 import SM3
|
|
118
|
+
from pytorch_optimizer.optimizer.soap import SOAP
|
|
117
119
|
from pytorch_optimizer.optimizer.sophia import SophiaH
|
|
118
120
|
from pytorch_optimizer.optimizer.srmm import SRMM
|
|
119
121
|
from pytorch_optimizer.optimizer.swats import SWATS
|
|
120
122
|
from pytorch_optimizer.optimizer.tiger import Tiger
|
|
121
123
|
from pytorch_optimizer.optimizer.trac import TRAC
|
|
122
124
|
from pytorch_optimizer.optimizer.utils import (
|
|
125
|
+
CPUOffloadOptimizer,
|
|
123
126
|
clip_grad_norm,
|
|
124
127
|
disable_running_stats,
|
|
125
128
|
enable_running_stats,
|
|
@@ -133,6 +136,7 @@ from pytorch_optimizer.optimizer.yogi import Yogi
|
|
|
133
136
|
|
|
134
137
|
HAS_BNB: bool = find_spec('bitsandbytes') is not None
|
|
135
138
|
HAS_Q_GALORE: bool = find_spec('q-galore-torch') is not None
|
|
139
|
+
HAS_TORCHAO: bool = find_spec('torchao') is not None
|
|
136
140
|
|
|
137
141
|
OPTIMIZER_LIST: List[OPTIMIZER] = [
|
|
138
142
|
AdamW,
|
|
@@ -210,6 +214,7 @@ OPTIMIZER_LIST: List[OPTIMIZER] = [
|
|
|
210
214
|
AdaLOMO,
|
|
211
215
|
AdamG,
|
|
212
216
|
AdEMAMix,
|
|
217
|
+
SOAP,
|
|
213
218
|
]
|
|
214
219
|
OPTIMIZERS: Dict[str, OPTIMIZER] = {str(optimizer.__name__).lower(): optimizer for optimizer in OPTIMIZER_LIST}
|
|
215
220
|
|
|
@@ -299,6 +304,15 @@ def load_bnb_optimizer(optimizer: str) -> OPTIMIZER: # pragma: no cover
|
|
|
299
304
|
return optim.RMSprop32bit
|
|
300
305
|
if 'sgd32bit' in optimizer:
|
|
301
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
|
+
|
|
302
316
|
raise NotImplementedError(f'[-] not implemented optimizer : {optimizer}')
|
|
303
317
|
|
|
304
318
|
|
|
@@ -312,19 +326,40 @@ def load_q_galore_optimizer(optimizer: str) -> OPTIMIZER: # pragma: no cover
|
|
|
312
326
|
raise NotImplementedError(f'[-] not implemented optimizer : {optimizer}')
|
|
313
327
|
|
|
314
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
|
+
|
|
315
343
|
def load_optimizer(optimizer: str) -> OPTIMIZER:
|
|
316
344
|
optimizer: str = optimizer.lower()
|
|
317
345
|
|
|
318
346
|
if optimizer.startswith('bnb'):
|
|
319
347
|
if HAS_BNB and torch.cuda.is_available():
|
|
320
348
|
return load_bnb_optimizer(optimizer) # pragma: no cover
|
|
321
|
-
raise ImportError(f'
|
|
349
|
+
raise ImportError(f'bitsandbytes and CUDA required for the optimizer {optimizer}')
|
|
322
350
|
if optimizer.startswith('q_galore'):
|
|
323
351
|
if HAS_Q_GALORE and torch.cuda.is_available():
|
|
324
352
|
return load_q_galore_optimizer(optimizer) # pragma: no cover
|
|
325
|
-
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
|
+
)
|
|
326
361
|
if optimizer not in OPTIMIZERS:
|
|
327
|
-
raise NotImplementedError(f'
|
|
362
|
+
raise NotImplementedError(f'not implemented optimizer : {optimizer}')
|
|
328
363
|
|
|
329
364
|
return OPTIMIZERS[optimizer]
|
|
330
365
|
|
|
@@ -382,13 +417,55 @@ def load_lr_scheduler(lr_scheduler: str) -> SCHEDULER:
|
|
|
382
417
|
return LR_SCHEDULERS[lr_scheduler]
|
|
383
418
|
|
|
384
419
|
|
|
385
|
-
def get_supported_optimizers() -> List[
|
|
386
|
-
|
|
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))
|
|
387
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())
|
|
388
464
|
|
|
389
|
-
|
|
390
|
-
return list(LR_SCHEDULER_LIST.values())
|
|
465
|
+
include_filters: Sequence[str] = filters if isinstance(filters, (tuple, list)) else [filters]
|
|
391
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))
|
|
392
470
|
|
|
393
|
-
|
|
394
|
-
return LOSS_FUNCTION_LIST
|
|
471
|
+
return sorted(filtered_list)
|
|
@@ -185,7 +185,7 @@ class GrokFastAdamW(BaseOptimizer):
|
|
|
185
185
|
bias_correction2_sq: float = math.sqrt(self.debias(beta2, group['step']))
|
|
186
186
|
|
|
187
187
|
should_grokfast: bool = (
|
|
188
|
-
group['grokfast'] and group['step'] > group['grokfast_after_step'] and group['grokfast_lamb'] > 0
|
|
188
|
+
group['grokfast'] and group['step'] > group['grokfast_after_step'] and group['grokfast_lamb'] > 0.0
|
|
189
189
|
)
|
|
190
190
|
|
|
191
191
|
for p in group['params']:
|
|
@@ -201,7 +201,7 @@ class GrokFastAdamW(BaseOptimizer):
|
|
|
201
201
|
if len(state) == 0:
|
|
202
202
|
state['exp_avg'] = torch.zeros_like(p)
|
|
203
203
|
state['exp_avg_sq'] = torch.zeros_like(p)
|
|
204
|
-
if
|
|
204
|
+
if group['grokfast'] and group['grokfast_lamb'] > 0.0:
|
|
205
205
|
state['grok_exp_avg'] = grad.clone()
|
|
206
206
|
|
|
207
207
|
self.apply_weight_decay(
|