A collection of tricks to speed up LLMs, see our transformer-tricks papers on arXiv
Project description
Transformer Tricks
A collection of tricks to simplify and speed up transformer models:
- Slim attention: [paper], [video], [podcast], [notebook], [code-readme]
- Matrix-shrink [work in progress]: [paper]
- Flash normalization: [paper], [podcast], [notebook], [code-readme]
- Precomputing the first layer: [paper], [podcast]
- Removing weights from skipless transformers: [paper], [podcast], [notebook]
Many of these tricks follow a recent trend of removing parts from neural networks such as RMSNorm’s removal of mean centering from LayerNorm, PaLM's removal of bias-parameters, GPT’s removal of the encoder stack, and of course transformer’s revolutionary removal of recurrent layers. Specifically, our FlashNorm removes the weights from RMSNorm and merges them with the next linear layer. And slim attention removes the entire V-cache from the context memory for MHA transformers.
Installation
Install the transformer tricks package:
pip install transformer-tricks
Documentation
Follow the links below for documentation of the python code in this directory:
Notebooks
The papers are accompanied by the following Jupyter notebooks:
Newsletter
Please subscribe to our [newsletter] on substack to get the latest news about this project. We will never send you more than one email per month.
Contributing
Before making a change to this repo, please do the following:
- Format your code by typing
autopep8 *.py. It's using the config inpyproject.toml - Whenever you change
transformer_tricks.py, publish a new version of the package as follows:- First, update the version number in
pyproject.tomland inrequirements.txt - Then, push the package to PyPi by typing
./push_pypi.sh - Links for python package: pypi, stats, source of this readme
- First, update the version number in
- Generate notebooks from python by typing
util/gen_notebooks
Please give us a ⭐ if you like this repo, thanks!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transformer_tricks-0.3.2.tar.gz.
File metadata
- Download URL: transformer_tricks-0.3.2.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccd27633b919c407c2c1d23502de903b1f81f2033838b312f47e7537623f5243
|
|
| MD5 |
e8199070c87c634b496ef16fc0d24450
|
|
| BLAKE2b-256 |
c1267aea5b62d45eb0703d83c1bc58e9f33098e9c10b3f769079826d1d1b76c9
|
File details
Details for the file transformer_tricks-0.3.2-py3-none-any.whl.
File metadata
- Download URL: transformer_tricks-0.3.2-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
432ab2fb6483cfbf2579eccdcd315a7543e03335926965b9c463064fe7ed1b70
|
|
| MD5 |
1c3bd389df25e9f538804711a5842104
|
|
| BLAKE2b-256 |
e1ba341ca6f3f4da6bf94f8211399ddc54212c38cc7ae2ed0e924037069cfb47
|