Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Attention implementation for ViT-based models #36545

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

qubvel
Copy link
Member

@qubvel qubvel commented Mar 4, 2025

What does this PR do?

Updates the way attention implementation is chosen. Instead of defining separate classes we use functional approach and switch attention implementation on the fly with congig._attn_implementaiton param.

The following model will have SDPA and FA2 support:

  • vit
  • audio-Spectrogram_transformer
  • deit
  • dinov2
  • dinov2_with_registers
  • dpt
  • ijepa
  • videomae
  • vit_mae
  • vit_msn
  • vitpose_backbone
  • vivit
  • yolos

It also affects the following models:

  • depth_anything (use dinov2 backbone)
  • zoedepth (use dinov2 backbone)

Fixes:

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@qubvel
Copy link
Member Author

qubvel commented Mar 5, 2025

run-slow: vit, audio_spectrogram_transformer, deit, dinov2, dinov2_with_registers, dpt, ijepa, videomae, vit_mae, vit_msn, vitpose_backbone, vivit, yolos

Copy link

github-actions bot commented Mar 5, 2025

This comment contains run-slow, running the specified jobs: This comment contains run-slow, running the specified jobs:

models: ['models/audio_spectrogram_transformer', 'models/deit', 'models/dinov2', 'models/dinov2_with_registers', 'models/dpt', 'models/ijepa', 'models/videomae', 'models/vit', 'models/vit_mae', 'models/vit_msn', 'models/vitpose_backbone', 'models/vivit', 'models/yolos']
quantizations: [] ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants