PSGD-QUAD
pip install quad-torch
An implementation of PSGD-QUAD for PyTorch.
import torch
from quad_torch import QUAD
model = torch.nn.Linear(10, 10)
optimizer = QUAD(
model.parameters(),
lr=0.001,
lr_style="adam",
momentum=0.95,
weight_decay=0.1,
max_size_dense=8192,
max_skew_dense=1.0,
preconditioner_lr=0.7,
noise_scale=1e-9,
dtype=torch.bfloat16,
)
Couple notes:
lr_style="adam"is the default and scales the update to match adam's behavior LR-wise and weight decay-wise.dtype=torch.bfloat16should be fine for most problems, but if a problem is particularly sensitive then you can tryNoneto default to gradient dtypes ortorch.float32to force f32 precision.
Resources
Xi-Lin Li's repo: https://github.com/lixilinx/psgd_torch
PSGD papers and resources listed from Xi-Lin's repo
- Xi-Lin Li. Preconditioned stochastic gradient descent, arXiv:1512.04202, 2015. (General ideas of PSGD, preconditioner fitting losses and Kronecker product preconditioners.)
- Xi-Lin Li. Preconditioner on matrix Lie group for SGD, arXiv:1809.10232, 2018. (Focus on preconditioners with the affine Lie group.)
- Xi-Lin Li. Black box Lie group preconditioners for SGD, arXiv:2211.04422, 2022. (Mainly about the LRA preconditioner. See these supplementary materials for detailed math derivations.)
- Xi-Lin Li. Stochastic Hessian fittings on Lie groups, arXiv:2402.11858, 2024. (Some theoretical works on the efficiency of PSGD. The Hessian fitting problem is shown to be strongly convex on set ${\rm GL}(n, \mathbb{R})/R_{\rm polar}$.)
- Omead Pooladzandi, Xi-Lin Li. Curvature-informed SGD via general purpose Lie-group preconditioners, arXiv:2402.04553, 2024. (Plenty of benchmark results and analyses for PSGD vs. other optimizers.)
License
This work is licensed under a Creative Commons Attribution 4.0 International License.
2024 Evan Walters, Omead Pooladzandi, Xi-Lin Li
Metadata
Release files for quad-torch 0.4.5
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 |
|---|---|---|---|---|
| quad_torch-0.4.5.tar.gz | 11.4 kB | Without provenance | Details for quad_torch-0.4.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| quad_torch-0.4.5-py3-none-any.whl | Python 3 | none | any | Details for quad_torch-0.4.5-py3-none-any.whl |
Total release size: 23.5 kB
Release files / quad_torch-0.4.5.tar.gz
| Download URL | quad_torch-0.4.5.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a7221b33ba9a0bbaf513d171fab5023e73254994a65b66d2606637a29df4256
|
|
BLAKE2b-256 checksum How to use checksums |
8d64eb57c01dcbeedcaab4dc11b232f3b22b8d7134b271746b35bcbababda477
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.9
|
Release files / quad_torch-0.4.5-py3-none-any.whl
| Download URL | quad_torch-0.4.5-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2311fd0edfd6e862797185edcd5e9d38c53b34e76b4212ab2c66968c15744c99
|
|
BLAKE2b-256 checksum How to use checksums |
068669fabf0c521e6d2c5c9b7d70d4e4150f597af21b197371b6f31cedf09fd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.9
|
Security for quad-torch 0.4.5
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.