Llama2 and CodeLlama Better Transformer Error
Author: HamidShojanazeri
Pull request: no

### System Info

- `transformers` version: 4.38.0.dev0
- Platform: Linux-5.15.0-1048-aws-x86_64-with-glibc2.31
- Python version: 3.10.13
- Huggingface_hub version: 0.20.3
- Safetensors version: 0.4.2
- Accelerate version: 0.26.1
- Accelerate config:    - compute_environment: LOCAL_MACHINE
        - distributed_type: MULTI_GPU
        - mixed_precision: bf16
        - use_cpu: False
        - debug: True
        - num_processes: 2
        - machine_rank: 0
        - num_machines: 1
        - gpu_ids: 0,1
        - rdzv_backend: static
        - same_network: True
        - main_training_function: main
        - downcast_bf16: no
        - tpu_use_cluster: False
        - tpu_use_sudo: False
        - tpu_env: []
- PyTorch version (GPU?): 2.2.0+cu118 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

```
from transformers import AutoTokenizer, AutoModelForCausalLM
import transformers
import torch

model_id = "codellama/CodeLlama-7b-Instruct-hf" # or model_id = "meta-llama/Llama-2-7b-chat-hf"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
   model_id,
   torch_dtype=torch.float16,
   device_map="auto",
)
model.to_bettertransformer()
chat = [
   {"role": "system", "content": "You are a helpful and honest code assistant expert in JavaScript. Please, provide all answers to programming questions in JavaScript"},
   {"role": "user", "content": "Write a function that computes the set of sums of all contiguous sublists of a given list."},
]
inputs = tokenizer.apply_chat_template(chat, return_tensors="pt").to("cuda")

output = model.generate(input_ids=inputs, max_new_tokens=200)
output = output[0].to("cpu")
print(tokenizer.decode(output))
```

Error logs

```
Traceback (most recent call last):
  File "/opt/hpcaas/.mounts/fs-5c62ddab/home/hamidnazeri/llama-package/llama-recipes/examples/code_llama/test.py", line 12, in <module>
    model.to_bettertransformer()
  File "/opt/hpcaas/.mounts/fs-5c62ddab/home/hamidnazeri/transformers/src/transformers/modeling_utils.py", line 4210, in to_bettertransformer
    return BetterTransformer.transform(self)
  File "/data/home/hamidnazeri/miniconda/envs/llama-recipe-feb-5-2024/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/data/home/hamidnazeri/miniconda/envs/llama-recipe-feb-5-2024/lib/python3.10/site-packages/optimum/bettertransformer/transformation.py", line 211, in transform
    raise ValueError(
ValueError: Transformers now supports natively BetterTransformer optimizations (torch.nn.functional.scaled_dot_product_attention) for the model type llama. Please upgrade to transformers>=4.36 and torch>=2.1.1 to use it. Details: https://huggingface.co/docs/transformers/perf_infer_gpu_one#flashattention-and-memory-efficient-attention-through-pytorchs-scaleddotproductattention
```

### Expected behavior

support for Llama2, Code Llama, It seems like an issue with supported models as other models such as `facebook/opt-350m` runs just fine.

cc: @younesbelkada 

Comments:
Hey! Thanks for reporting. As the error mentions, people should use the native implementation in `transformers` that supports `attn_implementation="sdpa"` or `attn_implementation="flash_attention"` to enable these feature. BetterTransformers API is deprecated. 
fyi @fxmarty as well 

thanks @ArthurZucker, I synced up with @younesbelkada offline, he pointed out the same, just wondering if we should change the error message to something more informative?

Yes definitely! Would you like to open a PR for that? 🤗  

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.