bigscience-workshop / bigscience-workshop/petals
Implemented FlashAttention 2
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 650
- PR merge metrics
- No merged PRs in 30d
Description
I managed to get [FlashAttention-2](https://github.com/Dao-AILab/flash-attention) implemented by switching the LlamaAttention in models.llama.config with a flash attention monkeypatch I got from alpaca_lora_4bit and updated it to version 2 by using replacing unpadded (old v1) with varlen (v2). Here is [my fork](https://github.com/Jeduh/petals) with the changes.
Results:
- \>1.1x increase in inference RPS
- 2x increase in forward RPS
All though, I cant do much with this since the main swarm rejects this code change and sends a protocol unsupported error. Makes sense.
Could FlashAttention 2 please be implemented into petals? As I've demonstrated, It's really easy and it saves a huge amount of attention memory with the new version, as attention is now made linear as seq_len grows, allowing for much higher --attn_cache_tokens. It even works for Multi-query attention and grouped-query attention for Llama 2 and I feel like this is right in line with the projects intentions of batching and linear attention compute being the same cost for the 3000-4000th token as the 0-1000th making usage calculations easy. At least as an option for hosts to get more out of their system?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.