masked-mha-runtime / examples /basic_usage.py
liangsu9988's picture
Publish GROOT N1.7 Thor kernel sources
77368d6 verified
Raw
History Blame
334 Bytes
import torch
from kernels import get_kernel
mha = get_kernel("flashrt/masked-mha-runtime", version=1)
q = torch.randn((41, 32, 48), device="cuda", dtype=torch.bfloat16)
k = torch.randn_like(q)
v = torch.randn_like(q)
logits = mha.allocate_workspace(q, k)
out = torch.empty_like(q)
mha.forward_static(q, k, v, logits=logits, out=out)