[sdpa] Allow prefill to use FA kernel with StaticCache
Author: Cyrilvallez
Pull request: yes

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=47094)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47094)
<!-- ci-dashboard-badge:end -->

# What does this PR do?

As per the title. In general, we have no reason to constrain the prefill to have a mask with sdpa, as most usual situations will not need it. It's more efficient to let it dispatch to the FA kernel if we can. 

It also has the following benefits:
- much faster, with quadratic benefits as the prefill size increases (e.g. 10% faster for input size `(1, 512)` and max cache len `2048`, and a huge 260% faster for input size `(1, 8k)` and max cache length `16k`)
- aligns `_ignore_causal_mask_sdpa` to be the same for cuda and xpu, saving redundant code
- improve the previous xpu version, so that a model that returns `None` early via the `create_mask_for_generate` call will STILL return None quickly after reentering the mask creation function in the model (see issue https://github.com/huggingface/transformers/issues/46962 and PR https://github.com/huggingface/transformers/pull/47019), which should avoid headaches in the future

With a llama 8B with `32` layers, i.e. `32` attention calls during the prefill, an input size of `(1, 512)`, and a max cache length of `2048`, I measured the prefill (excluding cache lazy init) to take an average of `0.029` s with this PR, compared to `0.032` s on main -> 10% faster for small sizes.
For bigger sizes, the benefits are much greater: for size `(1, 8192)` and max cache length `16384`, prefill took `0.735` s on main vs `0.280` s on this PR -> 260% faster

Script used for benchmarking:
<details>

<summary>benchmark.py</summary>

```python
import torch
from transformers import AutoModelForCausalLM, StaticCache, GenerationConfig
import time

model_id = "meta-llama/Llama-3.1-8B-Instruct"
device = 0
prefill_size = 8192
max_len = 16384

model = AutoModelForCausalLM.from_pretrained(model_id, device_map=device)

ids = torch.randint(100, 200, (1, prefill_size), device=device)
generation_config = GenerationConfig()
model_kwargs = {
    "past_key_values": StaticCache(config=model.config, max_cache_len=max_len),
    "position_ids": torch.arange(prefill_size, device=device)[None, :],
    "attention_mask": torch.ones_like(ids)
}

# Lazy init the cache to avoid measuring cache allocation
with torch.no_grad():
    out = model._prefill(
        ids,
        generation_config=generation_config,
        model_kwargs=model_kwargs,
    )

N = 100
times = []
for _ in range(N):
    with torch.no_grad():
        # Reset cache to empty
        model_kwargs["past_key_values"].reset()
        t0 = time.time()
        out = model._prefill(
            ids,
            generation_config=generation_config,
            model_kwargs=model_kwargs,
        )
        dt = time.time() - t0
        times.append(dt)

print(f"Took {torch.mean(torch.tensor(times)):.3f} s in average")
```

</details>

cc @vasqu, @kaixuanliu for viz as well 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_47094). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=47094)
**Latest run:** [28784316088:1](https://github.com/huggingface/transformers/actions/runs/28784316088)
**Result:** `failure` | **Jobs:** 15 | **Tests:** 171,547 | **Failures:** 6 | **Duration:** 25h 41m

<!-- ci-dashboard-recap:end -->

Thanks @Cyrilvallez , I verified the correctness and benchmarked the performance on XPU as well:
| Settings | main | this PR | speedup
|-----|-----|-----|-----|
| seq=512, cache=2048   | 35.1 ms   | 32.7 ms   | ~7% |
| seq=2048, cache=8192   | 80.5ms   | 43.3 ms   | ~86%|
| seq=4096, cache=8192   | 148.3ms   | 78.5 ms   | ~89%|

basically align with what your data collected on cuda device.

Thanks a lot for double checking perfs and correctness! 🤗