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

[Draft]: Add flash attention to whisper (unsure how correct this is) #2722

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

Conversation

Murad-Awad
Copy link

Whisper should be able to support flash attention. I attempted to add this in this PR; I don't know much about flash attention and a lot of this was pattern matching with other examples in the repo. I need to take a more detailed look later.

let k = k.transpose(1, 2)?;
let v = v.transpose(1, 2)?;
let softmax_scale = 1f32 / (self.n_head as f32).sqrt();
flash_attn(&q, &k, &v, softmax_scale, true)?.transpose(1, 2)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all attention is technically causal in whisper given that it predicts tokens sequentially. I could be wrong on this though and I have a very cursory understanding of flash attention.

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