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

fix: handle SDPA attention implementation for vision encoder #59

Merged
merged 2 commits into from
Nov 11, 2024
Merged

Conversation

xffxff
Copy link
Collaborator

@xffxff xffxff commented Nov 11, 2024

ref: #54

AutoModelForCausalLM.from_pretrained(model_id_or_path, device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True, attn_implementation="sdpa") currently raises an error because our ViT model does not support the sdpa attention implementation. This PR introduces a fallback mechanism: when attn_implementation="sdpa" is set, the ViT model will automatically use "flash_attention_2" instead, while the language model continues to use sdpa. A warning will be issued to inform the user of this fallback behavior.

@xffxff xffxff merged commit b84e928 into main Nov 11, 2024
1 check passed
@xffxff xffxff deleted the sdpa branch November 11, 2024 07:54
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.

1 participant