huggingface / transformers

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

Correct check for SDPA in Vision Language Models #30565

Open zucchini-nlp opened 5 months ago

zucchini-nlp commented 5 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 5 months ago

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

lucasjinreal commented 3 months ago

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