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 flash-attention in forms of custom-call #17

Merged
merged 4 commits into from
Apr 17, 2024

Conversation

ApsarasX
Copy link

@ApsarasX ApsarasX commented Apr 12, 2024

Usage:

import torch_xla.core.functions as xf

xf.flash_attn(
    query,
    key,
    value,
    *,
    dropout_rate=0.0,
    scale=None,
    is_causal=False,
    alibi_slopes=None,
    deterministic=False,
    return_softmax=False,
)

xf.flash_attn_varlen(
    query,
    key,
    value,
    cu_seqlens_query,
    cu_seqlens_key,
    *,
    max_seqlen_q,
    max_seqlen_k,
    dropout_rate=0.0,
    scale=None,
    is_causal=False,
    alibi_slopes=None,
    deterministic=False,
    return_softmax=False,
)

@ApsarasX ApsarasX force-pushed the wengang/flash-attention-rebase branch from c8f076e to b89507d Compare April 15, 2024 06:19
test/test_flash_attn.py Show resolved Hide resolved
test/test_flash_attn.py Show resolved Hide resolved
@ApsarasX ApsarasX force-pushed the wengang/flash-attention-rebase branch from c2e19ce to 52f1d1f Compare April 17, 2024 02:35
@ApsarasX ApsarasX merged commit 08306b7 into master Apr 17, 2024
0 of 2 checks passed
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