Giter Club home page Giter Club logo

lit-gpt's Introduction

lightning-GPT

lightning-GPT is a minimal wrapper around Andrej Karpathy's minGPT and nanoGPT in Lightning.

It is aimed at providing a minimal Lightning layer on top of minGPT and nanoGPT, while leveraging the full breadth of Lightning.

There are currently a few options:

  • MinGPT: the GPT model from minGPT vanilla (set --implementation=mingpt)
  • NanoGPT: the GPT model from nanoGPT vanilla (set --implementation=nanogpt)
  • DeepSpeedMinGPT: the GPT model from minGPT made DeepSpeed-ready (set --strategy=deepspeed)
  • DeepSpeedNanoGPT: the GPT model from nanoGPT made DeepSpeed-ready (set --strategy=deepspeed)
  • FSDPMinGPT: the GPT model from minGPT made FSDP (native)-ready (set --strategy=fsdp-gpt)
  • FSDPNanoGPT: the GPT model from nanoGPT made FSDP (native)-ready (set --strategy=fsdp-gpt)

minGPT and nanoGPT are vendored with the repo in the mingpt and nanogpt directories respectively. Find the respective LICENSE there.

Thanks to:

  • @karpathy for the original minGPT and nanoGPT implementation
  • @williamFalcon for the first Lightning port
  • @SeanNaren for the DeepSpeed pieces

Installation

There are two main ways to install this package.

Installation from source is preferred if you need the latest version with yet unreleased changes, want to use the provided benchmarking or training suites or need to adjust the package.

Installation from PyPI is preferred if you just want to use a stable version of the package without any modifications.

Installation from PyPI

To install the package, simply run

pip install lightning-gpt

Installation from source

To clone the repository, please clone the repo with

git clone https://github.com/Lightning-AI/lightning-GPT && cd lightning-GPT
git submodule update --init --recursive

and install with

pip install -e .

After this you can proceed with the following steps.

MinGPT

First install the dependencies

pip install -r requirements.txt

then

python train.py

See

python train.py --help

for the available flags.

NanoGPT

First install the dependencies.

pip install -r requirements.txt
pip install -r requirements/nanogpt.txt

then

python train.py

See

python train.py --help

for the available flags.

DeepSpeed

Install the extra-dependencies:

pip install -r requirements/deepspeed.txt

and pass the strategy flag to the script

python train.py --implementation mingpt --strategy deepspeed

or

python train.py --implementation nanogpt --strategy deepspeed

FSDP native

Pass the strategy flag to the script

python train.py --implementation mingpt --strategy fsdp_native

or

python train.py --implementation nanogpt --strategy fsdp_native

PyTorch 2.0

To run on dynamo/inductor from the PyTorch 2.0 compiler stack, run

python train.py --compile dynamo

Note that you will need a recent torch nightly (1.14.x) for torch.compile to be available.

Credits

License

Apache 2.0 license https://opensource.org/licenses/Apache-2.0

lit-gpt's People

Contributors

justusschock avatar lantiga avatar thomasyoungson avatar tchaton avatar

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.