huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
134.58k stars 26.91k forks source link

Correct check for SDPA in Vision Language Models #30565

Closed zucchini-nlp closed 2 weeks ago

zucchini-nlp commented 6 months ago

System Info

In current implementation of VLMs, the "_supports_sdpa" attribute checks and activates SDPA attention only for the language model. For example in Llava

It should also check and if available use SDPA attention for vision tower.

We can raise a warning for composite models if only one part support sdpa, but other does not, and activate SDPA for the supported part. That waythe user knows what is happening in the background.

Verified models

NielsRogge commented 6 months ago

Edited your issue to include a list of models to check ;) feel free to expand

lucasjinreal commented 4 months ago

Please consider add for specific Vsion Encoders, such as Siglip CLIP InternViT etc.