Efficient computation library for linear attention.
Project description
An efficient Linear Attention Decoding package
1. installation
conda create -n efficient_linear_decoding python=3.9
conda activate efficient_linear_decoding
pip install efficient_linear_decoding
The code has been test under the following environment:
triton>=2.1.0
torch>=2.1.0
pycuda
pynvml
numpy<2
You can use the following command to install:
pip install triton==2.1.0
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
pip install pycuda
pip install pynvml
pip install numpy
2. usage
import torch
from efficient_linear_decoding.efficient_linear_decoding import causal_linear_decoder
# Create input tensor
Q = torch.randn(2,32,1024,128,device='cuda:0')
K = torch.randn(2,32,1024,128,device='cuda:0')
V = torch.randn(2,32,1024,128,device='cuda:0')
# Inference using causal_linear_decoder
output = causal_linear_decoder(Q,K,V)
# If you want to input a mask with weight, set the is_mask_weight: True
gamma = torch.full((32,),0.5,device='cuda:0')
output = causal_linear_decoder(Q,K,V,is_mask_weight=True,gamma=gamma)
3. acknowledgement
method | Title | Paper | Code |
---|---|---|---|
causal_dot_product | Fast Transformers with Clustered Attention | arxiv | code |
Lighting Attention-2 | Lightning Attention-2: A Free Lunch for Handling Unlimited Sequence Lengths in Large Language Models | arxiv | code |
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
Built Distribution
Close
Hashes for efficient_linear_decoding-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c86885d9f900df411ba939639ba7adb6353303308f9a4bfba693e9de7b7f3587 |
|
MD5 | 04998d2ec87770df3c076003b22c2667 |
|
BLAKE2b-256 | be33f23346e282b8606645f6d0d00bf686e37fa06f2aefab4425f5779f9a7953 |
Close
Hashes for efficient_linear_decoding-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0363e998d95d90d622c503a8539e1cb076e83cfec689740512ac7650765a9142 |
|
MD5 | f8daee0d8a25b7c3ccda828606e2624b |
|
BLAKE2b-256 | 4a522e7c1c136f5900704ef3ee9f09d6660a881275c31e3604f926b85da6dc82 |