You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtorchfromflash_attn.flash_attentionimportFlashMHA# Replace this with your correct GPU devicedevice="cuda:0"# Create attention layer. This is similar to torch.nn.MultiheadAttention,# and it includes the input and output linear layersflash_mha=FlashMHA(
embed_dim=128, # total channels (= num_heads * head_dim)num_heads=8, # number of headsdevice=device,
dtype=torch.float16,
)
# Run forward pass with dummy datax=torch.randn(
(64, 256, 128), # (batch, seqlen, embed_dim)device=device,
dtype=torch.float16
)
output=flash_mha(x)[0]
fromflash_attn.flash_attentionimportFlashAttention# Create the nn.Moduleflash_attention=FlashAttention()
To apply FlashAttention
The text was updated successfully, but these errors were encountered: