-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support varlen FlashAttention #23
base: main
Are you sure you want to change the base?
Conversation
if softmax_scale is None: | ||
softmax_scale = q.shape[-1]**(-0.5) | ||
assert isinstance(window_size, tuple) and len(window_size) == 2 | ||
|
||
softmax_lse, out, rng_state = torch_xla._XLAC._flash_attention_forward( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SPMDFlashAttnVarlenXla
and FlashAttnVarlenQKVPackedXla
also need to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. But I found no UT for them.
tests/ops/test_flash_attn.py
Outdated
@pytest.mark.parametrize("dtype", [torch.float16, torch.bfloat16]) | ||
@pytest.mark.parametrize("mha_type", ["mha", "mqa", "gqa"]) | ||
@pytest.mark.parametrize("deterministic", [False, True]) | ||
@pytest.mark.parametrize("dtype", [torch.bfloat16]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing so many test options?
) | ||
|
||
|
||
class FlashAttention2(nn.Module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the FlashAttention2 mean? Does FA2 stand for it, or is the 2 just a magic number?
dk_xla, | ||
dv_xla, | ||
) = torch.autograd.grad(ret_xla, (q_xla, k_xla, v_xla), g_xla) | ||
ta.mark_step() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ta.sync instead.
c6b2cb0
to
c3ad6dc
Compare
No description provided.