Class FlashInferAttentionKernel
- All Implemented Interfaces:
AttentionKernel
Decode (S==1) uses FlashInfer BatchDecodeWithPagedKVCache
(vendored headers). Prefill uses GPU page gather + LibTorch SDPA with the
same mask semantics as torch_native.
Ragged contiguous prefill (vision tower) uses
BatchPrefillWithRaggedKVCache when supported, otherwise batched SDPA
inside the FlashInfer module.
Expects AttentionContext.isPaged() with CSR metadata and a
FlashInferWorkspace, or AttentionContext.isRaggedContiguous()
with cumulative segment indptr. Query layout [B, H, S, D] for paged;
[N, H, D] NHD for ragged.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbackend()Returns the backend this kernel implements.Runs attention.
-
Constructor Details
-
FlashInferAttentionKernel
public FlashInferAttentionKernel()Creates a FlashInfer attention kernel.
-
-
Method Details
-
forward
Description copied from interface:AttentionKernelRuns 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).- Specified by:
forwardin interfaceAttentionKernel- 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
Description copied from interface:AttentionKernelReturns the backend this kernel implements.- Specified by:
backendin interfaceAttentionKernel- Returns:
- backend this kernel implements.
-