grokfast-pytorch


Namegrokfast-pytorch JSON
Version 0.0.11 PyPI version JSON
download
home_pageNone
SummaryGrokfast
upload_time2024-12-22 16:47:44
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2024 Phil Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords artificial intelligence deep learning grokking
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img src="./grokfast.png" width="400px"></img>

## Grokfast - Pytorch (wip)

Explorations into <a href="https://arxiv.org/html/2405.20233v2">"Grokfast, Accelerated Grokking by Amplifying Slow Gradients"</a>, 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 <a href="https://github.com/ironjr/grokfast">here</a>

## Install

```bash
$ pip install grokfast-pytorch
```

## Usage

```python
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

```bibtex
@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}
}
```

```bibtex
@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}
}
```

```bibtex
@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}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "grokfast-pytorch",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "artificial intelligence, deep learning, grokking",
    "author": null,
    "author_email": "Phil Wang <lucidrains@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b1/a1/e30d47919b92c71655dec825789a948ebb820a73d2b9986a4ab036f85313/grokfast_pytorch-0.0.11.tar.gz",
    "platform": null,
    "description": "<img src=\"./grokfast.png\" width=\"400px\"></img>\n\n## Grokfast - Pytorch (wip)\n\nExplorations into <a href=\"https://arxiv.org/html/2405.20233v2\">\"Grokfast, Accelerated Grokking by Amplifying Slow Gradients\"</a>, 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.\n\nThe official repository can be found <a href=\"https://github.com/ironjr/grokfast\">here</a>\n\n## Install\n\n```bash\n$ pip install grokfast-pytorch\n```\n\n## Usage\n\n```python\nimport torch\nfrom torch import nn\n\n# toy model\n\nmodel = nn.Linear(10, 1)\n\n# import GrokFastAdamW and instantiate with parameters\n\nfrom grokfast_pytorch import GrokFastAdamW\n\nopt = GrokFastAdamW(\n    model.parameters(),\n    lr = 1e-4,\n    weight_decay = 1e-2\n)\n\n# forward and backwards\n\nloss = model(torch.randn(10))\nloss.backward()\n\n# optimizer step\n\nopt.step()\nopt.zero_grad()\n```\n\n## Todo\n\n- [ ] run all experiments on small transformer\n    - [ ] modular addition\n    - [ ] pathfinder-x\n    - [ ] run against nadam and some other optimizers\n    - [ ] see if `exp_avg` could be repurposed for amplifying slow grads\n- [ ] add the foreach version only if above experiments turn out well\n\n## Citations\n\n```bibtex\n@inproceedings{Lee2024GrokfastAG,\n    title   = {Grokfast: Accelerated Grokking by Amplifying Slow Gradients},\n    author  = {Jaerin Lee and Bong Gyun Kang and Kihoon Kim and Kyoung Mu Lee},\n    year    = {2024},\n    url     = {https://api.semanticscholar.org/CorpusID:270123846}\n}\n```\n\n```bibtex\n@misc{kumar2024maintaining,\n    title={Maintaining Plasticity in Continual Learning via Regenerative Regularization},\n    author={Saurabh Kumar and Henrik Marklund and Benjamin Van Roy},\n    year={2024},\n    url={https://openreview.net/forum?id=lyoOWX0e0O}\n}\n```\n\n```bibtex\n@inproceedings{anonymous2024the,\n    title   = {The Complexity Dynamics of Grokking},\n    author  = {Anonymous},\n    booktitle = {Submitted to The Thirteenth International Conference on Learning Representations},\n    year    = {2024},\n    url     = {https://openreview.net/forum?id=07N9jCfIE4},\n    note    = {under review}\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Phil Wang  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Grokfast",
    "version": "0.0.11",
    "project_urls": {
        "Homepage": "https://pypi.org/project/grokfast_pytorch/",
        "Repository": "https://github.com/lucidrains/grokfast-pytorch"
    },
    "split_keywords": [
        "artificial intelligence",
        " deep learning",
        " grokking"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a949432a7718e176528ff7d5eec86690201ff7792a7c203b8fd73c87fc7cbdc4",
                "md5": "71e1ae60fbc49ba731813b2f39907b70",
                "sha256": "b0eb6390441c77d6c16145e433043500e774c7f62ccafdcec02af4bd5aa59d01"
            },
            "downloads": -1,
            "filename": "grokfast_pytorch-0.0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "71e1ae60fbc49ba731813b2f39907b70",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 6183,
            "upload_time": "2024-12-22T16:47:42",
            "upload_time_iso_8601": "2024-12-22T16:47:42.854442Z",
            "url": "https://files.pythonhosted.org/packages/a9/49/432a7718e176528ff7d5eec86690201ff7792a7c203b8fd73c87fc7cbdc4/grokfast_pytorch-0.0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b1a1e30d47919b92c71655dec825789a948ebb820a73d2b9986a4ab036f85313",
                "md5": "5c3ad081c6a1951a4ef5a8cc695e1337",
                "sha256": "ddd058ec2c0828f3ae26e8c23c0146cd0b8157864c77187368e11e1042abed84"
            },
            "downloads": -1,
            "filename": "grokfast_pytorch-0.0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "5c3ad081c6a1951a4ef5a8cc695e1337",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 146693,
            "upload_time": "2024-12-22T16:47:44",
            "upload_time_iso_8601": "2024-12-22T16:47:44.066155Z",
            "url": "https://files.pythonhosted.org/packages/b1/a1/e30d47919b92c71655dec825789a948ebb820a73d2b9986a4ab036f85313/grokfast_pytorch-0.0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-22 16:47:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lucidrains",
    "github_project": "grokfast-pytorch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "grokfast-pytorch"
}
        
Elapsed time: 0.53024s