llama sdpa patching WIP
This commit is contained in:
@@ -2,10 +2,6 @@
|
||||
Patched LlamaAttention to use torch.nn.functional.scaled_dot_product_attention
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
import torch
|
||||
from transformers.utils import is_torch_bf16_gpu_available
|
||||
|
||||
from axolotl.monkeypatch.utils import (
|
||||
mask_2d_to_4d,
|
||||
@@ -15,11 +11,15 @@ from axolotl.monkeypatch.utils import (
|
||||
|
||||
|
||||
def hijack_llama_prepare_4d_mask():
|
||||
from typing import Optional
|
||||
|
||||
import torch
|
||||
from transformers import modeling_attn_mask_utils
|
||||
from transformers.models.llama.modeling_llama import LlamaModel
|
||||
from transformers.models.llama.modeling_llama.LlamaModel import (
|
||||
_prepare_4d_causal_attention_mask_with_cache_position,
|
||||
)
|
||||
from transformers.utils import is_torch_bf16_gpu_available
|
||||
|
||||
# modeling_llama._prepare_4d_causal_attention_mask_for_sdpa = ( # pylint: disable=protected-access
|
||||
# patched_prepare_4d_causal_attention_mask_for_sdpa
|
||||
|
||||
Reference in New Issue
Block a user