Skip to content

xigh/gpt2-experiments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPT-2 Implementations

Collection d'implémentations GPT-2 en Python et Rust pour comparer différentes stratégies d'optimisation.

Implémentations

Python

Dossier Description
numpy-gpt2 Pure NumPy, single-thread
numpy-gpt2-kvcache NumPy avec KV-cache
pytorch-gpt2 PyTorch sans cache
pytorch-gpt2-kvcache PyTorch avec KV-cache
transformers-gpt2 Hugging Face Transformers

Rust

Dossier Description
gpt2-rs-naive Single-thread baseline
gpt2-rs-threads-rayon Rayon work-stealing
gpt2-rs-threads-crossbeam Thread pool persistant (crossbeam channels)
gpt2-rs-threads-crossbeam-scope Scoped threads (crossbeam::scope)
gpt2-rs-async-tokio Async Tokio (spawn_blocking + join!)

Benchmarks

Voir BENCHMARKS.md pour une analyse détaillée.

Résumé (GPT-2 base, Apple Silicon)

Implementation TTFT tok/s
pytorch-gpt2-kvcache 25 ms 54
gpt2-rs-threads-crossbeam 28 ms 44
gpt2-rs-async-tokio 50 ms 46

Usage

Lancer les benchmarks

./test-engines.sh                              # benchmark tous les engines
./test-engines.sh --list                       # lister engines/modèles disponibles
./test-engines.sh -e pytorch-gpt2-kvcache      # engine spécifique
./test-engines.sh -m openai-community/gpt2-xl  # modèle spécifique
./test-engines.sh --all                        # tous les modèles

Tester un engine individuellement

Python:

source .venv/bin/activate
cd pytorch-gpt2-kvcache
python main.py "Once upon a time" --model openai-community/gpt2 --profile

Rust:

cd gpt2-rs-threads-crossbeam
cargo build --release
./target/release/gpt2-rs-threads-crossbeam \
    --model ~/models/openai-community/gpt2 \
    --prompt "Once upon a time" \
    --max-tokens 30 \
    --profile

Setup

Télécharger les modèles

./download-models.sh

Environnement Python

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Build Rust

cd gpt2-rs-threads-crossbeam
cargo build --release

Modèles supportés

  • GPT-2 (124M) - 523 MB
  • GPT-2 Medium (355M) - 1.4 GB
  • GPT-2 Large (774M) - 3.0 GB
  • GPT-2 XL (1.5B) - 6.0 GB

Format: Hugging Face avec model.safetensors.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published