Grokfast - Pytorch (wip)
Explorations into "Grokfast, Accelerated Grokking by Amplifying Slow Gradients", out of Seoul National University in Korea. In particular, will compare it with NAdam on modular addition as well as a few other tasks, since I am curious why those experiments are left out of the paper. If it holds up, will polish it up into a nice package for quick use.
The official repository can be found here
Install
$ pip install grokfast-pytorch
Usage
import torch
from torch import nn
# toy model
model = nn.Linear(10, 1)
# import GrokFastAdamW and instantiate with parameters
from grokfast_pytorch import GrokFastAdamW
opt = GrokFastAdamW(
model.parameters(),
lr = 1e-4,
weight_decay = 1e-2
)
# forward and backwards
loss = model(torch.randn(10))
loss.backward()
# optimizer step
opt.step()
opt.zero_grad()
Todo
- run all experiments on small transformer
- modular addition
- pathfinder-x
- run against nadam and some other optimizers
- see if
exp_avgcould be repurposed for amplifying slow grads
- add the foreach version only if above experiments turn out well
Citations
@inproceedings{Lee2024GrokfastAG,
title = {Grokfast: Accelerated Grokking by Amplifying Slow Gradients},
author = {Jaerin Lee and Bong Gyun Kang and Kihoon Kim and Kyoung Mu Lee},
year = {2024},
url = {https://api.semanticscholar.org/CorpusID:270123846}
}
@misc{kumar2024maintaining,
title={Maintaining Plasticity in Continual Learning via Regenerative Regularization},
author={Saurabh Kumar and Henrik Marklund and Benjamin Van Roy},
year={2024},
url={https://openreview.net/forum?id=lyoOWX0e0O}
}
@inproceedings{anonymous2024the,
title = {The Complexity Dynamics of Grokking},
author = {Anonymous},
booktitle = {Submitted to The Thirteenth International Conference on Learning Representations},
year = {2024},
url = {https://openreview.net/forum?id=07N9jCfIE4},
note = {under review}
}
Metadata
Release files for grokfast-pytorch 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| grokfast_pytorch-0.0.11.tar.gz | 146.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| grokfast_pytorch-0.0.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 152.9 kB
Release files / grokfast_pytorch-0.0.11.tar.gz
| Download URL | grokfast_pytorch-0.0.11.tar.gz |
|---|---|
| Size | 146.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ddd058ec2c0828f3ae26e8c23c0146cd0b8157864c77187368e11e1042abed84
|
|
BLAKE2b-256 checksum How to use checksums |
b1a1e30d47919b92c71655dec825789a948ebb820a73d2b9986a4ab036f85313
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.21
|
Release files / grokfast_pytorch-0.0.11-py3-none-any.whl
| Download URL | grokfast_pytorch-0.0.11-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0eb6390441c77d6c16145e433043500e774c7f62ccafdcec02af4bd5aa59d01
|
|
BLAKE2b-256 checksum How to use checksums |
a949432a7718e176528ff7d5eec86690201ff7792a7c203b8fd73c87fc7cbdc4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.21
|