prefill_attention_paged_dflash_bf16_indirect

Function prefill_attention_paged_dflash_bf16_indirect 

Source
pub fn prefill_attention_paged_dflash_bf16_indirect(
    gpu: &dyn GpuBackend,
    kernel: KernelHandle,
    q: DevicePtr,
    k_cache: DevicePtr,
    v_cache: DevicePtr,
    output: DevicePtr,
    block_table: DevicePtr,
    q_len: u32,
    kv_len_q_offset_dev: DevicePtr,
    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

DFlash γ-block paged Flash Attention — BF16 KV cache, INDIRECT scalar args.

Phase 5 (CUDA graph) variant of prefill_attention_paged_dflash. Reads kv_len, q_offset, and q_rope_pos from device pointers at kernel entry instead of taking them as kernel scalar arguments. This makes the launch graph-friendly: the host writes the dynamic triple into kv_len_q_offset_dev (12 bytes: [u32 kv_len, u32 q_offset, u32 q_rope_pos]) BEFORE entering the captured region, and the captured graph node binds only the pointer — replays pick up whatever values the host wrote pre-launch. q_offset = ctx_count (cache-block addressing); q_rope_pos = absolute decode position (query RoPE rotation, decoupled from cache addressing).

Resolves to kernel inferspark_prefill_paged_indirect. The kernel binary is otherwise identical to inferspark_prefill_paged (causal_mask_enabled = 0 is still hardcoded here on the launch side).

Phase B note: defined but NOT YET WIRED IN to forward_block_layer_paged. Phase C swaps the dispatcher; Phase D adds graph capture around it.