Comments (7)
We found that after 4.36, the default attention of llama is changed from "LlamaAttention" to "LlamaSdpaAttention". Hence the replacement function will not work. Instead, you may try:
modify_method_of_instance(base_model, "LlamaAttention", "forward", self_extend_forward)
--> modify_method_of_instance(base_model, "LlamaSdpaAttention", "forward", self_extend_forward)
This might be the reason for the failure.
from longlm.
We found that after 4.36, the default attention of llama is changed from "LlamaAttention" to "LlamaSdpaAttention". Hence the replacement function will not work. Instead, you may try:
modify_method_of_instance(base_model, "LlamaAttention", "forward", self_extend_forward) --> modify_method_of_instance(base_model, "LlamaSdpaAttention", "forward", self_extend_forward)
This might be the reason for the failure.
it work, thank you.
I have another question. I want to add it here. but it can still only run normally on 4.32, and the running result of 4.36 is still wrong.
I just added the following three pieces of code and used this command to run them: CUDA_VISIBLE_DEVICES=0,1 python eval/passkey.py --model /data/supry/models/llama-2/llama2-7b-hf --min-tokens 4096 --max-tokens 8192 --tokens-step 4096 --length-step 1024 --iterations 20 --serope
from longlm.
from longlm.
Hi YL-9! Could you please test whether self-extend can work by instance wise modification, like the example we provide? Sometimes, direct modification to the transformers' class does not take effect, while the cause of failure is case by case. That's the reason why we choose to modify the forward function of a model instance rather than its class. (Of course,, this can avoid any unexpected behavior for the modification only happens to the specific model instance)
from longlm.
ok, thank you!
from longlm.
Hi, thanks for the nice work! I see the current implementation in llama_self_extend_patch_4_36.py
is regular pytorch. I wonder if you plan to implement Flash attention for transformers==4.36
?
from longlm.
Hi, thanks for the nice work! I see the current implementation in
llama_self_extend_patch_4_36.py
is regular pytorch. I wonder if you plan to implement Flash attention fortransformers==4.36
?
Hi, thank you for your interests. The main different between transformers==4.36 and transformers==4.38.2 is how the RoPE is applied to KV. You may have a check. The computation of self attention is nearly the same. This means you can follow our 4.38.2 implementation to have a flash attention implementation for 4.36 with minor modification.
One of the possible issues is the flash_attn version used by 4.36. In that case, you may use our triton flash attention implementation instead of flash_attn. It's 10~20% slower than flash_attn.
from longlm.
Related Issues (20)
- Flash Attention implementation is coming
- Can it be implemented on qwen1.5? HOT 2
- Example for phi2? HOT 7
- Example for gemma & use with Ollama HOT 5
- OOM on LongBench HOT 1
- FlashAttention does not work for Batch size > 1
- What effect on qwen1.5 will be if i use self-extend trick? HOT 3
- Something wrong in modify_method_of_instance function HOT 2
- Question | Has anyone tried this with GGUF models? HOT 1
- Long context
- Questions regarding group query/key positional index HOT 2
- Question about equation 4 and Table 5 caption in paper HOT 3
- llama3 is not working. HOT 1
- Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! when resuming training
- Passkey retrieval (needle in a haystack) HOT 2
- Run example.py Error: Failed to modify the attention method of LlamaForCausalLM HOT 2
- Differences with ReRoPE HOT 1
- 是否有示例代码支持对safetensors格式LLM启用SelfExtend HOT 5
- Cohere command r HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from longlm.