Skip to main content

LightGPT lightweight GPT

Project description

LightGPT

LightGPT — a lightweight, GPT-styled LLM designed to run on a wide range of hardware. It supports three modes:

  • Overkill: uses larger architecture and optimized libraries (for modern hardware)
  • Normal: balanced parameters for decent CPU/RAM machines
  • Underkill: very small footprint for ancient/low-memory hardware

This repo contains a minimal reference implementation and demo to run on CPU.

Quickstart (CPU):

  1. Create a Python environment with Python 3.10+.
  2. Install dependencies:
pip install -r requirements.txt
  1. Run the demo:
python examples/run_demo.py --mode normal

See src/lightgpt for the model and examples/run_demo.py for usage.

Advanced: ONNX & Tiny runtime

  • Export ONNX: python3 examples/export_onnx.py
  • Export NPZ weights for Tiny runtime (after training or checkpoint): python3 scripts/export_npz.py lightgpt.chkpt lightgpt_weights.npz
  • Run NumPy Tiny runtime (Underkill): python3 benchmarks/bench_infer.py lightgpt_weights.npz

ONNX Runtime (optimized CPU)

  • Export dynamic-axes ONNX model:
python3 examples/export_onnx.py --out lightgpt.onnx --mode normal --seq 64
  • Optionally quantize the ONNX model (int8 weights):
python3 examples/quantize_onnx.py lightgpt.onnx
  • Run ONNX Runtime optimized inference (set threads for CPU parallelism):
python3 examples/run_onnx.py lightgpt.onnx --prompt "Hello world" --intra 2 --inter 1

The ONNX runner uses onnxruntime with ORT_ENABLE_EXTENDED optimizations and lets you tune intra_op_num_threads and inter_op_num_threads for your CPU.

Benchmarks & Model Checks

  • Compare FP32 vs INT8 ONNX:
python3 examples/onnx_benchmark.py lightgpt.onnx --quant lightgpt.quant.onnx --prompt "Hello" --runs 5 --gen 16
  • Run the model checks (Conversation / Questionnaire / Philosophical) across PyTorch, ONNX and Tiny runtime:
python3 examples/model_check.py --out report.txt --onnx lightgpt.onnx --npz lightgpt_weights.npz --mode normal

The model_check.py script will write a textual report report.txt containing the generated token ids and a simple tokenized token-preview. Use this to verify that LightGPT produces outputs for different content styles and runtimes.

Packaging & publishing to PyPI

This repository is configured to publish as a Python package. Steps to publish a release:

  1. Create a PyPI API token: go to https://pypi.org/manage/account/#api-tokens and create a token with upload scope.

Continuous Integration (recommended)

Add the token as a repository secret named PYPI_API_TOKEN in GitHub (Settings → Secrets). A release workflow is included that publishes automatically when you push a tag matching v* (e.g. v0.1.0).

Manual (local)

If you prefer to publish locally, set an environment variable and run the included publish script. Use a secure shell environment — do not commit your token.

POSIX example:

export TWINE_PASSWORD=pypi-...
./scripts/publish_pypi.sh

PowerShell example:

$env:TWINE_PASSWORD='pypi-...'; ./scripts/publish_pypi.ps1

Notes:

  • The package uses pyproject.toml + setuptools and includes README.md as the long description.
  • For Colab, you can install directly from GitHub: pip install git+https://github.com/Maor-404/LightGPT.git.

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

lightgpt-0.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lightgpt-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lightgpt-0.1.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for lightgpt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c44364dda84327a85919a805239ef392848967dbb86bdbbc5e4408f65f5988d6
MD5 2643c84456f194110a39c39024d1755b
BLAKE2b-256 e8aff045ac802380de10256c9e506a636281baa9eb42a14fa141434708c3273c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lightgpt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for lightgpt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e09f73c1b46b14a4822a92e6547f4eac2dec371038e716dfd18868c5ed2ed5b0
MD5 326a4d240f2a4155033237c7c76557eb
BLAKE2b-256 640d442b125af84e2993ae2f59f7ad7e66134695fcb67cff5c29630bddbe0998

See more details on using hashes here.

Supported by

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