Skip to main content

GPT training in Lightning

Project description

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 from source

To clone the repository, please clone the repo with

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

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

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

lightning_gpt-0.1.0.tar.gz (263.7 kB view details)

Uploaded Source

Built Distribution

lightning_gpt-0.1.0-py3-none-any.whl (135.5 kB view details)

Uploaded Python 3

File details

Details for the file lightning_gpt-0.1.0.tar.gz.

File metadata

  • Download URL: lightning_gpt-0.1.0.tar.gz
  • Upload date:
  • Size: 263.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for lightning_gpt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d7ac6723ed5a2f772b03dfbcb73c46aebc3e9212bddc2e2a83cfe04934f23f42
MD5 4b425dd16bdb6bae1fc039424e2316e1
BLAKE2b-256 1768c480054b7c7c5a169284c3fe165e407bfbd88b1258b8a14f4611701188ae

See more details on using hashes here.

File details

Details for the file lightning_gpt-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lightning_gpt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f3b592b28feb5eb374e960011d24da888773dc28bf2c1d62ee8d90cfd2b4249
MD5 aa4a69d65ce46d033866d6a08d038e3b
BLAKE2b-256 a55df81ab890a956475ac81c675df6e9a09286d99c8ca8820ed9ced7310b65fb

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page