Add SDPA and Flash Attention support for OWL-ViT#44159
Open
samuelleecong wants to merge 2 commits intohuggingface:mainfrom
Open
Add SDPA and Flash Attention support for OWL-ViT#44159samuelleecong wants to merge 2 commits intohuggingface:mainfrom
samuelleecong wants to merge 2 commits intohuggingface:mainfrom
Conversation
Refactor OwlViTAttention to use ALL_ATTENTION_FUNCTIONS for dynamic attention backend dispatch, enabling SDPA and Flash Attention 2 support. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: owlvit |
Contributor
|
#42136 already started this effort so I'd like to focus on one PR. Maybe you can sync on that PR instead |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #28103
OwlViTAttentionto useALL_ATTENTION_FUNCTIONSfor dynamic attention backend dispatch (same pattern as CLIP)eager_attention_forwardstandalone function with the standardized interface(batch * heads, seq, head_dim)to 4D(batch, heads, seq, head_dim)for SDPA/Flash compatibility_supports_sdpa,_supports_flash_attn, and_supports_attention_backendflags onOwlViTPreTrainedModelTest plan
pytest tests/models/owlvit/ -v— 327 passed, 288 skipped, 0 failedpytest tests/models/owlvit/ -v -k "sdpa"— all SDPA-specific tests passatol=1e-5across all model outputs (text embeds, image embeds, hidden states, logits)🤖 Generated with Claude Code