Collection d'implémentations GPT-2 en Python et Rust pour comparer différentes stratégies d'optimisation.
| 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 |
| 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!) |
Voir BENCHMARKS.md pour une analyse détaillée.
| Implementation | TTFT | tok/s |
|---|---|---|
| pytorch-gpt2-kvcache | 25 ms | 54 |
| gpt2-rs-threads-crossbeam | 28 ms | 44 |
| gpt2-rs-async-tokio | 50 ms | 46 |
./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èlesPython:
source .venv/bin/activate
cd pytorch-gpt2-kvcache
python main.py "Once upon a time" --model openai-community/gpt2 --profileRust:
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./download-models.shpython3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtcd gpt2-rs-threads-crossbeam
cargo build --release- 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.