mirror of
https://github.com/deepseek-ai/DeepSeek-VL2.git
synced 2026-11-05 01:07:23 +00:00
[GH-ISSUE #87] ImportError: cannot import name 'LlamaFlashAttention2' from 'transformers.models.llama.modeling_llama' , !pip install transformers==4.47.1 does not fix #70
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-VL2#70
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mohayl on GitHub (Feb 18, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-VL2/issues/87
ImportError Traceback (most recent call last)
Cell In[43], line 11
6 except ImportError:
7 LlamaFlashAttention2 = None # or assign a fallback implementation
---> 11 from deepseek_vl2.models import DeepseekVLV2ForCausalLM
12 from deepseek_vl2.models import DeepseekVLV2Processor
14 from deepseek_vl2.utils.io import load_pil_images
File ~/DeepSeek-VL2/deepseek_vl2/models/init.py:21
1 # Copyright (c) 2023-2024 DeepSeek.
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a copy of
(...)
17 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 from .processing_deepseek_vl_v2 import DeepseekVLV2Processor
---> 21 from .modeling_deepseek_vl_v2 import DeepseekVLV2ForCausalLM
23 all = [
24 "DeepseekVLV2Processor",
25 "DeepseekVLV2ForCausalLM",
26 ]
File ~/DeepSeek-VL2/deepseek_vl2/models/modeling_deepseek_vl_v2.py:28
26 from .siglip_vit import VisionTransformer
27 from .configuration_deepseek import DeepseekV2Config
---> 28 from .modeling_deepseek import DeepseekV2ForCausalLM
31 logger = logging.get_logger(name)
34 class MlpProjector(nn.Module):
File ~/DeepSeek-VL2/deepseek_vl2/models/modeling_deepseek.py:37
35 from transformers.cache_utils import Cache, DynamicCache
36 from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask
---> 37 from transformers.models.llama.modeling_llama import (
38 LlamaAttention,
39 LlamaFlashAttention2
40 )
41 from transformers.modeling_outputs import (
42 BaseModelOutputWithPast,
43 CausalLMOutputWithPast,
44 SequenceClassifierOutputWithPast,
45 )
46 from transformers.modeling_utils import PreTrainedModel
ImportError: cannot import name 'LlamaFlashAttention2' from 'transformers.models.llama.modeling_llama'
@RunningLeon commented on GitHub (Feb 21, 2025):
met same issue with transformers==4.48.3. Roll back to 4.47.0 would fix it. Hope it fixed soon.
@baibizhe commented on GitHub (Feb 26, 2025):
i delete that line. that line of code of for tiny model. the small and normal model function properly without that line .
@kevinkexu commented on GitHub (Mar 6, 2025):
yeah, it seems deepseek never uses LlamaFlashAttention2, just commenting all LlamaFlashAttention2 will work.
@randomradio commented on GitHub (Oct 30, 2025):
pip install transformers==4.41.1 resolved it.
@hieunc278 commented on GitHub (Nov 9, 2025):
Basically, we should not solve this issue by commenting out LlamaFlashAttention2 class, I solved this by more properly way
@MiddlePathLabs commented on GitHub (Nov 16, 2025):
How?
@aibhavesh commented on GitHub (Mar 12, 2026):
yes how would it possible without using attention we can load it ??