GithubHelp home page GithubHelp logo

lawa's Introduction

Latest Weight Averaging (LAWA)

Paper Link

Abstract

Training vision or language models on large datasets can take days, if not weeks. We show that averaging the weights of the k latest checkpoints, each collected at the end of an epoch, can speed up the training progression in terms of loss and accuracy by dozens of epochs, corresponding to time savings up to ~68 and ~30 GPU hours when training a ResNet50 on ImageNet and RoBERTa-Base model on WikiText-103, respectively. We also provide the code and model checkpoint trajectory to reproduce the results and facilitate research on reusing historical weights for faster convergence.

Codebase structure

  • There is a standalone LAWA Scheduler in lawa.py, which can be imported into any PyTorch training loop
  • Besides that, this repo contains two forks, one for each of the bert and imagenet experiments
  • I tried to add LAWA to the forks with minimal modifications
    • that means, most code is not touched by me
    • Installation instructions and requirements are contained in the respective README file of each
    • this LAWA implementation does not require additional packages, it only requires PyTorch
    • the key LAWA averaging operations can be found in lawa_utils.py
  • As of now, this codebase is designed for averaging checkpoints post-training, not for online training
    • I wanted to be able to experiment with historical checkpoints after running a full training run only once
    • that means, to try out LAWA, you first need to obtain training trajectory checkpoints (either by downloading mine, see below, or creating you own)
    • then, you can experiment with averaging a number of checkpoints, as shown in the results-reproducing shell scripts below

Reproduce the results

  • In both folders (bert and imagenet), there is a shell script called reproduce_results.sh
  • To run it, you need to modify the checkpoint and dataset paths

Checkpoints

Citation

If you find this code useful for your work, please cite our paper as

@article{lawa,
  title={Stop Wasting My Time! Saving Days of ImageNet and BERT Training with Latest Weight Averaging},
  author={Kaddour, Jean},
  journal={arXiv preprint arXiv:2209.14981},
  year={2022},
  url={https://arxiv.org/abs/2209.14981}
}

lawa's People

Contributors

jeankaddour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

okbalefthanded

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.