Interface AttentionKernel
- All Known Implementing Classes:
FlashInferAttentionKernel, TorchNativeAttentionKernel
public interface AttentionKernel
Attention compute kernel (contiguous SDPA or paged FlashInfer).
-
Method Summary
Modifier and TypeMethodDescriptionbackend()Returns the backend this kernel implements.Runs attention.
-
Method Details
-
forward
Runs attention.For
AttentionBackend.TORCH_NATIVE,query/key/valueare contiguous[B,H,S,D]/[B,H,L,D]andmaskis optional.For
AttentionBackend.FLASHINFER,queryis[B,H,S,D](or[B,S,H,D]— see kernel docs);key/valuemay benullwhenAttentionContext.isPaged()(KV read from the pool).- Parameters:
query- query tensor.key- key tensor, ornullwhen paged.value- value tensor, ornullwhen paged.mask- attention mask, ornull.ctx- scale / causal / paged metadata.- Returns:
- attention output matching query layout expected by the caller
(
[B,H,S,D]for both backends in v1).
-
backend
AttentionBackend backend()Returns the backend this kernel implements.- Returns:
- backend this kernel implements.
-