Skip to content

feat: flashv2 #94

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

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

feat: flashv2 #94

wants to merge 4 commits into from

Conversation

koritsky
Copy link
Contributor

@koritsky koritsky commented Apr 8, 2024

Add flash attention v2
Basically, just extracted flash specific changes from https://github.com/yaak-ai/carGPT/tree/xformers-flashv2

Tested and it demonstrated running speed improvements: mean duration of train/val step (they are pretty similar) dropped by ~15% (1.9 -> 1.6 s)

@koritsky
Copy link
Contributor Author

koritsky commented Apr 8, 2024

facebookresearch/xformers#700

Probably small performance increase is because we use custom attention masks

@koritsky koritsky marked this pull request as draft April 8, 2024 09:30
@koritsky koritsky changed the title add flashv2 feat: flashv2 Apr 8, 2024
@koritsky koritsky marked this pull request as ready for review April 8, 2024 11:24
@sandhawalia sandhawalia requested a review from egorchakov April 9, 2024 08:14
Copy link
Contributor

@egorchakov egorchakov left a comment

Choose a reason for hiding this comment

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

we'd also probably wanna add a corresponding branch to https://github.com/yaak-ai/carGPT/blob/main/cargpt/components/llm.py#L229 (for attention viz at inference time)

@@ -3,6 +3,8 @@
from tensordict.tensorclass import _eq, _getitem # noqa: PLC2701
from tensordict.utils import IndexType

from cargpt.utils.attention import MemoryEfficientScaledDotProduct # noqa #type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

do we actually need this exported here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to import it somewhere, so I find __init__.py the best choice

@koritsky
Copy link
Contributor Author

koritsky commented Apr 9, 2024

So let's just merge it without viz feature. Can still be used at full grown training after experimenting stage is completed (never)

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