No learning rates needed: Introducing SALSA - Stable Armijo Line Search Adaptation
The Repository to the Paper Faster Convergence for No learning rates needed: Introducing SALSA - Stable Armijo Line Search Adaptation
Youtube Link:
Install
Download the repo and use:
pip install .
Dependencies:
for replicating the results (not needed for using the optimizer):
pip install transformersfor huggingface transformers <3pip install datasetsfor huggingface datasets <3pip install tensorflow-datasetsfor tensorflow datasets <3pip install wandbfor optional logging <3- for easy replication use conda and environment.yml eg:
$ conda env create -f environment.ymland$ conda activate sls3
Use in own projects
The custom optimizer is in \salsa\SaLSA.py and the comparison version are in \salsa\adam_sls.py \ Example Usage:
from salsa.SaLSA import SaLSA
self.optimizer = SaLSA(model.parameters())
The typical pytorch forward pass needs to be changed from :
optimizer.zero_grad()
y_pred = model(x)
loss = criterion(y_pred, y)
loss.backward()
optimizer.step()
scheduler.step()
to:
def closure(backwards = False):
y_pred = model(x)
loss = criterion(y_pred, y)
if backwards: loss.backward()
return loss
optimizer.zero_grad()
loss = optimizer.step(closure = closure)
This code change is necessary since, the optimizers needs to perform additional forward passes and thus needs to have the forward pass encapsulated in a function. See embedder.py in the fit() method for more details
Replicating Results
The results of the Line Search Algorithm are:
on average a 50% reduction in final loss, while only needing about 3% extra compute time on average.
For replicating the main Results of the Paper run:
$ python test/run_multiple.py
$ python test/run_multiple_img.py
For replicating specific runs or trying out different hyperparameters use:
$ python test/main.py
and change the test/config.json file appropriately
Older Versions of this Optimizer:
https://github.com/TheMody/Faster-Convergence-for-Transformer-Fine-tuning-with-Line-Search-Methods https://github.com/TheMody/Improving-Line-Search-Methods-for-Large-Scale-Neural-Network-Training
Please cite:
No learning rates needed: Introducing SALSA - Stable ArmijoLine Search Adaptation from Philip Kenneweg, Tristan Kenneweg, Fabian Fumagalli Barbara Hammer published in IJCNN 2024 and on arvix
@misc{kenneweg2024learningratesneededintroducing,
title={No learning rates needed: Introducing SALSA -- Stable Armijo Line Search Adaptation},
author={Philip Kenneweg and Tristan Kenneweg and Fabian Fumagalli and Barbara Hammer},
year={2024},
eprint={2407.20650},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2407.20650},
}
Metadata
Release files for SaLSa-Optimizer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| salsa_optimizer-0.1.0.tar.gz | 9.2 kB | Without provenance | Details for salsa_optimizer-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| SaLSa_Optimizer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for SaLSa_Optimizer-0.1.0-py3-none-any.whl |
Total release size: 20.8 kB
Release files / salsa_optimizer-0.1.0.tar.gz
| Download URL | salsa_optimizer-0.1.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e0add70ac8ae78334b8b4e929face5731faf04304a65928abaa16864e2ddb37
|
|
BLAKE2b-256 checksum How to use checksums |
dd49466afc51275f25a2346611daf6653992e901c26f3b0a23f64b4e455ba7cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.4
|
Release files / SaLSa_Optimizer-0.1.0-py3-none-any.whl
| Download URL | SaLSa_Optimizer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d7b261bded0c482ac40bc34b189e2b81f5d7d86bdd0ff86bdccdc8ea34f669bd
|
|
BLAKE2b-256 checksum How to use checksums |
e682bf53d409445752be327f60843fb22adc2f6aa3d0ba0a5086b1eb93f9245b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.4
|
Security for SaLSa-Optimizer 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.