Skip to main content

Grokfast

Project description

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_avg could 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}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grokfast_pytorch-0.0.6.tar.gz (146.0 kB view details)

Uploaded Source

Built Distribution

grokfast_pytorch-0.0.6-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file grokfast_pytorch-0.0.6.tar.gz.

File metadata

  • Download URL: grokfast_pytorch-0.0.6.tar.gz
  • Upload date:
  • Size: 146.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for grokfast_pytorch-0.0.6.tar.gz
Algorithm Hash digest
SHA256 c586e99a541e5212769e6ff8903af99af9de52352a7d3e2691dc27d779648c4f
MD5 a58d05ce08154c207f18f133b9c2cc07
BLAKE2b-256 a8a1123794330ef0b8b9ac242f08ff13f2eed33b88624f3f94e5344e0ccb6be1

See more details on using hashes here.

File details

Details for the file grokfast_pytorch-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for grokfast_pytorch-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 53045b106fdf8afcd55ae42b00f3ecf9477825967628cce9e3de699ea5bc420f
MD5 340fdc732f37f16110d99bd627c74fb4
BLAKE2b-256 30999013d30e568e145d5ec2c2757e2b9d00fbb780d42f5181fcb13f180075ff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page