pub fn prefill_attention_paged(
gpu: &dyn GpuBackend,
kernel: KernelHandle,
q: DevicePtr,
k_cache: DevicePtr,
v_cache: DevicePtr,
output: DevicePtr,
block_table: DevicePtr,
q_len: u32,
kv_len: u32,
q_offset: u32,
num_q_heads: u32,
num_kv_heads: u32,
head_dim: u32,
cache_block_size: u32,
sliding_window: u32,
inv_sqrt_d: f32,
stream: u64,
) -> Result<()>Expand description
Paged prefill Flash Attention — reads K/V from paged KV cache via block_table.
For chunked prefill chunk 1+: Q comes from GEMM (contiguous), K/V reside in the paged cache from prior chunks. Replaces per-token paged decode loop with a single Flash Attention pass (O(N) per chunk instead of O(N^2) total).
Kernel: inferspark_prefill_paged(Q, K_cache, V_cache, O, block_table, q_len, kv_len, q_offset, nq, nkv, hd, block_size, inv_sqrt_d)
Grid: (num_q_heads, ceil(q_len/32), 1) Block: (128, 1, 1)