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

Support varlen FlashAttention #23

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

Support varlen FlashAttention #23

wants to merge 3 commits into from

Conversation

Seventeen17
Copy link

No description provided.

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(
Copy link
Contributor

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.

Copy link
Author

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.

@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])
Copy link
Contributor

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):
Copy link
Contributor

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()
Copy link
Contributor

Choose a reason for hiding this comment

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

use ta.sync instead.

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.

3 participants